Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.Compiler.toSource()


    }

    Result result = compiler.compile(EXTERNS, inputs, options);

    assertTrue("compilation failed", result.success);
    String source = compiler.toSource();

    StringBuilder sb = new StringBuilder();
    try {
      result.sourceMap.validate(true);
      result.sourceMap.appendTo(sb, "testcode");
View Full Code Here


   
    Result result = compiler.compile(extern, input, options);
    if (result.success)
    {
      logger.debug(Messages.OUTPUT_FROM_MINIFIER, errorStream.toString());
      readers.add( new StringReader(compiler.toSource()) );
    }
    else
    {
      logger.error(Messages.ERROR_WHILE_BUNDLING_MSG, errorStream.toString());
      readers.add( new StringReader(String.format(Messages.ERROR_WHILE_BUNDLING_MSG, errorStream.toString())) );
View Full Code Here

        // compile() returns a Result, but it is not needed here.
        compiler.compile(extern, input, options);

        // The compiler is responsible for generating the compiled code; it is not
        // accessible via the Result.
        return compiler.toSource();
    }

    /**
     * @return the externs to use when compiling
     */
 
View Full Code Here

               JSSourceFile.fromCode(sourceName, code.toString())
            };
            Result res = compiler.compile(new JSSourceFile[0], inputs, options);
            if (res.success)
            {
               script = new StringReader(compiler.toSource());
            }
            else
            {
               StringBuilder msg = new StringBuilder("Handle me gracefully JS errors\n");
               for (JSError error : res.errors)
View Full Code Here

      logger.info("Closure Minifier Warning:  " + warning.sourceName + "  Description:  " +  warning.description);
    }

    if (results.success) {
      try {
        Files.write(compiler.toSource(), destFile, Charsets.UTF_8);
      } catch (IOException e) {
        throw new ClosureException("Failed to write minified file to " + destFile, e);
      }
    }else{
      throw new ClosureException("Closure Compiler Failed - See error messages on System.err");
View Full Code Here

      expect(result.getErrors()).andReturn(new JSError[] { error });
    } else {
      expect(result.hasErrors()).andReturn(false);
    }
    expect(result.getResult()).andReturn(res);
    expect(result.toSource()).andReturn(toSource);
    replay(result);
    return result;
  }

  private CompilerOptions mockRealJsCompilerOptions(boolean enableExternExports) {
View Full Code Here

      expect(result.getErrors()).andReturn(new JSError[] { error });
    } else {
      expect(result.hasErrors()).andReturn(false);
    }
    expect(result.getResult()).andReturn(res);
    expect(result.toSource()).andReturn(toSource);
    replay(result);
    return result;
  }

  private CompilerOptions mockRealJsCompilerOptions(boolean enableExternExports) {
View Full Code Here

    Result r = compiler.compile(externs, jsInputs, options);
    if (!r.success) {
      return null;
    }

    String wrapped = "(function(){" + compiler.toSource() + "})();\n";
    return wrapped;
  }

}
View Full Code Here

        externs = new SourceFile[] {};
      }
      Result result = null;
      result = compiler.compile(Arrays.asList(externs), Arrays.asList(input), compilerOptions);
      if (result.success) {
        writer.write(compiler.toSource());
      } else {
        throw new WroRuntimeException("Compilation has errors: " + Arrays.asList(result.errors));
      }
    } catch (final Exception e) {
      onException(e);
View Full Code Here

            System.out.println(node.toStringTree());
        }
       
        // The compiler is responsible for generating the compiled code; it is not
        // accessible via the Result.
        return compiler.toSource();
    }
   
    /**
     * Process this particular node looking for calls, interesting functions, and
     * variables.
 
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.