int () { if (myLineNumber == -1) { PsiElement psiElement = getPsiElement(); if (psiElement == null) return -1; if (!psiElement.isValid()) return -1; LOG.assertTrue(psiElement.isPhysical()); InjectedLanguageManager manager = InjectedLanguageManager.getInstance(psiElement.getProject()); PsiFile containingFile = manager.getTopLevelFile(psiElement); Document document = PsiDocumentManager.getInstance(psiElement.getProject()).getDocument(containingFile); if (document == null) return -1; TextRange textRange = getTextRange(); if (textRange == null) return -1; textRange = manager.injectedToHost(psiElement, textRange); int startOffset = textRange.getStartOffset(); int textLength = document.getTextLength(); LOG.assertTrue(startOffset <= textLength, getDescriptionTemplate() + " at " + startOffset + ", " + textLength); myLineNumber = document.getLineNumber(startOffset); } return myLineNumber; }