boolean (@NotNull PsiElement host, @NotNull PsiFile containingFile, boolean probeUp, @NotNull PsiLanguageInjectionHost.InjectedPsiVisitor visitor) { //do not inject into nonphysical files except during completion if (!containingFile.isPhysical() && containingFile.getOriginalFile() == containingFile) { PsiElement context = InjectedLanguageManager.getInstance(containingFile.getProject()).getInjectionHost(containingFile); if (context == null) return false; PsiFile file = context.getContainingFile(); if (file == null || !file.isPhysical() && file.getOriginalFile() == file) return false; } if (containingFile.getViewProvider() instanceof InjectedFileViewProvider) return false; // no injection inside injection PsiElement inTree = loadTree(host, containingFile); if (inTree != host) { host = inTree; containingFile = host.getContainingFile(); } PsiDocumentManager documentManager = PsiDocumentManager.getInstance(containingFile.getProject()); Document document = documentManager.getDocument(containingFile); if (document == null || documentManager.isCommitted(document)) { probeElementsUp(host, containingFile, probeUp, visitor); } return true; }