PsiElement (PsiFile file, int offset) { PsiElement element = file.findElementAt(offset); if (element == null && offset == file.getTextLength()) { element = file.findElementAt(offset - 1); } return element; }