use of com.jetbrains.python.findUsages.PyFindUsagesHandlerFactory 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;
}
Aggregations