void (@NotNull AnActionEvent event) { DataContext dataContext = event.getDataContext(); Project project = CommonDataKeys.PROJECT.getData(dataContext); Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (project == null || editor == null) { return; } PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null || file.getVirtualFile() == null) { return; } boolean hasSelection = editor.getSelectionModel().hasSelection(); LayoutCodeDialog dialog = new LayoutCodeDialog(project, file, hasSelection, HELP_ID); dialog.show(); if (dialog.isOK()) { new FileInEditorProcessor(file, editor, dialog.getRunOptions()).processCode(); } }