Examples of toSource()


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

    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) {
        throw new SmallerException("Closure Failed: "
            + result.errors[0].toString());
      }
View Full Code Here

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

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

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

}
View Full Code Here

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

    compilerOptions.setManageClosureDependencies(entryPoints);

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

    if (result.success) {
      printStream.println(compiler.toSource());
    } else {
      for (JSError error : result.errors) {
        printError(printStream, "ERROR",  error);
      }
      for (JSError warning : result.warnings) {
View Full Code Here

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

        }

        try {
            Files.createParentDirs(outputFile);
            Files.touch(outputFile);
            Files.write(compiler.toSource(), outputFile, Charsets.UTF_8);
        } catch (IOException e) {
            throw new MojoFailureException(outputFile != null ? outputFile.toString() : e.getMessage());
        }
    }
}
View Full Code Here

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

      Pattern pattern = Pattern.compile("^/\\*.*?\\*/\\s?", Pattern.DOTALL);
      Matcher matcher = pattern.matcher(new String(content, charset));
      while (matcher.find()) {
        out.write(matcher.group());
      }
      out.write(compiler.toSource());
      out.flush();
      content = baos.toByteArray();
    }
    is.close();
    out.close();
View Full Code Here

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

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

                    writer.append(compiler.toSource());

                    if (closureConfig.getSourceMapFormat() != null) {
                        log.info("Creating the minified file map ["
                                + ((verbose) ? sourceMapResult.getPath() : sourceMapResult.getName()) + "].");
View Full Code Here

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

                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) {
                        msg.append(error.sourceName).append(":").append(error.lineNumber).append(" ").append(error.description)
                                .append("\n");
View Full Code Here

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

        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

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

    compilerOptions.setManageClosureDependencies(entryPoints);

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

    if (result.success) {
      printStream.println(compiler.toSource());
    } else {
      for (JSError error : result.errors) {
        printError(printStream, "ERROR",  error);
      }
      for (JSError warning : result.warnings) {
View Full Code Here

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

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