PsiElement (@NotNull PsiFile psiFile, @Nullable Editor editor) { PsiElement contextElement = psiFile; if (editor != null) { PsiElement element = psiFile.findElementAt(editor.getCaretModel().getOffset()); if (element != null) { contextElement = element; } } return contextElement; }