Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.JSSourceFile


    }

    @Override
    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());
View Full Code Here


            else CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
        }

        List<JSSourceFile> sources = new ArrayList<JSSourceFile>();
        for (FragmentDescriptor sd : scripts) {
            JSSourceFile input;
            if (sd instanceof ExternalFragment)
                input = JSSourceFile.fromFile(request.getRealPath(((ExternalFragment) sd).getFilePath()));
            else
                input = JSSourceFile.fromCode("fragment" + Integer.toString(scripts.indexOf(sd)),
                        ((InternalFragment) sd).getText());
View Full Code Here

      System.exit(1);
    }
  }

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

        //
        Compiler compiler = new Compiler();
        CompilerOptions options = new CompilerOptions();
        level.setOptionsForCompilationLevel(options);
        WarningLevel.QUIET.setOptionsForWarningLevel(options);
        JSSourceFile extern = JSSourceFile.fromCode("extern", "");

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

        // Advanced mode is used here, but additional options could be set, too.
        CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);

        // To get the complete set of externs, the logic in
        // CompilerRunner.getDefaultExterns() should be used here.
        JSSourceFile extern[] = {JSSourceFile.fromCode("externs.js", "")};

        // The dummy input name "input.js" is used here so that any warnings or
        // errors will cite line numbers in terms of input.js.
        JSSourceFile input[] = {JSSourceFile.fromCode(name, content)};
       
        if (formattingOptions != null) {
            formattingOptions.applyToOptions(options);
        }
View Full Code Here

            compLevel.setOptionsForCompilationLevel(options);
        }

        // To get the complete set of externs, the logic in
        // CompilerRunner.getDefaultExterns() should be used here.
        JSSourceFile extern[] = {JSSourceFile.fromCode("externs.js", "")};

        // The dummy input name "input.js" is used here so that any warnings or
        // errors will cite line numbers in terms of input.js.
        JSSourceFile input[] = {JSSourceFile.fromCode(name, code)};
       
        if (m_formattingOptions != null) {
            m_formattingOptions.applyToOptions(options);
        }
View Full Code Here

            formattingOptions.applyToOptions(options);
        }
       
        // To get the complete set of externs, the logic in
        // CompilerRunner.getDefaultExterns() should be used here.
        JSSourceFile extern = JSSourceFile.fromCode("externs.js", "");
       
        // The dummy input name "input.js" is used here so that any warnings or
        // errors will cite line numbers in terms of input.js.
        if (name == null) {
            name = "System.out.js";
        }
        JSSourceFile input = JSSourceFile.fromCode(name, code);
   
        // 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
View Full Code Here

      //
      Compiler compiler = new Compiler();
      CompilerOptions options = new CompilerOptions();
      level.setOptionsForCompilationLevel(options);
      WarningLevel.QUIET.setOptionsForWarningLevel(options);
      JSSourceFile extern = JSSourceFile.fromCode("extern", "");

      //
      JSSourceFile jsInput;
      try
      {
         String code = JSSourceFile.fromReader("code", input).getCode();
         jsInput = JSSourceFile.fromCode("jsInput", code);
         compiler.compile(extern, jsInput, options);
View Full Code Here

TOP

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

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.