void (DataContext dataContext, Presentation presentation) { Editor editor = CommonDataKeys.EDITOR.getData(dataContext); if (editor == null) { presentation.setVisible(false); return; } Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); PsiElement element = getTargetElement(editor, project); Ref<@NlsActions.ActionText String> actionName = new Ref<>(); boolean result = element != null && CopyHandler.canCopy(new PsiElement[]{element}, actionName); if (!result && file != null) { result = CopyHandler.canCopy(new PsiElement[]{file}, actionName); } presentation.setEnabled(result); presentation.setVisible(true); if (!actionName.isNull()) { presentation.setText(actionName.get()); } }