Search in sources :

Example 1 with PyFindUsagesHandlerFactory

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;
}
Also used : FindUsagesHandler(com.intellij.find.findUsages.FindUsagesHandler) PyFindUsagesHandlerFactory(com.jetbrains.python.findUsages.PyFindUsagesHandlerFactory) UsageInfo(com.intellij.usageView.UsageInfo) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

FindUsagesHandler (com.intellij.find.findUsages.FindUsagesHandler)1 UsageInfo (com.intellij.usageView.UsageInfo)1 PyFindUsagesHandlerFactory (com.jetbrains.python.findUsages.PyFindUsagesHandlerFactory)1 NotNull (org.jetbrains.annotations.NotNull)1