boolean (@NotNull Project project, @NotNull UExpression expression) { Pattern pattern = myCachedCommentPattern; if (pattern != null) { PsiElement sourcePsi = expression.getSourcePsi(); if (sourcePsi == null) return false; PsiFile file = sourcePsi.getContainingFile(); Document document = PsiDocumentManager.getInstance(project).getDocument(file); if (document == null) return false; int line = document.getLineNumber(sourcePsi.getTextRange().getStartOffset()); int lineStartOffset = document.getLineStartOffset(line); CharSequence lineText = document.getCharsSequence().subSequence(lineStartOffset, document.getLineEndOffset(line)); Matcher matcher = pattern.matcher(lineText); int start = 0; while (matcher.find(start)) { start = matcher.start(); PsiElement element = file.findElementAt(lineStartOffset + start); if (PsiTreeUtil.getParentOfType(element, PsiComment.class, false) != null) return true; if (start == lineText.length() - 1) break; start++; } } return false; }