Package: org.codehaus.groovy.control

## [Java] Class ModuleImportHelper

- 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

- - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `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`.
    `` | `public static ModuleFinder` | `moduleFinder(SourceUnit source)` Builds a ModuleFinder that combines the system module finder with one scanning the compilation classpath for modular JARs.
    `` | `public static List<String>` | `resolveModulePackages(String moduleName, ModuleFinder finder)` Resolves a module by name and collects its exported packages (including transitive dependencies).

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### 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)

    - #### 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

    - #### public static List<String> resolveModulePackages(String moduleName, ModuleFinder finder)

      Resolves a module by name and collects its exported packages (including transitive dependencies).

      throws:
        IllegalArgumentException if the module is not found
      Parameters:
        `moduleName` - the JPMS module name
        `finder` - the module finder to use
      Returns:
        the list of exported package names