Package com.google.gwt.dev.cfg

Examples of com.google.gwt.dev.cfg.ModuleDef$LibraryDependencyEdge


      if (!isLegacyMode()) {
        throw new UnsupportedOperationException();
      }
      for (int i = 0; i < moduleNames.length; i++) {
        String moduleName = moduleNames[i];
        ModuleDef moduleDef = loadModule(getLogger(), moduleName, true);
        HostedModeBase.this.compile(getLogger(), moduleDef);
      }
    }
View Full Code Here


   * @return
   * @throws MalformedURLException
   * @see javax.servlet.ServletContext#getResource(java.lang.String)
   */
  public URL getResource(String path) throws MalformedURLException {
    ModuleDef moduleDef = moduleDefRef.get();
    assert (moduleDef != null) : "GWTShellServlet should have guaranteed that a"
        + " live servlet will never process a request for a dead module; if you"
        + " are using this servlet outside the context of processing a call,"
        + " then don't do that";

    String moduleContext = "/" + moduleDef.getName() + "/";
    if (!path.startsWith(moduleContext)) {
      // Check for a renamed module
      moduleContext = "/" + moduleDef.getCanonicalName() + "/";
      if (!path.startsWith(moduleContext)) {
        // This path is in a different context; just return null
        return null;
      }
    }

    String partialPath = path.substring(moduleContext.length());

    // Try to get the resource from the application's public path
    Resource publicResource = moduleDef.findPublicFile(partialPath);
    if (publicResource != null) {
      return publicResource.getURL();
    }

    // Otherwise try the path in the shell's public generated directory
View Full Code Here

        compilerContextBuilder.options(new PrecompileTaskOptionsImpl(options)).build();
    assertTrue(validate(getErrorLoggingTreeLogger(), GOOD));
  }

  private void precompile(TreeLogger logger, String moduleName) throws UnableToCompleteException {
    ModuleDef module = ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName);
    compilerContext = compilerContextBuilder.module(module).build();
    if (Precompile.precompile(logger, compilerContext) == null) {
      throw new UnableToCompleteException();
    }
  }
View Full Code Here

      throw new UnableToCompleteException();
    }
  }

  private boolean validate(TreeLogger logger, String moduleName) {
    ModuleDef module;
    try {
      module = ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName);
      compilerContext = compilerContextBuilder.module(module).build();
    } catch (UnableToCompleteException e) {
      fail("Failed to load the module definition");
View Full Code Here

   * @return the loaded module
   * @throws UnableToCompleteException
   */
  protected ModuleDef loadModule(TreeLogger logger, String moduleName, boolean refresh)
      throws UnableToCompleteException {
    ModuleDef moduleDef =
        ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleName, refresh);
    compilerContext = compilerContextBuilder.module(moduleDef).build();
    assert (moduleDef != null) : "Required module state is absent";
    return moduleDef;
  }
View Full Code Here

              moduleName);
      // TODO(jat): add support for closing an active module
      TreeLogger logger = module.getLogger();
      try {
        // Try to find an existing loaded version of the module def.
        ModuleDef moduleDef = loadModule(logger, moduleName, true);
        assert (moduleDef != null);

        ArchivePreloader.preloadArchives(logger, compilerContext);

        CompilationState compilationState = moduleDef.getCompilationState(logger, compilerContext);
        ShellModuleSpaceHost host =
            doCreateShellModuleSpaceHost(logger, compilationState, moduleDef);
        return host;
      } catch (RuntimeException e) {
        logger.log(TreeLogger.ERROR, "Exception initializing module", e);
View Full Code Here

    // TODO(zundel): There is an optimal order to compile these modules in.
    // Modify ModuleDefLoader to be able to figure that out and sort them for
    // us.

    for (String moduleToCompile : options.getModuleNames()) {
      ModuleDef module;
      // The units in this set already belong to an archive and should not be
      // written out.
      Set<String> currentModuleArchivedUnits = new HashSet<String>();
      try {
        module = ModuleDefLoader.loadFromClassPath(logger, compilerContext, moduleToCompile);
        compilerContext = compilerContextBuilder.module(module).build();
      } catch (Throwable e) {
        CompilationProblemReporter.logAndTranslateException(logger, e);
        return false;
      }

      SpeedTracerLogger.Event loadAllArchives =
          SpeedTracerLogger.start(CompilerEventType.LOAD_ARCHIVE, "module", moduleToCompile);
      try {
        Collection<URL> archiveURLs = module.getAllCompilationUnitArchiveURLs();
        if (logger.isLoggable(TreeLogger.TRACE) && archiveURLs != null) {
          for (URL archiveURL : archiveURLs) {
            logger.log(TreeLogger.TRACE, "Found archive: " + archiveURL);
          }
        }

        // Don't re-archive previously compiled units from this invocation of CompileModule.
        for (String compiledModuleName : newlyCompiledModules.keySet()) {
          if (module.isInherited(compiledModuleName)) {
            currentModuleArchivedUnits.addAll(newlyCompiledModules.get(compiledModuleName));
          }
        }

        // Load up previously archived modules
        for (URL archiveURL : archiveURLs) {
          String archiveURLString = archiveURL.toString();
          Set<String> unitPaths = unitsInArchives.get(archiveURLString);
          // Don't bother deserializing archives that have already been read.
          if (unitPaths != null) {
            currentModuleArchivedUnits.addAll(unitPaths);
            continue;
          }

          SpeedTracerLogger.Event loadArchive =
              SpeedTracerLogger.start(CompilerEventType.LOAD_ARCHIVE, "dependentModule", archiveURL
                  .toString());
          try {
            CompilationUnitArchive archive = CompilationUnitArchive.createFromURL(archiveURL);
            // Pre-populate CompilationStateBuilder with .gwtar files
            CompilationStateBuilder.addArchive(compilerContext, archive);

            // Remember already archived units - we don't want to add them back.
            if (!archive.getTopModuleName().equals(moduleToCompile)) {
              Set<String> archivedUnits = new HashSet<String>();
              unitsInArchives.put(archiveURLString, archivedUnits);
              for (CompilationUnit unit : archive.getUnits().values()) {
                archivedUnits.add(unit.getResourcePath());
              }
              currentModuleArchivedUnits.addAll(archivedUnits);
            }
          } catch (IOException ex) {
            logger.log(TreeLogger.WARN, "Unable to read: " + archiveURL + ". Skipping: " + ex);
          } catch (ClassNotFoundException ex) {
            logger
                .log(TreeLogger.WARN, "Incompatible archive: " + archiveURL + ". Skipping: " + ex);
          } finally {
            loadArchive.end();
          }
        }
      } finally {
        loadAllArchives.end();
      }

      CompilationState compilationState;
      try {
        compilationState = module.getCompilationState(logger, compilerContext);
      } catch (Throwable e) {
        CompilationProblemReporter.logAndTranslateException(logger, e);
        return false;
      }

      if (options.isStrict() && compilationState.hasErrors()) {
        logger.log(TreeLogger.ERROR, "Failed to compile " + moduleToCompile);
        return false;
      }

      Set<String> compiledUnits = Sets.newHashSet();
      CompilationUnitArchive outputArchive = new CompilationUnitArchive(moduleToCompile);
      for (CompilationUnit unit : compilationState.getCompilationUnits()) {
        if (!currentModuleArchivedUnits.contains(unit.getResourcePath())) {
          outputArchive.addUnit(unit);
          compiledUnits.add(unit.getResourcePath());
        }
      }
      newlyCompiledModules.put(moduleToCompile, compiledUnits);

      String slashedModuleName =
          module.getName().replace('.', '/') + ModuleDefLoader.COMPILATION_UNIT_ARCHIVE_SUFFIX;
      File outputFile = new File(outputDir, slashedModuleName);
      outputFile.getParentFile().mkdirs();
      logger.log(TreeLogger.INFO, "Writing " + outputArchive.getUnits().size() + " units to "
          + outputFile.getAbsolutePath());
      try {
View Full Code Here

  private static TypeOracle getTestTypeOracle() throws UnableToCompleteException {
    if (sTypeOracle == null) {
      TreeLogger logger = createLogger();
      CompilerContext.Builder compilerContextBuilder = new CompilerContext.Builder();
      CompilerContext compilerContext = compilerContextBuilder.build();
      ModuleDef moduleDef = ModuleDefLoader.createSyntheticModule(logger, compilerContext,
          "com.google.gwt.user.rebind.rpc.testcases.RebindRPCTestCases.JUnit", new String[] {
              "com.google.gwt.user.rebind.rpc.testcases.RebindRPCTestCases",
              "com.google.gwt.junit.JUnit"}, true);
      compilerContext = compilerContextBuilder.module(moduleDef).build();
      sTypeOracle = moduleDef.getCompilationState(logger, compilerContext).getTypeOracle();
    }
    return sTypeOracle;
  }
View Full Code Here

  private final RebindOracle[] rebindOracles;

  public DistillerRebindPermutationOracle(CompilerContext compilerContext,
      CompilationState compilationState, ArtifactSet generatorArtifacts,
      PropertyPermutations perms) {
    ModuleDef module = compilerContext.getModule();
    this.compilationState = compilationState;
    permutations = new Permutation[perms.size()];
    rebindOracles = new RebindOracle[perms.size()];
    generatorContext = new StandardGeneratorContext(
        compilerContext, compilationState, generatorArtifacts, true);
    BindingProperty[] orderedProps = perms.getOrderedProperties();
    ConfigProps config = new ConfigProps(module);
    Rules rules = module.getRules();
    for (int i = 0; i < rebindOracles.length; ++i) {
      BindingProps props = new BindingProps(orderedProps, perms.getOrderedPropertyValues(i), config);
      rebindOracles[i] = new StandardRebindOracle(props.toPropertyOracle(), rules,
          generatorContext);
      permutations[i] = new Permutation(i, props);
View Full Code Here

    TreeLogger branch = getTopLogger().branch(TreeLogger.TRACE, "Loading modules");
    try {
      for (String moduleName : options.getModuleNames()) {
        TreeLogger moduleBranch = branch.branch(TreeLogger.TRACE, moduleName);
        ModuleDef module = loadModule(moduleBranch, moduleName, false);
        // Create a hard reference to the module to avoid gc-ing it until we
        // actually load the module from the browser.
        startupModules.put(module.getName(), module);

        if (!options.isNoServer()) {
          validateServletTags(moduleBranch, servletValidator, servletWriter, module);
        }
      }
View Full Code Here

TOP

Related Classes of com.google.gwt.dev.cfg.ModuleDef$LibraryDependencyEdge

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.