Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.CompilerOptions


      log("None of the files changed. Compilation skipped.");
    }
  }

  private CompilerOptions createCompilerOptions() {
    CompilerOptions options = new CompilerOptions();

    this.compilationLevel.setOptionsForCompilationLevel(options);
    if (this.debugOptions) {
      this.compilationLevel.setDebugOptionsForCompilationLevel(options);
    }

    options.prettyPrint = this.prettyPrint;
    options.printInputDelimiter = this.printInputDelimiter;
    options.generateExports = this.generateExports;

    this.warningLevel.setOptionsForWarningLevel(options);
    options.setManageClosureDependencies(manageDependencies);

    if (replaceProperties) {
      convertPropertiesMap(options);
    }
View Full Code Here


   * module. The set of options is similar to the one which is used by
   * CompilationLevel in simple mode. The main difference is that variable
   * renaming and closurePass options are turned off.
   */
  private CompilerOptions getSecureCompilerOptions() {
    CompilerOptions options = new CompilerOptions();

    options.variableRenaming = VariableRenamingPolicy.OFF;
    options.inlineLocalVariables = true;
    options.inlineLocalFunctions = true;
    options.checkGlobalThisLevel = CheckLevel.OFF;
View Full Code Here

    public String compress(String jsCode) {
        String result = jsCode;
        try {
            Compiler compiler = new Compiler();

            CompilerOptions options = new CompilerOptions();

            // use the simple compilation level
            CompilationLevel.SIMPLE_OPTIMIZATIONS
                .setOptionsForCompilationLevel(options);
View Full Code Here

  protected RunResult compile(String js, String fileName) {
    return compile(js, fileName, null, null);
  }

  protected CompilerOptions getCompilerOptions() {
    CompilerOptions options = new CompilerOptions();
    options.sourceMapOutputPath = "testcode_source_map.out";
    options.sourceMapFormat = getSourceMapFormat();
    options.sourceMapDetailLevel = detailLevel;
    return options;
  }
View Full Code Here

  }

  protected RunResult compile(
      String js1, String fileName1, String js2, String fileName2) {
    Compiler compiler = new Compiler();
    CompilerOptions options = getCompilerOptions();

    // Turn on IDE mode to get rid of optimizations.
    options.ideMode = true;

    JSSourceFile[] inputs = { JSSourceFile.fromCode(fileName1, js1) };
View Full Code Here

  @Override
  public Reader minify(String settingName, List<InputSource> inputSources) throws ContentProcessingException {
    ByteArrayOutputStream errorStream = new ByteArrayOutputStream();
   
    Compiler compiler = new Compiler( new PrintStream(errorStream) );
    CompilerOptions options = new CompilerOptions();
   
    getCompilationLevelForSettingName(settingName).setOptionsForCompilationLevel(options);
   
    /* we have to use an extern, so create a dummy one */
    SourceFile extern = SourceFile.fromCode("externs.js", "function alert(x) {}");
View Full Code Here

    @Override
    public String compress(final String original) {
        final Compiler compiler = new Compiler();

        // Advanced mode is used here, but additional options could be set, too.
        CompilerOptions options = new CompilerOptions();
        level.setOptionsForCompilationLevel(options);
        overrideOptions(options);

        final SourceFile extern = getExterns();
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

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.