Package com.google.javascript.jscomp

Examples of com.google.javascript.jscomp.CompilerOptions$AliasTransformation


  public void setUp() {
    testFolder = new File(ClassLoader.getSystemResource("test").getFile());
    victim = new GoogleClosureCompressorProcessor() {
      @Override
      protected CompilerOptions newCompilerOptions() {
        final CompilerOptions options = super.newCompilerOptions();
        // explicitly set this to null to make test pass also when running mvn test from command line.
        // the reason are some weird characters used in jquery-core
        options.setOutputCharset(null);
        return options;
      }
    };
    Context.set(Context.standaloneContext());
    WroTestUtils.createInjector().inject(victim);
View Full Code Here


   */
  @Override
  public void process(final Resource resource, final Reader reader, final Writer writer)
      throws IOException {
    final String content = IOUtils.toString(reader);
    final CompilerOptions compilerOptions = optionsPool.getObject();
    final Compiler compiler = newCompiler(compilerOptions);
    try {
      final String fileName = resource == null ? "wro4j-processed-file.js" : resource.getUri();
      final SourceFile[] input = new SourceFile[] {
        SourceFile.fromInputStream(fileName, new ByteArrayInputStream(content.getBytes(getEncoding())))
View Full Code Here

  /**
   * @return default {@link CompilerOptions} object to be used by compressor.
   */
  protected CompilerOptions newCompilerOptions() {
    final CompilerOptions options = new CompilerOptions();
    /**
     * According to John Lenz from the Closure Compiler project, if you are using the Compiler API directly, you should
     * specify a CodingConvention. {@link http://code.google.com/p/wro4j/issues/detail?id=155}
     */
    options.setCodingConvention(new ClosureCodingConvention());
    // use the wro4j encoding by default
    options.setOutputCharset(getEncoding());
    // set it to warning, otherwise compiler will fail
    options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);
    return options;
  }
View Full Code Here

     */
    public static ErrorManager validate(String name, String content, FormattingOption formattingOptions)
    {
        Compiler compiler = new Compiler();

        CompilerOptions options = new CompilerOptions();
        // 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.
View Full Code Here

     */
    private String slim(String name, String code, boolean isLib, CompilationLevel compLevel)
    {
        Compiler compiler = new Compiler();

        CompilerOptions options = new CompilerOptions();
        if (compLevel != null) {
            // Advanced mode is used here, but additional options could be set, too.
            compLevel.setOptionsForCompilationLevel(options);
        }

View Full Code Here

        compiler.setLoggingLevel(LOGGER.getLevel());
       
        Logger.getLogger("com.google.javascript.jscomp").setUseParentHandlers(false);
        Logger.getLogger("com.google.javascript.jscomp").addHandler(new SlimConsoleHandler());
       
        CompilerOptions options = new CompilerOptions();
        // Advanced mode is used here, but additional options could be set, too.
        level.setOptionsForCompilationLevel(options);
       
        if (formattingOptions != null) {
            formattingOptions.applyToOptions(options);
View Full Code Here

  private void compress() throws UnsupportedEncodingException, IOException {
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    InputStream is = new ByteArrayInputStream(content);
    Writer out = new OutputStreamWriter(baos, charset);
    CompilerOptions options = new CompilerOptions();
    CompilationLevel.SIMPLE_OPTIMIZATIONS
        .setOptionsForCompilationLevel(options);
    Compiler.setLoggingLevel(Level.OFF);
    Compiler compiler = new Compiler();
    compiler.disableThreads();
View Full Code Here

    // environment for compilation
    final List<SourceFile> externs = CommandLineRunner.getDefaultExterns();

    // create compiler + options
    final Compiler compiler = new Compiler();
    final CompilerOptions options = new CompilerOptions();
    level.setOptionsForCompilationLevel(options);

    // never remove unused stuff:
    // this only would work when we had all javascript for the page bundled together
    // also this will not work due to the dynamic rendering of javascript after page creation
View Full Code Here

  @Override
  public InputStream minify(String name, String type, InputStream stream) throws IOException {
    if (type.equals("script")) {
      Compiler compiler = new Compiler();
      CompilerOptions options = new CompilerOptions();
      SourceFile source = SourceFile.fromInputStream(name, stream);
      Result result = compiler.compile(Collections.<SourceFile>emptyList(), Collections.singletonList(source), options);
      if (result.errors.length > 0) {
        StringWriter buffer = new StringWriter();
        PrintWriter writer = new PrintWriter(buffer);
View Full Code Here

         level = CompilationLevel.SIMPLE_OPTIMIZATIONS;
      }

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

      //
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.CompilerOptions$AliasTransformation

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.