private void loadModuleFromSource(
      Package pkg,
      Modules modules,
      LinkedList<JCCompilationUnit> moduleTrees,
      List<JCCompilationUnit> parsedTrees) {
    // skip it if we already resolved the package
    if (pkg.getModule() != null) {
      // make sure the default module is always added to the classpath, it will be the only one to
      // have a module
      if (!addedDefaultModuleToClassPath && pkg.getModule().isDefault()) {
        addedDefaultModuleToClassPath = true;
        ceylonEnter.addOutputModuleToClassPath(pkg.getModule());
      }
      return;
    }
    String pkgName = pkg.getQualifiedNameString();
    Module module = null;
    // do we have a module for this package?
    // FIXME: is this true? what if we have a module.ceylon at toplevel?
    if (pkgName.isEmpty()) module = modules.getDefaultModule();
    else {
      for (Module m : modulesLoadedFromSource) {
        if (Util.isSubPackage(m.getNameAsString(), pkgName)) {
          module = m;
          break;
        }
      }
      if (module == null) {
        module = loadModuleFromSource(pkgName, moduleTrees, parsedTrees);
      } else if (!module.isAvailable()) {
        loadModuleFromSource(pkgName, moduleTrees, parsedTrees);
      }

      if (module == null) {
        // no declaration for it, must be the default module, unless we're bootstrapping the
        // language module,
        // because we have some com.redhat.ceylon packages that must go in the language module
        if (isBootstrap) module = modules.getLanguageModule();
        else module = modules.getDefaultModule();
      }
    }
    // bind module and package together
    pkg.setModule(module);
    module.getPackages().add(pkg);
    // automatically add this module's jar to the classpath if it exists
    ceylonEnter.addOutputModuleToClassPath(module);
  }
Example #2
0
 private static void printUsage() {
   List<String> defaultRepositories =
       com.redhat.ceylon.compiler.java.util.Util.addDefaultRepositories(
           Collections.<String>emptyList());
   System.err.print(
       "Usage: ceylon [options...] moduleName[/version]... :\n"
           + "\n"
           + "-out <path>:  Output module repository (default: 'modules')\n"
           + "-src <path>:  Source path (default: 'source')\n"
           + "              You can set this option multiple times\n"
           + "-rep <path>:  Module repository\n"
           + "              You can set this option multiple times\n"
           + "              Default:\n");
   for (String repo : defaultRepositories) System.err.println("              " + repo);
   System.err.print(
       "-non-shared:  Document non-shared declarations\n"
           + "-source-code: Include the source code\n"
           + "-d:           Not supported yet\n"
           + "-help:        Prints help usage\n"
           + "-version:     Prints version number\n");
   System.exit(1);
 }
 public LazyInterfaceAlias(ClassMirror classMirror, ModelCompleter completer) {
   this.classMirror = classMirror;
   this.completer = completer;
   setName(Util.getMirrorName(classMirror));
 }