PsiFile (DataContext context, Project project) { PsiFile file = CommonDataKeys.PSI_FILE.getData(context); if (file == null) { Editor editor = CommonDataKeys.EDITOR.getData(context); if (editor != null) { file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); } } return file; }