Package com.google.javascript.jscomp

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


    return result;
  }

  private Compiler mockRealJsCompiler(JSError error, Result res, String toSource) {
    Compiler result = createMock(Compiler.class);
    expect(result.compile(EasyMock.<List<JSSourceFile>>anyObject(),
        EasyMock.<List<JSSourceFile>>anyObject(),
        isA(CompilerOptions.class))).andReturn(res);
    if (error != null) {
      expect(result.hasErrors()).andReturn(true);
      expect(result.getErrors()).andReturn(new JSError[] { error });
View Full Code Here


    if (options.isExternExportsEnabled()) {
      allContent.add(EXPORTSYMBOL_CODE);
    }

    Compiler actualCompiler = newCompiler();
    Result result = actualCompiler.compile(
        allExterns,
        convertToJsSource(allContent),
        options);

    if (actualCompiler.hasErrors()) {
View Full Code Here

  protected CompileResult doCompileContent(JsContent content, CompilerOptions options,
      List<SourceFile> externs) throws CompilerException {

    Compiler compiler = new Compiler(getErrorManager()); // We shouldn't reuse compilers
    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

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

      Result result = compiler.compile(externs, sources, options);
      if (result.success) {
        writeResult(compiler.toSource());
      } else {
        throw new BuildException("Compilation failed.");
      }
View Full Code Here

            // or errors will cite line numbers in terms of input.js.
            JSSourceFile[] inputs = new JSSourceFile[1];
            inputs[0] = JSSourceFile.fromCode("input", jsCode);

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

            // The compiler is responsible for generating the compiled code; it
            // is not accessible via the Result.
            result = compiler.toSource();
        } catch (Exception e) {
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());
        }
View Full Code Here

      JSSourceFile[] multiple =  { JSSourceFile.fromCode(fileName1, js1),
                                   JSSourceFile.fromCode(fileName2, js2) };
      inputs = multiple;
    }

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

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

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

      throw new ContentProcessingException(ex);
    }
   
    List<Reader> readers = new LinkedList<>();
   
    Result result = compiler.compile(extern, input, options);
    if (result.success)
    {
      logger.debug(Messages.OUTPUT_FROM_MINIFIER, errorStream.toString());
      readers.add( new StringReader(compiler.toSource()) );
    }
View Full Code Here

        // The dummy input name "input.js" is used here so that any warnings or
        // errors will cite line numbers in terms of input.js.
        final SourceFile input = SourceFile.fromCode("input.js", original);

        // 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();
    }
View Full Code Here

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