void (@NotNull AnActionEvent e) { final PackageDependenciesNode leftNode = myLeftTree.getSelectedNode(); final PackageDependenciesNode rightNode = myRightTree.getSelectedNode(); if (leftNode != null && rightNode != null) { boolean hasDirectDependencies = myTransitiveBorder == 0; if (myTransitiveBorder > 0) { final Set<PsiFile> searchIn = getSelectedScope(myLeftTree); final Set<PsiFile> searchFor = getSelectedScope(myRightTree); for (DependenciesBuilder builder : myBuilders) { if (hasDirectDependencies) break; for (PsiFile from : searchIn) { if (hasDirectDependencies) break; for (PsiFile to : searchFor) { if (hasDirectDependencies) break; final List<List<PsiFile>> paths = builder.findPaths(from, to); for (List<PsiFile> path : paths) { if (path.isEmpty()) { hasDirectDependencies = true; break; } } } } } } final PatternDialectProvider provider = PatternDialectProvider.getInstance(mySettings.SCOPE_TYPE); assert provider != null; PackageSet leftPackageSet = provider.createPackageSet(leftNode, true); if (leftPackageSet == null) { leftPackageSet = provider.createPackageSet(leftNode, false); } LOG.assertTrue(leftPackageSet != null); PackageSet rightPackageSet = provider.createPackageSet(rightNode, true); if (rightPackageSet == null) { rightPackageSet = provider.createPackageSet(rightNode, false); } LOG.assertTrue(rightPackageSet != null); if (hasDirectDependencies) { DependencyValidationManager.getInstance(myProject) .addRule(new DependencyRule(new NamedScope.UnnamedScope(leftPackageSet), new NamedScope.UnnamedScope(rightPackageSet), true)); rebuild(); } else { Messages.showErrorDialog(DependenciesPanel.this, CodeInsightBundle .message("analyze.dependencies.unable.to.create.rule.error.message", leftPackageSet.getText(), rightPackageSet.getText()), CodeInsightBundle.message("mark.dependency.illegal.text")); } } }