@Override public String process(final String filename, final String source, final Config conf, final ClassLoader loader) throws Exception { final CompilerOptions copts = new CompilerOptions(); copts.setCodingConvention(new ClosureCodingConvention()); copts.setOutputCharset(StandardCharsets.UTF_8); copts.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); CompilationLevel level = level(get("level")); level.setOptionsForCompilationLevel(copts); Compiler.setLoggingLevel(Level.SEVERE); Compiler compiler = new Compiler(); compiler.disableThreads(); compiler.initOptions(copts); List<SourceFile> externs = externs(copts); Result result = compiler.compile(externs, ImmutableList.of(SourceFile.fromCode(filename, source)), copts); if (result.success) { return compiler.toSource(); } List<AssetProblem> errors = Arrays.stream(result.errors) .map(error -> new AssetProblem(error.sourceName, error.lineNumber, error.getCharno(), error.description, null)) .collect(Collectors.toList()); throw new AssetException(name(), errors); }
protected CompilerOptions getCompilerOptions() { CompilerOptions options = new CompilerOptions(); options.setLanguageIn(this.languageIn); options.setLanguageOut(this.languageOut); options.setCodingConvention(new ClosureCodingConvention()); CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options); WarningLevel.valueOf(this.warningLevel).setOptionsForWarningLevel(options); options.setClosurePass(true); options.skipAllCompilerPasses(); return options; }
/** By default, decorate the ClosureCodingConvention. */ public GoogleCodingConvention() { this(new ClosureCodingConvention()); }
/** By default, decorate the ClosureCodingConvention. */ public GoogleCodingConvention() { this(new ClosureCodingConvention()); }
/** * @return default {@link CompilerOptions} object to be used by compressor. */ protected CompilerOptions newCompilerOptions() { 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()); // set it to warning, otherwise compiler will fail options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); return options; } }
/** * @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(Charset.forName(getEncoding())); // set it to warning, otherwise compiler will fail options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); return options; }
/** * @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()); //set it to warning, otherwise compiler will fail options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); //Initialise source map options if (googleClosureMap) { options.setSourceMapFormat(SourceMap.Format.DEFAULT); } return options; }
options.setCodingConvention(new ClosureCodingConvention()); options.setOutputCharset(OUTPUT_CHARSET); options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);
/** * @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; }
/** * @return default {@link com.google.javascript.jscomp.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()); options.setOutputCharset(getEncoding()); //set it to warning, otherwise compiler will fail options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); return options; }
/** * @return default {@link com.google.javascript.jscomp.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()); options.setOutputCharset(getEncoding()); //set it to warning, otherwise compiler will fail options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); return options; }
options.setCodingConvention(new ClosureCodingConvention()); options.setOutputCharset(OUTPUT_CHARSET); options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING);
@Override public CharSequence minify(final Config config, final CharSequence source) { final CompilerOptions options = new CompilerOptions(); options.setCodingConvention(new ClosureCodingConvention()); options.setOutputCharset("UTF-8"); options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, CheckLevel.WARNING); compilationLevel.setOptionsForCompilationLevel(options); Compiler.setLoggingLevel(Level.SEVERE); Compiler compiler = new Compiler(); compiler.disableThreads(); compiler.initOptions(options); String fname = removeExtension(config.getName()) + ".js"; Result result = compiler.compile(defaultExterns, Arrays.asList(SourceFile.fromCode(fname, source.toString())), options); if (result.success) { return compiler.toSource(); } JSError[] errors = result.errors; throw new IllegalStateException(errors[0].toString()); }
options.setCodingConvention(new JqueryCodingConvention()); } else { options.setCodingConvention(new ClosureCodingConvention());
conv = new JqueryCodingConvention(); } else { conv = new ClosureCodingConvention();
conv = new ChromeCodingConvention(); } else { conv = new ClosureCodingConvention();
options.setCodingConvention(new ClosureCodingConvention());