I had problems with reference-search before when variables contained non-java symbols like $ that are allowed in my language. I have implemented the referenceSearch EP and used a PsiSearchHelper that did not use the option
Still, I now ran into another issue. In the following code, the first "var" (the underscore is an operator and not part of the variable!) is the target. It refers to itself and both of the two remaining "var" also refer to it.
var_ :> var_ + var
I have written a small action that simply checks all references within a file and the output for the above code is (-> means "resolves to")
"var" at offset 1 -> "var" at offset 1 (is Ref: true, soft: false)
"var" at offset 9 -> "var" at offset 1 (is Ref: true, soft: false)
"var" at offset 16 -> "var" at offset 1 (is Ref: true, soft: false)
However, the second "var_" which acts as "usage" and not as a target, doesn't get highlighted.
I suspect the error is within the optimized string-search that IntelliJ does before it checks the locations for valid usages.
Does some know, where exactly these string-occurrences of "var" are collected within the IdentifierHighlighterPass, so that I can debug, where things go south? Of course, if someone has a solution, I'm all ears!