boolean (final DataContext dataContext) { Project project = CommonDataKeys.PROJECT.getData(dataContext); if (project == null) { return false; } if (DumbService.isDumb(project)) return false; Object target = LangDataKeys.PASTE_TARGET_PSI_ELEMENT.getData(dataContext); if (target == null) { return false; } PsiElement[] elements = PsiCopyPasteManager.getInstance().getElements(new boolean[]{false}); if (elements == null) { return false; } // disable cross-project paste for (PsiElement element : elements) { PsiManager manager = element.getManager(); if (manager == null || manager.getProject() != project) { return false; } } return true; }