Package com.google.javascript.jscomp

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


    MessageFormatter formatter =
        options.errorFormat.toFormatter(compiler, false);
    AntErrorManager errorManager = new AntErrorManager(formatter, task);
    compiler.setErrorManager(errorManager);

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

    String wrapped = "(function(){" + compiler.toSource() + "})();\n";
View Full Code Here


    List<JSSourceFile> externs = CommandLineRunner.getDefaultExterns();
    externs.addAll(filesToJsSourceFiles(externFiles));

    compilerOptions.setManageClosureDependencies(entryPoints);

    Result result = compiler.compile(externs, inputs, compilerOptions);

    if (result.success) {
      printStream.println(compiler.toSource());
    } else {
      for (JSError error : result.errors) {
View Full Code Here

            return;
        }

        Compiler compiler = new Compiler();
        compiler.setLoggingLevel(Level.WARNING);
        Result result = compiler.compile(new ArrayList<JSSourceFile>(), sources, compilerOptions);

        for (JSError warning : result.warnings) {
            getLog().warn(warning.toString());
        }
View Full Code Here

    CompilerOptions options = new CompilerOptions();
    CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
    Compiler.setLoggingLevel(Level.OFF);
    Compiler compiler = new Compiler();
    compiler.disableThreads();
    Result result = compiler.compile(new JSSourceFile[] {},
      new JSSourceFile[] { JSSourceFile.fromInputStream("is", is) }, options);
    if (result.success) {
      Pattern pattern = Pattern.compile("^/\\*.*?\\*/\\s?", Pattern.DOTALL);
      Matcher matcher = pattern.matcher(new String(content, charset));
      while (matcher.find()) {
View Full Code Here

                    if (closureConfig.getUseDefaultExterns()) {
                        externs.addAll(CommandLineRunner.getDefaultExterns());
                    }

                    Compiler compiler = new Compiler();
                    compiler.compile(externs, Lists.newArrayList(input), options);

                    if (compiler.hasErrors()) {
                        throw new EvaluatorException(compiler.getErrors()[0].description);
                    }
View Full Code Here

    // disable JS Closure Compiler internal thread
    compiler.disableThreads();

    SourceFile source = SourceFile.fromCode(content.getSource(), content.get());
    Result result = compiler.compile(externs, Lists.newArrayList(source), options);

    if (result.errors.length > 0) {
      throw new CompilerException(result.errors);
    }
View Full Code Here

  }

  public static Result compile(String program, int num) {
    JSSourceFile input = JSSourceFile.fromCode(""+num, program);
    Compiler compiler = new Compiler();
    Result result = compiler.compile(extern, input, options);
    return result;
  }

  private static void usage() {
    System.out.println(
View Full Code Here

                compiler.setErrorManager(new LoggerErrorManager(java.util.logging.Logger.getLogger(ResourceRequestHandler.class
                        .getName())));
                StringWriter code = new StringWriter();
                IOTools.copy(script, code);
                JSSourceFile[] inputs = new JSSourceFile[] { 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

        //
        JSSourceFile jsInput;
        try {
            String code = JSSourceFile.fromReader("code", input).getCode();
            jsInput = JSSourceFile.fromCode("jsInput", code);
            compiler.compile(extern, jsInput, options);
            output.write(compiler.toSource());
        } catch (Exception ex) {
            throw new ResourceCompressorException(ex);
        }
    }
View Full Code Here

    List<JSSourceFile> externs = CommandLineRunner.getDefaultExterns();
    externs.addAll(filesToJsSourceFiles(externFiles));

    compilerOptions.setManageClosureDependencies(entryPoints);

    Result result = compiler.compile(externs, inputs, compilerOptions);

    if (result.success) {
      printStream.println(compiler.toSource());
    } else {
      for (JSError error : result.errors) {
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.