Package org.codehaus.groovy.control

# Class ModuleImportHelper

java.lang.Object
org.codehaus.groovy.control.ModuleImportHelper

public final class ModuleImportHelper extends Object
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 Type
  Method
  Description
  `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 it `requires transitive`.
  `static ModuleFinder`
  `moduleFinder(SourceUnit source)`
  Builds a `ModuleFinder` that combines the system module finder with one scanning the compilation classpath for modular JARs.
  `static List<String>`
  `resolveModulePackages(String moduleName, ModuleFinder finder)`
  Resolves a module by name and collects its exported packages (including transitive dependencies).

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### moduleFinder

    public static ModuleFinder moduleFinder(SourceUnit source)
    Builds a `ModuleFinder` that 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 it `requires transitive`. This implements the transitive readability semantics specified by JEP 476.
    Parameters:
      `moduleRef` - the module to inspect
      `finder` - the finder used to resolve transitive dependencies
      `packageNames` - accumulator for discovered package names
      `visited` - set of already-visited module names (to avoid cycles)

  - ### resolveModulePackages

    public static List<String> resolveModulePackages(String moduleName, ModuleFinder finder)
    Resolves a module by name and collects its exported packages (including transitive dependencies).
    Parameters:
      `moduleName` - the JPMS module name
      `finder` - the module finder to use
    Returns:
      the list of exported package names
    Throws:
      `IllegalArgumentException` - if the module is not found