void (@NotNull AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return; } PsiDocumentManager.getInstance(project).commitAllDocuments(); final Editor editor = CommonDataKeys.EDITOR.getData(dataContext); PsiElement[] elements; PsiElement targetPsiElement = LangDataKeys.TARGET_PSI_ELEMENT.getData(dataContext); PsiDirectory defaultTargetDirectory = targetPsiElement instanceof PsiDirectory ? (PsiDirectory)targetPsiElement : null; if (editor != null) { PsiElement aElement = getTargetElement(editor, project); PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument()); if (file == null) return; elements = new PsiElement[]{aElement}; if (aElement == null || !CopyHandler.canCopy(elements)) { elements = new PsiElement[]{file}; } } else { elements = LangDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext); } doCopy(elements, defaultTargetDirectory); }