Object (@NotNull DataProvider dataProvider) { final PsiElement element = CommonDataKeys.PSI_ELEMENT.getData(dataProvider); if (element != null) { return element.getContainingFile(); } Project project = CommonDataKeys.PROJECT.getData(dataProvider); if (project != null) { VirtualFile vFile = CommonDataKeys.VIRTUAL_FILE.getData(dataProvider); if (vFile != null && vFile.isValid()) { return PsiManager.getInstance(project).findFile(vFile); } } return null; }