boolean (@NotNull PsiErrorElement element) { if (isKnownSubLanguage(element.getParent().getLanguage())) { // // Immediately discard filters with non-matching template view provider if already known // FileViewProvider viewProvider = element.getUserData(TOP_LEVEL_VIEW_PROVIDER); if (viewProvider == null) { viewProvider = InjectedLanguageManager.getInstance(element.getProject()).getTopLevelFile(element).getViewProvider(); element.putUserData(TOP_LEVEL_VIEW_PROVIDER, viewProvider); } if (!isTemplateViewProvider(viewProvider)) return true; PsiFile psiFile = element.getContainingFile(); TextRange range = element.getTextRange(); // // An error can occur after template element or before it. Check both. // if (isNearTemplateExpressions(psiFile, range.getStartOffset(), range.getEndOffset()) || hasErrorElementsBeforeAndUp(element) || PsiTreeUtil.findChildOfType(element, OuterLanguageElement.class) != null) { return false; } } return true; }