Registering problem with a Java class different than the one being visited

I have an inspection that registers problems while visiting a Java class.

I'd like to register some of them to appear in the file for a different class.

I'm using something like this:


JavaPsiFacade psiFacade = JavaPsiFacade.getInstance(classBeingVisited.getProject());
PsiClass anotherClass = psiFacade.findClass("another.class.qualified.name", classBeingVisited.getResolveScope());
problemsHolder.registerProblem(anotherClass.getContainingFile(), "Error");

However the registered problem appears in classBeingVisited.java instead of anotherClass.java.
Is there a way to have the desired behavior?

 

0

Hi Karl,

problemsHolder contains a file where the problems are collected, argument of a `registerProblem` method is expected to be inside a file. Actually local inspections are not supposed to highlight something in another file cause refresh of highlighting is not evident at all. The file where you try to highlight something could be closed and the work is not required at all, etc.

Why can't you highlight the code in open file depending on some other place? If you would describe the inspection in more details, probably there are another way to solve the problem.

Anna

0

请先登录再写评论。