Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.CompilerOptions


        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


  @SuppressWarnings("unchecked")
  @Test
  public void testCompileSuccessOptWithProfiling() throws Exception {
    jsUriMock = mockJsUri(false); // opt

    realOptionsMock = new CompilerOptions();
    realOptionsMock.enableExternExports(false);
    realOptionsMock.sourceMapOutputPath = "test.out";
    realOptionsMock.sourceMapFormat = Format.V2;
    realOptionsMock.sourceMapDetailLevel = SourceMap.DetailLevel.ALL;
    realOptionsMock.ideMode = false;
View Full Code Here

    replay(result);
    return result;
  }

  private CompilerOptions mockRealJsCompilerOptions(boolean enableExternExports) {
    CompilerOptions result = createMock(CompilerOptions.class);
    expect(result.isExternExportsEnabled()).andReturn(enableExternExports).anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void testCompileSuccessOptWithProfiling() throws Exception {
    jsUriMock = mockJsUri(false); // opt

    realOptionsMock = new CompilerOptions();
    realOptionsMock.enableExternExports(false);
    realOptionsMock.sourceMapOutputPath = "test.out";
    realOptionsMock.sourceMapFormat = Format.V2;
    realOptionsMock.sourceMapDetailLevel = SourceMap.DetailLevel.ALL;
    realOptionsMock.ideMode = false;
View Full Code Here

    replay(result);
    return result;
  }

  private CompilerOptions mockRealJsCompilerOptions(boolean enableExternExports) {
    CompilerOptions result = createMock(CompilerOptions.class);
    expect(result.isExternExportsEnabled()).andReturn(enableExternExports).anyTimes();
    replay(result);
    return result;
  }
View Full Code Here

    ThreadFactory threadFactory = new ClosureJSThreadFactory();
    return Executors.newFixedThreadPool(threadPoolSize, threadFactory);
  }

  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

    List<SourceFile> jsInputs = new ArrayList<SourceFile>();
    for (File f : inputs) {
      jsInputs.add(SourceFile.fromFile(f));
    }

    CompilerOptions options = new CompilerOptions();
    CompilationLevel.ADVANCED_OPTIMIZATIONS
        .setOptionsForCompilationLevel(options);
    WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
    for (DiagnosticGroup dg : diagnosticGroups) {
      options.setWarningLevel(dg, CheckLevel.ERROR);
    }

    options.setCodingConvention(new GoogleCodingConvention());

    Compiler compiler = new Compiler();
    MessageFormatter formatter =
        options.errorFormat.toFormatter(compiler, false);
    AntErrorManager errorManager = new AntErrorManager(formatter, task);
View Full Code Here

TOP

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

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.