Package com.google.javascript.jscomp

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


  }

  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;
  }

  private static void usage() {
    System.out.println(
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

                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

        SourceFile input = SourceFile.fromInputStream(resource.toString(), resource.openStream());

        List<SourceFile> inputs = Collections.singletonList(input);

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

        if (result.success)
        {
            return IOUtils.toInputStream(compiler.toSource(), OUTPUT_CHARSET);
        }
View Full Code Here

  public void compile(List<File> filesToCompile, String destFileName){
    File destFile = prepareDestFile(destFileName);

    Compiler compiler = new Compiler();
    Result results = compiler.compile(getExterns(), getInputs(filesToCompile), getCompilerOptions());

    logger.debug(results.debugLog);
    for(JSError error : results.errors){
      logger.error("Closure Minifier Error:  " + error.sourceName + "  Description:  " +  error.description);
    }
View Full Code Here

  private Compiler createCompiler(List<SourceFile> inputs, List<SourceFile> externs) {
    CompilerOptions options = getCompilerOptions();
    Compiler compiler = new Compiler();
    compiler.disableThreads();
    compiler.compile(externs, inputs, options);
    return compiler;
  }

  @VisibleForTesting
  static CompilerOptions getCompilerOptions() {
View Full Code Here

  private Compiler getCompiler(String externs, String jsInput) {
    Compiler compiler = new Compiler();
    compiler.disableThreads();
    CompilerOptions options = RefactoringDriver.getCompilerOptions();
    compiler.compile(
        ImmutableList.of(SourceFile.fromCode("externs", externs)),
        ImmutableList.of(SourceFile.fromCode("test", jsInput)),
        options);
    return compiler;
  }
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

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.