Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.CompilerOptions$AliasTransformationHandler


    compileLevel = level.toLowerCase().trim();
    compilerOptions = defaultCompilerOptions();
  }

  public CompilerOptions defaultCompilerOptions() {
    CompilerOptions result = new CompilerOptions();
    if (compileLevel.equals("advanced")) {
      CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(result);
    }
    else if (compileLevel.equals("whitespace_only")) {
      CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(result);
View Full Code Here


     */
    if (!outputCorrelatedJs()) {
      return compilerOptions;
    }

    CompilerOptions options = defaultCompilerOptions();
    setSourceMapCompilerOptions(options);
    return options;
  }
View Full Code Here

    if (cachedResult != null) {
      return cachedResult;
    }

    // Only run actual compiler if necessary.
    CompilerOptions options = getCompilerOptions(jsUri);

    if (!compileLevel.equals("none")) {
      /*
       *  isDebug usually will turn off all compilation, however, setting
       *  isExternExportsEnabled and specifying an export path will keep the
       *  closure compiler on and export the externs for debugging.
       */
      if (!jsUri.isDebug() || options.isExternExportsEnabled()) {
        return doCompile(jsUri, content, externs, cacheKey);
      }
    }

    return doDebug(content, cacheKey);
View Full Code Here

  protected JsResponse doCompile(JsUri jsUri, Iterable<JsContent> content, String externs,
      String cacheKey) {
    JsResponseBuilder builder = new JsResponseBuilder();

    CompilerOptions options = getCompilerOptions(jsUri);

    List<SourceFile> allExterns = Lists.newArrayList();
    allExterns.add(SourceFile.fromCode("externs", externs));
    if (defaultExterns != null) {
      allExterns.addAll(defaultExterns);
    }

    List<JsContent> allContent = Lists.newLinkedList(content);
    if (options.isExternExportsEnabled()) {
      allContent.add(EXPORTSYMBOL_CODE);
    }

    Compiler actualCompiler = newCompiler();
    Result result = actualCompiler.compile(
View Full Code Here

        return true;
      }
    };
    List<JsContent> builder = Lists.newLinkedList(defaultCompiler.getJsContent(jsUri, bundle));

    CompilerOptions options = getCompilerOptions(jsUri);
    if (options.isExternExportsEnabled()) {
      List<String> exports = Lists.newArrayList(bundle.getApis(ApiDirective.Type.JS, true));
      Collections.sort(exports);
      String prevExport = null;
      for (String export : exports) {
        if (!export.equals(prevExport)) {
View Full Code Here

  protected ExecutorService createThreadPool() {
    return Executors.newFixedThreadPool(threadPoolSize);
  }

  public CompilerOptions defaultCompilerOptions() {
    CompilerOptions result = new CompilerOptions();
    if (compileLevel.equals("advanced")) {
      CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(result);
    }
    else if (compileLevel.equals("whitespace_only")) {
      CompilationLevel.WHITESPACE_ONLY.setOptionsForCompilationLevel(result);
View Full Code Here

    return result;
  }

  @VisibleForTesting
  protected CompilerOptions getCompilerOptions(JsUri uri) {
    CompilerOptions options = defaultCompilerOptions();
    return options;
  }
View Full Code Here

  }

  public JsResponse compile(JsUri jsUri, Iterable<JsContent> content, String externs) {
    JsResponseBuilder builder = new JsResponseBuilder();

    CompilerOptions options = getCompilerOptions(jsUri);
    StringBuilder compiled = new StringBuilder();
    StringBuilder exports = new StringBuilder();

    // Add externs export to the list if set in options.
    if (options.isExternExportsEnabled()) {
      List<JsContent> allContent = Lists.newLinkedList(content);
      allContent.add(EXPORTSYMBOL_CODE);
      content = allContent;
    }

    try {
      List<Future<CompileResult>> futures = Lists.newLinkedList();

      // Process each content for work
      for (JsContent code : content) {
        JsResponse defaultCompiled = defaultCompiler.compile(jsUri, Lists.newArrayList(code), externs);

        Future<CompileResult> future = null;
        boolean compile = !code.isNoCompile() && !compileLevel.equals("none");
        /*
         *  isDebug usually will turn off all compilation, however, setting
         *  isExternExportsEnabled and specifying an export path will keep the
         *  closure compiler on and export the externs for debugging.
         */
        compile = compile && (!jsUri.isDebug() || options.isExternExportsEnabled());
        if (compile) { // We should compile this code segment.
          String cacheKey = makeCacheKey(defaultCompiled.toJsString(), externs, jsUri, options);

          synchronized (compiling) {
            CompileResult cached = cache.getElement(cacheKey);
View Full Code Here

        return true;
      }
    };
    List<JsContent> builder = Lists.newLinkedList(defaultCompiler.getJsContent(jsUri, bundle));

    CompilerOptions options = getCompilerOptions(jsUri);
    if (options.isExternExportsEnabled()) {
      List<String> exports = Lists.newArrayList(bundle.getApis(ApiDirective.Type.JS, true));
      Collections.sort(exports);
      String prevExport = null;
      for (String export : exports) {
        if (!export.equals(prevExport)) {
View Full Code Here

      throw new BuildException("outputFile attribute must be set");
    }

    Compiler.setLoggingLevel(Level.OFF);

    CompilerOptions options = createCompilerOptions();
    Compiler compiler = createCompiler(options);

    JSSourceFile[] externs = findExternFiles();
    JSSourceFile[] sources = findSourceFiles();
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.CompilerOptions$AliasTransformationHandler

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.