int (@NotNull PsiElement element) { TextRange textRange = element.getTextRange(); if (textRange == null) return 0; PsiAnnotation lastAnnotation = null; for (PsiElement child = element.getLastChild(); child != null; child = child.getPrevSibling()) { if (child instanceof PsiAnnotation) { lastAnnotation = (PsiAnnotation)child; break; } } if (lastAnnotation == null) { return textRange.getStartOffset(); } ASTNode node = lastAnnotation.getNode(); if (node != null) { do { node = TreeUtil.nextLeaf(node); } while (node != null && ElementType.JAVA_COMMENT_OR_WHITESPACE_BIT_SET.contains(node.getElementType())); } if (node != null) return node.getTextRange().getStartOffset(); return textRange.getStartOffset(); }