Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.Result


  }

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


    if (isStale() || forceRecompile) {
      log("Compiling " + sources.size() + " file(s) with " +
          externs.size() + " extern(s)");

      Result result = compiler.compile(externs, sources, options);

      if (result.success) {
        StringBuilder source = new StringBuilder(compiler.toSource());

        if (this.outputWrapperFile != null) {
View Full Code Here

    public void compress(Reader r, Writer w) throws Exception {
        com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
        JSSourceFile file = JSSourceFile.fromInputStream("greenscript.js", new ReaderInputStream(r));
        List<JSSourceFile> files = new ArrayList<JSSourceFile>();
        files.add(file);
        Result result = compiler.compile(externalJavascriptFiles, files, options);
        if (result.success) {
            w.write(compiler.toSource());
        } else {
            throw new Exception("error compile javascript");
        }
View Full Code Here

                input = JSSourceFile.fromCode("fragment" + Integer.toString(scripts.indexOf(sd)),
                        ((InternalFragment) sd).getText());
            sources.add(input);
        }

        Result res = compiler.compile(new JSSourceFile[]{}, sources.toArray(new JSSourceFile[]{}), options);
        if (!res.success)
            throw new JSCompileException();
        String licenses = "";
        try {
            licenses = getLicenses(scripts, settings, request);
View Full Code Here

            log.info("Compiler Options:" + compilerOptions);

            compilationLevel.setOptionsForCompilationLevel(compilerOptions);

            Compiler compiler = new Compiler();
            Result result = compiler.compile(externs, source, compilerOptions);

            // TODO: should log results to a file if desired.
            for (JSError warning : result.warnings) {
                getLog().warn(warning.toString());
            }
View Full Code Here

      }
      String code1 = ScriptFuzzer.getPrettyCode(script);
      StringBuilder debugInfo = new StringBuilder("Seed: ").append(currentSeed);
      debugInfo.append("\nJavaScript: ").append(code1);
      try {
        Result result = compile(script);
        if (result.success) {
          if (result.warnings.length == 0) {
            getLogger().info(debugInfo.toString());
          } else {
            getLogger().warning(debugInfo.toString());
View Full Code Here

      inputs = ImmutableList.of(
          SourceFile.fromCode(fileName1, js1),
          SourceFile.fromCode(fileName2, js2));
    }

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

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

    StringBuilder sb = new StringBuilder();
View Full Code Here

      compilerOptions.setSourceMapDetailLevel(DetailLevel.ALL);
    }
    setupOptions(compilerOptions, options);
    compiler.initOptions(compilerOptions);

    final Result result = compiler.compile(SourceFile.fromCode("externs", ""),
        SourceFile.fromReader("source.js", reader), compilerOptions);
    if (result.success) {
      writer.write(compiler.toSource());
    } else {
      if (result.errors.length > 0) {
View Full Code Here

    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

TOP

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

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.