PsiElement (@NotNull Project project, PsiElement decl, Locator location, PsiFile file) { final int column = location.getColumnNumber(); final int line = location.getLineNumber(); final Document document = PsiDocumentManager.getInstance(project).getDocument(file); assert document != null; if (line <= 0 || document.getLineCount() < line - 1) { return decl; } final int startOffset = document.getLineStartOffset(line - 1); final PsiElement at; if (column > 0) { if (decl.getContainingFile().getFileType() == RncFileType.getInstance()) { return new RncLocationPsiElement(file, startOffset, column); } at = file.findElementAt(startOffset + column - 2); } else { PsiElement element = file.findElementAt(startOffset); at = element != null ? PsiTreeUtil.nextLeaf(element) : null; } return PsiTreeUtil.getParentOfType(at, XmlTag.class); }