|
|
|
Property references are looked in XML/JSP/JSPX files only.
What about this simple solution:
FindUsageProvider: public FindUsageHint[] getFindUsageHints(PsiElement elem) public class FindUsageHint So IDEA first calls this method to get all words to be search for. It actually possible for quite a while in Demetra. You're to register your own custom reference searcher to a ref searchers registry as follows:
ReferenceSearch.INSTANCE.registerExecutor(new CustomReferenceSearcher());
somwhere at plugin loading time. /** * @author max */ public class CustomReferencesSearcher implements QueryExecutor<PsiReference, ReferencesSearch.SearchParameters> { public boolean execute(final ReferencesSearch.SearchParameters params, final Processor<PsiReference> consumer) { final PsiElement target = params.getElementToSearch(); final SearchScope searchScope = limitToFileType(params.getScope(), StdFileTypes.XML); // Your custom language file type here if (target instanceof PsiMethod) { String name = ((PsiMethod)target).getName(); if (name.startsWith("xxx")) { String searchText = "yyy" + name.substring(3); final TextOccurenceProcessor processor = new TextOccurenceProcessor() { public boolean execute(PsiElement element, int offsetInElement) { final PsiReference[] refs = element.getReferences(); for (PsiReference ref : refs) { if (ref.getRangeInElement().contains(offsetInElement)) { if (ref.isReferenceTo(target)) { return consumer.process(ref); } } } return true; } }; return PsiManager.getInstance(target.getProject()).getSearchHelper().processElementsWithWord(processor, searchScope, searchText, UsageSearchContext.IN_CODE, true); } } return true; } private static SearchScope limitToFileType(SearchScope scope, final FileType type) { return scope.intersectWith(new GlobalSearchScope() { public boolean contains(VirtualFile file) { return file.getFileType() == type; } public int compare(VirtualFile file1, VirtualFile file2) { return 0; // irrelevant } public boolean isSearchInModuleContent(Module aModule) { return true; } public boolean isSearchInLibraries() { return false; } }); } } |
|||||||||||||||||||||||||||||||||||||||||||||||||||
Please JB, any news?