Package com.google.javascript.jscomp

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


    {
        Compiler.setLoggingLevel(Level.INFO);

        compiler_ = new Compiler();

        options_ = new CompilerOptions();
        initOptions();
       
        jsExternsFiles_ = new ArrayList<SourceFile>();
        initExterns();
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();
    boolean useExterns = compileLevel.equals("advanced");
    if (!useExterns) {
      /*
       * Kicking the can down the road.  Advanced optimizations doesn't currently work with the closure compiler in shindig.
       * When it's fixed, we need to make sure all externs are included (not just externs for what was requested) otherwise
       * the cache key will fluctuate with the url hit, and we will get massive cache churn and possible DDOS scenarios
       * when we recompile all requested modules on the fly because the cache key was different.
       */
      externs = "";
    }

    // 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

    return new CheckAccessControls(compiler);
  }

  @Override
  protected CompilerOptions getOptions() {
    CompilerOptions options = super.getOptions();
    options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.ERROR);
    options.setWarningLevel(DiagnosticGroups.CONSTANT_PROPERTY,
        CheckLevel.ERROR);
    return options;
  }
View Full Code Here

        //
        if (script != null) {
            if (key.minified) {
                CompilationLevel level = CompilationLevel.SIMPLE_OPTIMIZATIONS;
                CompilerOptions options = new CompilerOptions();
                level.setOptionsForCompilationLevel(options);
                com.google.javascript.jscomp.Compiler compiler = new Compiler();
                compiler.setErrorManager(new LoggerErrorManager(java.util.logging.Logger.getLogger(ResourceRequestHandler.class
                        .getName())));
                StringWriter code = new StringWriter();
View Full Code Here

            level = CompilationLevel.SIMPLE_OPTIMIZATIONS;
        }

        //
        Compiler compiler = new Compiler();
        CompilerOptions options = new CompilerOptions();
        level.setOptionsForCompilationLevel(options);
        WarningLevel.QUIET.setOptionsForWarningLevel(options);
        JSSourceFile extern = JSSourceFile.fromCode("extern", "");

        //
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

TOP

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

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.