How to obtain the references to a class from non-java files?
Question: how to obtain the references to a class from non-java files?
In order to determine if a class is only used by test code, I
- 1°/ obtain all the references to it (see below), and
- 2°/ check if any of them is located in a production source tree.
public static PsiReference[] referencesTo (PsiMember i_psiMember,
boolean i_ignoreAccessScope)
{
PsiSearchHelper searchHelper =
i_psiMember.getManager().getSearchHelper();
SearchScope searchUseScope = i_psiMember.getUseScope();
PsiReference[] references = searchHelper.findReferences
(i_psiMember, searchUseScope, i_ignoreAccessScope);
return references;
}
Problem: I miss the xml references, like the ones in plugin.xml.
Question:
How can I obtain those missing references?
TIA
Alain
Please sign in to leave a comment.
searchHelper.processUsagesInNonJavaFiles()
-
Maxim Shafirov
http://www.jetbrains.com
"Develop with pleasure!"
Maxim
>
This method requires a PsiNonJavaFileReferenceProcessor, that cannot be
obtained from the openAPI.
Added:
"unobfuscate a PsiNonJavaFileReferenceProcessor source"
http://www.jetbrains.net/jira/browse/IDEA-2496
Alain
Alain Ravet wrote:
Alain, PsiNonJavaFileReferenceProcessor is a callback-interface that is meant to be
implemented by yourself. The method PsiNonJavaFileReferenceProcessor.process() will be
called by PsiSearchHelper.processUsagesInNonJavaFiles() for every reference that is found
in non-java files. Without implementing that yourself, processUsagesInNonJavaFiles() would
be totally useless because there's no return value.
Sascha
Sascha
>Alain, PsiNonJavaFileReferenceProcessor is a callback-interface that is meant to be
>implemented by yourself. The method PsiNonJavaFileReferenceProcessor.process() will be
>called by PsiSearchHelper.processUsagesInNonJavaFiles() for every reference that is found
>in non-java files. Without implementing that yourself, processUsagesInNonJavaFiles() would
>be totally useless because there's no return value.
>
>
I just want to use the PsiNonJavaFileReferenceProcessor that IDEA uses
when you run a Find Usage + search in non-java files.
, and that finds references in plugin.xml, for example.
Why should I reimplement it: it's already there?!
Alain
Not correct:
this method processes plain text usages, but those usage in xml are not
considered plain text now, but rather usages in foreign language.
Calling getReferences() like in Alain's example should find references in
xml as well. If it does not, this is a sure bug.
Eugene.
"Maxim Shafirov (JetBrains)" <max@jetbrains.com> wrote in message
news:c8a8a1bfd9ec8c7384925fd3c05@news.jetbrains.com...
>
>
>
Eugene Vigdorchik (JetBrains) wrote:
>Calling getReferences() like in Alain's example should find references
>in xml as well. If it does not, this is a sure bug.
>
>
You're right: it works fine, and the references in plugin.xlm - f.ex-
are already found by getReferences().
Alain