本文整理了Java中com.google.javascript.jscomp.Compiler.disableThreads()
方法的一些代码示例,展示了Compiler.disableThreads()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Compiler.disableThreads()
方法的具体详情如下:
包路径:com.google.javascript.jscomp.Compiler
类名称:Compiler
方法名:disableThreads
[英]Disable threads. This is for clients that run on AppEngine and don't have threads.
[中]禁用线程。这适用于在AppEngine上运行且没有线程的客户端。
代码示例来源:origin: jooby-project/jooby
@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);
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
private Compiler createCompiler(
List<SourceFile> inputs, List<SourceFile> externs, CompilerOptions compilerOptions) {
Compiler compiler = new Compiler();
compiler.disableThreads();
compiler.compile(externs, inputs, compilerOptions);
return compiler;
}
代码示例来源:origin: com.asual.lesscss/lesscss-servlet
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();
Result result = compiler.compile(new JSSourceFile[] {},
new JSSourceFile[] { JSSourceFile.fromInputStream("is", is) },
options);
if (result.success) {
Pattern pattern = Pattern.compile("^/\\*.*?\\*/\\s?",
Pattern.DOTALL);
Matcher matcher = pattern.matcher(new String(content, charset));
while (matcher.find()) {
out.write(matcher.group());
}
out.write(compiler.toSource());
out.flush();
content = baos.toByteArray();
}
is.close();
out.close();
}
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
@Override
public String call() {
// Neither the compiler nor the options is thread safe, so they can't be
// saved as instance state.
ByteArrayOutputStream baos = new ByteArrayOutputStream();
Compiler compiler = new Compiler(new PrintStream(baos));
// Threads can't be used in small unit tests.
compiler.disableThreads();
SourceFile externs = SourceFile.fromCode("externs", "function Symbol() {}");
SourceFile sourceFile = SourceFile.fromCode(path, js);
compiler.<SourceFile, SourceFile>compile(
ImmutableList.<SourceFile>of(externs),
ImmutableList.<SourceFile>of(sourceFile),
getOptions());
if (compiler.getErrorManager().getErrorCount() > 0) {
String message;
try {
message = baos.toString(StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
throw new IllegalStateException(message);
}
return compiler.toSource();
}
});
代码示例来源:origin: org.pustefixframework/pustefix-core
@Override
public void compress(Reader reader, Writer writer) throws CompressorException {
com.google.javascript.jscomp.Compiler compiler = new com.google.javascript.jscomp.Compiler();
compiler.disableThreads();
CompilerOptions options = new CompilerOptions();
CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
try {
SourceFile inputFile = SourceFile.fromReader("input.js", reader);
List<SourceFile> inputFiles = new ArrayList<>();
inputFiles.add(inputFile);
List<SourceFile> externFiles = new ArrayList<>();
compiler.compile(externFiles, inputFiles, options);
writer.write(compiler.toSource());
} catch(IOException x) {
throw new CompressorException("Error while compressing javascript", x);
}
}
代码示例来源:origin: alexo/wro4j
private Compiler newCompiler(final CompilerOptions compilerOptions) {
Compiler.setLoggingLevel(Level.SEVERE);
final Compiler compiler = new Compiler();
compilationLevel.setOptionsForCompilationLevel(compilerOptions);
// make it play nice with GAE
compiler.disableThreads();
compiler.initOptions(compilerOptions);
return compiler;
}
代码示例来源:origin: ro.isdc.wro4j/wro4j-extensions
private Compiler newCompiler(final CompilerOptions compilerOptions) {
Compiler.setLoggingLevel(Level.SEVERE);
final Compiler compiler = new Compiler();
compilationLevel.setOptionsForCompilationLevel(compilerOptions);
// make it play nice with GAE
compiler.disableThreads();
compiler.initOptions(compilerOptions);
return compiler;
}
代码示例来源:origin: pl.matisoft/spring-soy-view-min-google
compilationLevel.setOptionsForCompilationLevel(compilerOptions);
compiler.disableThreads();
compiler.initOptions(compilerOptions);
代码示例来源:origin: angular/clutz
TypeScriptGenerator(Options opts) {
this.opts = opts;
this.compiler = new Compiler();
compiler.disableThreads();
setErrorStream(System.err);
this.pathUtil = new PathUtil(opts.root, opts.absolutePathPrefix);
this.nameUtil = new NameUtil(compiler);
}
代码示例来源:origin: org.hibnet/webpipes-googleclosure
private Compiler newCompiler(CompilerOptions compilerOptions, CompilationLevel compilationLevel) {
Compiler.setLoggingLevel(Level.SEVERE);
Compiler compiler = new Compiler();
compilationLevel.setOptionsForCompilationLevel(compilerOptions);
// make it play nice with GAE
compiler.disableThreads();
compiler.initOptions(compilerOptions);
return compiler;
}
代码示例来源:origin: pl.matisoft/spring-soy-view-ajax-compiler
compilationLevel.setOptionsForCompilationLevel(compilerOptions);
compiler.disableThreads();
compiler.initOptions(compilerOptions);
代码示例来源:origin: org.scala-js/closure-compiler-java-6
/** Generates the runtime by requesting the "es6_runtime" library from the compiler. */
private static String getEs6Runtime() {
CompilerOptions options = getOptions();
options.setLanguageOut(LanguageMode.ECMASCRIPT3); // change .delete to ['delete']
options.setForceLibraryInjection(ImmutableList.of("es6_runtime"));
Compiler compiler = new Compiler();
// Threads can't be used in small unit tests.
compiler.disableThreads();
SourceFile externs = SourceFile.fromCode("externs", "function Symbol() {}");
SourceFile sourceFile = SourceFile.fromCode("source", "");
compiler.compile(ImmutableList.of(externs), ImmutableList.of(sourceFile), options);
return compiler.toSource();
}
}
代码示例来源:origin: com.github.hazendaz/htmlcompressor
compiler.disableThreads();
代码示例来源:origin: bessemHmidi/AngularBeans
public String compile(String code) {
Compiler compiler = new Compiler();
compiler.disableThreads();
SourceFile extern = SourceFile.fromCode("externs.js","function alert(x) {}");
SourceFile input = SourceFile.fromCode("input.js", code);
compiler.compile(extern, input, options);
return compiler.toSource();
}
}
代码示例来源:origin: org.apache.shindig/shindig-gadgets
protected CompileResult doCompileContent(JsContent content, CompilerOptions options,
List<SourceFile> externs) throws CompilerException {
Compiler compiler = new Compiler(getErrorManager()); // We shouldn't reuse compilers
// disable JS Closure Compiler internal thread
compiler.disableThreads();
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);
}
return new CompileResult(compiler, result);
}
代码示例来源:origin: apache/tapestry-5
compiler.disableThreads();
代码示例来源:origin: org.apache.tapestry/tapestry-webresources
compiler.disableThreads();
代码示例来源:origin: com.github.jknack/amd4j-closure
@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());
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE, CheckLevel.WARNING);
compiler.setPassConfig(new LintPassConfig(options));
compiler.disableThreads();
SourceFile externs = SourceFile.fromCode("<Linter externs>", "");
compiler.compile(ImmutableList.<SourceFile>of(externs), ImmutableList.of(file), options);
代码示例来源:origin: com.google.javascript/closure-compiler
options.setSummaryDetailLevel(0);
compiler.setPassConfig(new LintPassConfig(options));
compiler.disableThreads();
SourceFile externs = SourceFile.fromCode("<Linter externs>", "");
compiler.compile(ImmutableList.<SourceFile>of(externs), ImmutableList.of(file), options);
内容来源于网络,如有侵权,请联系作者删除!