Repository: apple/pkl
File: pkl-core/src/main/java/org/pkl/core/runtime/VmImportAnalyzer.java (Java)

Code before:
    var moduleResolver = context.getModuleResolver();
    var securityManager = context.getSecurityManager();
    var collectedImports = collectImports(resolvedModuleKey, moduleResolver, securityManager);
    var importsInModule = new TreeSet<Import>();
    for (var imprt : collectedImports) {
      importsInModule.add(imprt.toImport());
    }
    imports.put(moduleUri, importsInModule);
    resolvedImports.put(moduleUri, resolvedModuleKey.getUri());
    for (var imprt : collectedImports) {
      if (imports.containsKey(imprt.moduleUri)) {
        continue;
      }
      analyzeSingle(imprt.moduleUri, imprt.resolvedModuleKey, context, imports, resolvedImports);
    }
  }

  private static Set<ImportEntry> collectImports(
      ResolvedModuleKey resolvedModuleKey,
      ModuleResolver moduleResolver,
      SecurityManager securityManager) {
    List<Entry> importsAndReads;
    var moduleKey = resolvedModuleKey.getOriginal();
    try {
      importsAndReads =
          ImportsAndReadsParser.parse(resolvedModuleKey.getOriginal(), resolvedModuleKey);
    } catch (VmException err) {
      throw new VmExceptionBuilder()
          .evalError("cannotAnalyzeBecauseSyntaxError", resolvedModuleKey.getOriginal().getUri())
          .wrapping(err)
          .build();
    } catch (IOException err) {
      throw new VmExceptionBuilder()
          .evalError("ioErrorLoadingModule", resolvedModuleKey.getOriginal().getUri())
          .build();
    }
    if (importsAndReads == null) {
      return Set.of();
    }
    var result = new HashSet<ImportEntry>();
    for (var entry : importsAndReads) {
      if (!entry.isModule()) {
        continue;
      }
      try {
        if (entry.isGlob()) {
          var theModuleKey =
              moduleResolver.resolve(moduleKey.resolveUri(IoUtils.toUri(entry.stringValue())));
          var elements =
              GlobResolver.resolveGlob(
                  securityManager,

Review comment (suggestion):
```suggestion
          ImportsAndReadsParser.parse(moduleKey, resolvedModuleKey);
```
Same for line 92 and 97.

Code after:
    var moduleResolver = context.getModuleResolver();
    var securityManager = context.getSecurityManager();
    var collectedImports = collectImports(resolvedModuleKey, moduleResolver, securityManager);
    var importsInModule = new TreeSet<Import>();
    for (var imprt : collectedImports) {
      importsInModule.add(imprt.toImport());
    }
    imports.put(moduleUri, importsInModule);
    resolvedImports.put(moduleUri, resolvedModuleKey.getUri());
    for (var imprt : collectedImports) {
      if (imports.containsKey(imprt.moduleUri)) {
        continue;
      }
      analyzeSingle(imprt.moduleUri, imprt.resolvedModuleKey, context, imports, resolvedImports);
    }
  }

  private static Set<ImportEntry> collectImports(
      ResolvedModuleKey resolvedModuleKey,
      ModuleResolver moduleResolver,
      SecurityManager securityManager) {
    List<Entry> importsAndReads;
    var moduleKey = resolvedModuleKey.getOriginal();
    try {
      importsAndReads = ImportsAndReadsParser.parse(moduleKey, resolvedModuleKey);
    } catch (VmException err) {
      throw new VmExceptionBuilder()
          .evalError("cannotAnalyzeBecauseSyntaxError", moduleKey.getUri())
          .wrapping(err)
          .build();
    } catch (IOException err) {
      throw new VmExceptionBuilder().evalError("ioErrorLoadingModule", moduleKey.getUri()).build();
    }
    if (importsAndReads == null) {
      return Set.of();
    }
    var result = new HashSet<ImportEntry>();
    for (var entry : importsAndReads) {
      if (!entry.isModule()) {
        continue;
      }
      try {
        if (entry.isGlob()) {
          var theModuleKey =
              moduleResolver.resolve(moduleKey.resolveUri(IoUtils.toUri(entry.stringValue())));
          var elements =
              GlobResolver.resolveGlob(
                  securityManager,
                  theModuleKey,
                  moduleKey,
                  moduleKey.getUri(),