boolean (@Nullable PsiElement element) { if (element == null) return false; PsiElement cur = element; PsiElement next = cur.getParent(); while (next != null) { if (cur == myStartElement || cur == myEndElement || next == myParent && cur.getTextRangeInParent().getStartOffset() >= myStartElement.getTextRangeInParent().getStartOffset() && cur.getTextRangeInParent().getEndOffset() <= myEndElement.getTextRangeInParent().getEndOffset()) { return true; } cur = next; next = cur.getParent(); } return false; }