use of com.intellij.find.findUsages.CustomUsageSearcher in project intellij-community by JetBrains.
the class PyTestCase method findUsage.
/**
* Finds all usages of element. Works much like method in {@link com.intellij.testFramework.fixtures.CodeInsightTestFixture#findUsages(com.intellij.psi.PsiElement)},
* but supports {@link com.intellij.find.findUsages.CustomUsageSearcher} and {@link com.intellij.psi.search.searches.ReferencesSearch} as well
*
* @param element what to find
* @return usages
*/
@NotNull
protected Collection<PsiElement> findUsage(@NotNull final PsiElement element) {
final Collection<PsiElement> result = new ArrayList<>();
final CollectProcessor<Usage> usageCollector = new CollectProcessor<>();
for (final CustomUsageSearcher searcher : CustomUsageSearcher.EP_NAME.getExtensions()) {
searcher.processElementUsages(element, usageCollector, new FindUsagesOptions(myFixture.getProject()));
}
for (final Usage usage : usageCollector.getResults()) {
if (usage instanceof PsiElementUsage) {
result.add(((PsiElementUsage) usage).getElement());
}
}
for (final PsiReference reference : ReferencesSearch.search(element).findAll()) {
result.add(reference.getElement());
}
for (final UsageInfo info : myFixture.findUsages(element)) {
result.add(info.getElement());
}
return result;
}
Aggregations