int (@NotNull final PsiElement parent) { PsiElement element = parent; if (element instanceof PsiDocCommentOwner) { PsiDocComment comment = ((PsiDocCommentOwner)element).getDocComment(); if (comment != null) { element = comment.getNextSibling(); while (element instanceof PsiWhiteSpace) { element = element.getNextSibling(); } } } if (element != null) { TextRange range = element.getTextRange(); if (range != null) { return range.getStartOffset(); } LOG.error("Range should not be null: " + element + "; " + element.getClass()); } LOG.error("Element should not be null: " + parent.getText()); return parent.getTextRange().getStartOffset(); }