PackageSet (final PackageDependenciesNode node, final boolean recursively) { GeneralGroupNode groupParent = getGroupParent(node); PatternPackageSet.Scope scope = PatternPackageSet.Scope.ANY; if (groupParent != null) { String name = groupParent.toString(); if (TreeModelBuilder.getProductionName().equals(name)) { scope = PatternPackageSet.Scope.SOURCE; } else if (TreeModelBuilder.getTestName().equals(name)) { scope = PatternPackageSet.Scope.TEST; } else if (TreeModelBuilder.getLibraryName().equals(name)) { scope = PatternPackageSet.Scope.LIBRARY; } } if (node instanceof ModuleGroupNode){ if (!recursively) return null; return new PatternPackageSet("*..*", scope, PatternDialectProvider.getGroupModulePattern((ModuleGroupNode)node)); } else if (node instanceof ModuleNode) { if (!recursively) return null; final String modulePattern = ((ModuleNode)node).getModuleName(); return new PatternPackageSet("*..*", scope, modulePattern); } else if (node instanceof PackageNode) { String pattern = ((PackageNode)node).getPackageQName(); if (pattern != null) { pattern += recursively ? "..*" : ".*"; } else { pattern = recursively ? "*..*" : "*"; } return new PatternPackageSet(pattern, scope, getModulePattern(node)); } else if (node instanceof FileNode fNode) { if (recursively) return null; final PsiElement element = fNode.getPsiElement(); String qName = null; if (element instanceof PsiClassOwner javaFile) { final VirtualFile virtualFile = javaFile.getVirtualFile(); LOG.assertTrue(virtualFile != null); final String packageName = PackageIndex.getInstance(element.getProject()).getPackageNameByDirectory(virtualFile.getParent()); final String name = virtualFile.getNameWithoutExtension(); if (!PsiNameHelper.getInstance(element.getProject()).isIdentifier(name)) return null; qName = StringUtil.getQualifiedName(packageName, name); } if (qName != null) { return new PatternPackageSet(qName, scope, getModulePattern(node)); } } else if (node instanceof GeneralGroupNode) { return new PatternPackageSet("*..*", scope, null); } return null; }