int (Document document, PsiElement element) { while (element instanceof PsiWhiteSpace || element instanceof PsiComment) { element = element.getNextSibling(); } if (element == null) return -1; TextRange range = element.getTextRange(); return document.getLineNumber(range.getEndOffset()); }