List<UsageInfo> (@NotNull PsiNamedElement element, boolean forHighlightUsages) { final List<UsageInfo> usages = new ArrayList<>(); final FindUsagesHandlerBase handler = new PyPsiFindUsagesHandlerFactory() { }.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; }, FindUsagesHandlerBase.createFindUsagesOptions(element.getProject(), null)); } return usages; }