How to check PsiMethod is invoked?


I have a class like this:

public class ChainClass {
public ChainClass methodA() {return this;}
public ChainClass methodB() {return this;}
public ChainClass methodC() {return this;}
pubilc ChainClass methodD() {return this;}


I want to provide a  Annotator or other component, can provide a feature:

If PsiMethod -> methodD is invoked, I should check PsiMethod -> methodA() are they called at the same time, then prompt an error.


ChainClass cc = new ChainClass()

It's ok!


ChainClass cc = new ChainClass()

It's not ok, should prompt an error!

1 comment
Comment actions Permalink

You can use Annotator or Inspection to perform such highlighting

You'll need to write code to navigate the PSI method calls and act accordingly. If you want to find all usages of a given method, you can use ReferencesSearch.


Please sign in to leave a comment.