boolean (@NotNull Project project, @NotNull Document hostDocument, int hostOffset) { PsiFile hostPsiFile = PsiDocumentManager.getInstance(project).getCachedPsiFile(hostDocument); if (hostPsiFile == null || !hostPsiFile.isValid()) return false; List<DocumentWindow> documents = InjectedLanguageManager.getInstance(project).getCachedInjectedDocumentsInRange(hostPsiFile, TextRange.create(hostOffset, hostOffset)); for (DocumentWindow document : documents) { if (document.isValid() && document.getHostRange(hostOffset) != null) return true; } return false; }