void (@NotNull DataContext dataContext) { PsiElement[] selectedPsiElements = PlatformCoreDataKeys.PSI_ELEMENT_ARRAY.getData(dataContext); if (selectedPsiElements != null) { List<String> names = new ArrayList<>(selectedPsiElements.length); for (PsiElement element : selectedPsiElements) { if (element instanceof PsiNamedElement) { names.add(((PsiNamedElement)element).getName()); } } CopyPasteManager.getInstance().setContents(new StringSelection(StringUtil.join(names, "\n"))); } }