PsiElement () { PsiFile file = getPsiFile(); if (file == null) return null; int offset = getLookupStart(); Editor editor = getEditor(); if (editor instanceof EditorWindow) { offset = editor.logicalPositionToOffset(((EditorWindow)editor).hostToInjected(myEditor.offsetToLogicalPosition(offset))); } if (offset > 0) return file.findElementAt(offset - 1); return file.findElementAt(0); }