code: private Location getModuleLocation(JCCompilationUnit tree) throws IOException {
          JavaFileObject fo = tree.sourcefile;
  
          Location loc =
                  fileManager.getLocationForModule(StandardLocation.MODULE_SOURCE_PATH, fo);
          if (loc == null) {
              Location sourceOutput = fileManager.hasLocation(StandardLocation.SOURCE_OUTPUT) ?
                      StandardLocation.SOURCE_OUTPUT : StandardLocation.CLASS_OUTPUT;
              loc =
                  fileManager.getLocationForModule(sourceOutput, fo);
          }
          return loc;
      }
docs: Determine the location for the module on the module source path
  or source output directory which contains a given CompilationUnit.
  If the source output directory is unset, the class output directory
  will be checked instead.
  {@code null} is returned if no such module can be found.
  @param tree the compilation unit tree
  @return the location for the enclosing module
  @throws IOException if there is a problem while searching for the module.