Resolved function parameter without usage
Hi,
i'm working on a custom language plugin for R. I've recently tried to improve its handling of -- someR-version of -- vargargs Here is how it looks like
function(...) as.character ( ... )
The argument of as.character is correctly resolved to the parameter of the function. However the parameter is tagged as "not used", so the relation is no bi-directional as expected:

The implemented unused parameter inspection looks pretty standard to me:
Query<PsiReference> search = ReferencesSearch.search(o);
PsiReference first = search.findFirst();
if (first == null) {
myProblemHolder.registerProblem(o, "Unused parameter " + o.getText(), ProblemHighlightType.LIKE_UNUSED_SYMBOL);
}
While digging through the stacktrace, I've stumbled over bits in com.intellij.psi.impl.search.LowLevelSearchUtil#getTextOccurrences where identifier are checked for java-validness with com.intellij.psi.impl.search.LowLevelSearchUtil#checkJavaIdentifier.
Is it possible that this prevents my ... to be reference-searched because they are not a valid java identifier ? Can I adjust it somehow?
I've also checked, and com.r4intellij.psi.references.RReferenceImpl#isReferenceTo (which is my implementation of com.intellij.psi.PsiReference#isReferenceTo is never called, so IJ did not find any elements with the same name worth checking.
Best,
Holger
Please sign in to leave a comment.
So find usages doesn't work as well, correct? What is the use scope of your parameter?
Anna
Hi Anna,
"Just" find usages doesn't work, the other direction works, that is the parameter is resolved correctly to the function parameter:
Not sure if I get your question right, but the scope of "..." is local (similar to a method parameter in java). And for all other identifiers usage search is working correctly. E.g
is working in both directions.
Just in case the identifier is dots-only like ., .., ... or .... and so on ReferencesSearch.search(o).findFirst() in Idea seems unable to resolve it. However, those identifiers are valid in my custom language (R).
It maybe because of some mistake in my code, but since it's working for all other identifier, and because of the above mentioned internal validation using LowLevelSearchUtil, I would suspect the Idea internals to cause the problem.
Any help or advice on how to enable dot-only identifiers would be highly appreciated.
Best,
Holger
I wanted to ensure that IDEA doesn't work consistently ;)
Then you need to implement your own reference searcher, like e.g. com.intellij.psi.impl.search.SimpleAccessorReferenceSearcher, cause LowLevelSearchUtil skips such text indeed and you would need to proceed manually.
Sorry for the inconvenience,
Anna