void (@Nullable PsiLanguageInjectionHost node) { if (node == null) return; final List<Pair<PsiElement, TextRange>> files = InjectedLanguageManager.getInstance(node.getProject()).getInjectedPsiFiles(node); if (files != null) { for (Pair<PsiElement, TextRange> pair : files) { new PyRecursiveElementVisitor() { @Override public void visitPyElement(@NotNull PyElement element) { super.visitPyElement(element); if (element instanceof PyReferenceOwner) { final PyResolveContext resolveContext = PyResolveContext.defaultContext(myTypeEvalContext); final PsiPolyVariantReference reference = ((PyReferenceOwner)element).getReference(resolveContext); markTargetImportsAsUsed(reference); } } }.visitElement(pair.getFirst()); } } }