Package org.codehaus.groovy.control
Class ModuleImportHelper
java.lang.Object
org.codehaus.groovy.control.ModuleImportHelper
Shared utilities for expanding JPMS module imports into package-level
star imports. Used by both the parser (
AstBuilder) and the
ImportCustomizer.- Since:
- 6.0.0
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidcollectModuleExports(ModuleReference moduleRef, ModuleFinder finder, List<String> packageNames, Set<String> visited) Collects the exported package names from the given module and, recursively, from any modules itrequires transitive.static ModuleFindermoduleFinder(SourceUnit source) Builds aModuleFinderthat combines the system module finder with one scanning the compilation classpath for modular JARs.resolveModulePackages(String moduleName, ModuleFinder finder) Resolves a module by name and collects its exported packages (including transitive dependencies).
-
Method Details
-
moduleFinder
Builds aModuleFinderthat combines the system module finder with one scanning the compilation classpath for modular JARs.- Parameters:
source- the source unit providing classpath and classloader- Returns:
- a composite module finder
-
collectModuleExports
public static void collectModuleExports(ModuleReference moduleRef, ModuleFinder finder, List<String> packageNames, Set<String> visited) Collects the exported package names from the given module and, recursively, from any modules itrequires transitive. This implements the transitive readability semantics specified by JEP 476.- Parameters:
moduleRef- the module to inspectfinder- the finder used to resolve transitive dependenciespackageNames- accumulator for discovered package namesvisited- set of already-visited module names (to avoid cycles)
-
resolveModulePackages
Resolves a module by name and collects its exported packages (including transitive dependencies).- Parameters:
moduleName- the JPMS module namefinder- the module finder to use- Returns:
- the list of exported package names
- Throws:
IllegalArgumentException- if the module is not found
-