How to make reference be marked as usage, if it has different text from referenced element.

I have some classes, marked with annotation @UiController("classId"), that provided special id for them.  The classes can be referenced by this "classId". These references are showed in Usages only if id equals class name. How to make references be showed in Usage independent of their text?

Thank you.

3 comments

Hi Alexander,

you need to provide custom searcher, you may see e.g. `org.jetbrains.plugins.javaFX.fxml.refs.JavaFxControllerFieldSearcher` for sample code.

Anna

0

Hi Anna!

Sorry for long silence! I implemented my searcher and it correctly search the usages. But the class is still marked as unused. Why Idea doesn't take in account my usages? I figured out, that when Idea searches for usages of some element for highlighting, it uses LocalSearchScope with single file inside. But how than it find usages from different files?

0

Hi,

actually the scope should be global. Could you please try to debug `com.intellij.codeInsight.daemon.impl.UnusedSymbolUtil#isReallyUsed`, especially `processUsages` inside?

Thanks,

Anna

0

Please sign in to leave a comment.