use of com.intellij.find.findUsages.FindUsagesHandler in project intellij-community by JetBrains.
the class PyRefactoringUtil method findUsages.
@NotNull
public static List<UsageInfo> findUsages(@NotNull PsiNamedElement element, boolean forHighlightUsages) {
final List<UsageInfo> usages = new ArrayList<>();
final FindUsagesHandler handler = new PyFindUsagesHandlerFactory().createFindUsagesHandler(element, forHighlightUsages);
assert handler != null;
final List<PsiElement> elementsToProcess = new ArrayList<>();
Collections.addAll(elementsToProcess, handler.getPrimaryElements());
Collections.addAll(elementsToProcess, handler.getSecondaryElements());
for (PsiElement e : elementsToProcess) {
handler.processElementUsages(e, usageInfo -> {
if (!usageInfo.isNonCodeUsage) {
usages.add(usageInfo);
}
return true;
}, FindUsagesHandler.createFindUsagesOptions(element.getProject(), null));
}
return usages;
}
use of com.intellij.find.findUsages.FindUsagesHandler in project intellij-community by JetBrains.
the class PyStaticCallHierarchyUtil method findUsages.
private static Collection<UsageInfo> findUsages(@NotNull final PsiElement element) {
final FindUsagesHandler handler = createFindUsageHandler(element);
if (handler == null) {
return Lists.newArrayList();
}
final CommonProcessors.CollectProcessor<UsageInfo> processor = new CommonProcessors.CollectProcessor<>();
final PsiElement[] psiElements = ArrayUtil.mergeArrays(handler.getPrimaryElements(), handler.getSecondaryElements());
final FindUsagesOptions options = handler.getFindUsagesOptions(null);
for (PsiElement psiElement : psiElements) {
handler.processElementUsages(psiElement, processor, options);
}
return processor.getResults();
}
Aggregations