boolean (int offset, PsiElement namedElement, PsiElement element) { if (namedElement == null) return false; TextRange range = namedElement.getTextRange(); if (range.getLength() == 0) return false; boolean isInNamedElement = range.contains(offset); return isInNamedElement || element.getTextRange().contains(offset-1); }