void (@NotNull AnActionEvent event) { final Presentation presentation = event.getPresentation(); final DataContext dataContext = event.getDataContext(); final Project project = event.getProject(); if (project == null || !LombokLibraryUtil.hasLombokLibrary(project)) { presentation.setEnabled(false); return; } final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (null != editor) { final PsiFile file = PsiUtilBase.getPsiFileInEditor(editor, project); presentation.setEnabled(file != null && isValidForFile(editor, file)); return; } boolean isValid = false; final VirtualFile[] files = CommonDataKeys.VIRTUAL_FILE_ARRAY.getData(dataContext); if (null != files) { PsiManager psiManager = PsiManager.getInstance(project); for (VirtualFile file : files) { if (file.isDirectory()) { //directory is valid isValid = true; break; } if (JavaFileType.INSTANCE.equals(file.getFileType())) { PsiJavaFile psiFile = (PsiJavaFile) psiManager.findFile(file); if (psiFile != null) { isValid = ContainerUtil.or(psiFile.getClasses(), this::isValidForClass); } } if (isValid) { break; } } } presentation.setEnabled(isValid); }