void (@NotNull PsiLanguageInjectionHost host, @NotNull PsiElement element, String @NotNull ... namesToSkip) { final List<Pair<PsiElement, TextRange>> files = InjectedLanguageManager.getInstance(host.getProject()).getInjectedPsiFiles(host); if (files == null) return; for (Pair<PsiElement, TextRange> pair : files) { pair.getFirst().accept( new PyRecursiveElementVisitor() { @Override public void visitPyReferenceExpression(@NotNull PyReferenceExpression expression) { super.visitPyReferenceExpression(expression); if (!ArrayUtil.contains(expression.getText(), namesToSkip)) { rememberReference(expression, element); rememberReferenceInInjectionHost(expression, host); } } }); } }