Predicate<VirtualFile> (@NotNull Project project, @NotNull ProjectSystemId externalSystemId) { ExternalSystemUnlinkedProjectAware unlinkedProjectAware = ExternalSystemUnlinkedProjectAware.getInstance(externalSystemId); if (unlinkedProjectAware == null) { return __ -> true; } Predicate<VirtualFile> isSelectedFile = virtualFile -> { return virtualFile.isDirectory() ? ContainerUtil.exists(virtualFile.getChildren(), it -> unlinkedProjectAware.isBuildFile(project, it)) : unlinkedProjectAware.isBuildFile(project, virtualFile); }; return virtualFile -> { if (!isSelectedFile.test(virtualFile)) { String name = externalSystemId.getReadableName(); String projectPath = UiUtils.getPresentablePath(virtualFile.getPath()); String message = virtualFile.isDirectory() ? JavaUiBundle.message("action.attach.external.project.warning.message.directory", projectPath, name) : JavaUiBundle.message("action.attach.external.project.warning.message.file", projectPath, name); String title = JavaUiBundle.message("action.attach.external.project.warning.title", name); Messages.showWarningDialog(project, message, title); return false; } return true; }; }