本文整理了Java中com.google.javascript.jscomp.Compiler.initOptions()
方法的一些代码示例,展示了Compiler.initOptions()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Compiler.initOptions()
方法的具体详情如下:
包路径:com.google.javascript.jscomp.Compiler
类名称:Compiler
方法名:initOptions
[英]Initializes the compiler options. It's called as part of a normal compile() job. Public for the callers that are not doing a normal compile() job.
[中]初始化编译器选项。它是作为普通compile()作业的一部分调用的。对于未执行正常compile()作业的调用方,为Public。
代码示例来源: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: com.google.javascript/closure-compiler
void initCompilerOptionsIfTesting() {
if (options == null) {
// initialization for tests that don't initialize the compiler
// by the normal mechanisms.
initOptions(newCompilerOptions());
}
}
代码示例来源:origin: com.google.javascript/closure-compiler
@Override
public ErrorManager getErrorManager() {
if (options == null) {
initOptions(new CompilerOptions());
}
return errorManager;
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
void initCompilerOptionsIfTesting() {
if (options == null) {
// initialization for tests that don't initialize the compiler
// by the normal mechanisms.
initOptions(newCompilerOptions());
}
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
@Override
public ErrorManager getErrorManager() {
if (options == null) {
initOptions(newCompilerOptions());
}
return errorManager;
}
代码示例来源: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: 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: 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
compiler.initOptions(compilerOptions);
代码示例来源:origin: pl.matisoft/spring-soy-view-min-google
compiler.initOptions(compilerOptions);
代码示例来源:origin: org.wisdom-framework/wisdom-maven-plugin
compiler.initOptions(options);
final Result result = compiler.compile(externs, inputs, options);
listErrors(result);
代码示例来源: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.wisdom-framework/wisdom-maven-plugin
compiler.initOptions(options);
final Result result = compiler.compile(externs, inputs, options);
listErrors(result);
代码示例来源:origin: com.google.javascript/closure-compiler
/**
* Initializes the instance state needed for a compile job if the sources
* are in modules.
*/
public <T extends SourceFile> void initModules(
List<T> externs, List<JSModule> modules, CompilerOptions options) {
initOptions(options);
checkFirstModule(modules);
this.externs = makeExternInputs(externs);
// Generate the module graph, and report any errors in the module specification as errors.
try {
this.moduleGraph = new JSModuleGraph(modules);
} catch (JSModuleGraph.ModuleDependenceException e) {
// problems with the module format. Report as an error. The
// message gives all details.
report(JSError.make(MODULE_DEPENDENCY_ERROR,
e.getModule().getName(), e.getDependentModule().getName()));
return;
}
// Creating the module graph can move weak source around, and end up with empty modules.
fillEmptyModules(getModules());
this.commentsPerFile = new ConcurrentHashMap<>(moduleGraph.getInputCount());
initBasedOnOptions();
initInputsByIdMap();
initAST();
}
代码示例来源:origin: org.scala-js/closure-compiler-java-6
initOptions(options);
代码示例来源:origin: apache/royale-compiler
private void initializeCompiler()
{
jscompiler = new Compiler();
options = new JXCompilerOptions();
//options.setLanguageIn(LanguageMode.ECMASCRIPT6_TYPED);
//options.setLanguageOut(LanguageMode.ECMASCRIPT6_TYPED);
options.setPreserveTypeAnnotations(true);
options.setPrettyPrint(true);
options.setLineLengthThreshold(80);
options.setPreferSingleQuotes(true);
//options.setIdeMode(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
options.setExternExports(false);
options.setExtraAnnotationNames(Arrays.asList(asdocTags));
options.setLanguageIn(LanguageMode.ECMASCRIPT_2015);
options.setLanguageIn(LanguageMode.ECMASCRIPT5_STRICT);
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new NamespaceResolutionPass(model,
jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new ResolvePackagesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectTypesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new AddMemberPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectImportsPass(model, jscompiler));
//compiler.setErrorManager(testErrorManager);
jscompiler.initOptions(options);
// don't need custom error manager with es6->es5 language options
//jscompiler.setErrorManager(wrapErrorManager(jscompiler.getErrorManager()));
model.setJSCompiler(jscompiler);
}
代码示例来源:origin: org.apache.flex.flexjs.compiler/compiler-jx
private void initializeCompiler()
{
jscompiler = new Compiler();
options = new JXCompilerOptions();
//options.setLanguageIn(LanguageMode.ECMASCRIPT6_TYPED);
//options.setLanguageOut(LanguageMode.ECMASCRIPT6_TYPED);
options.setPreserveTypeAnnotations(true);
options.setPrettyPrint(true);
options.setLineLengthThreshold(80);
options.setPreferSingleQuotes(true);
options.setIdeMode(true);
options.setParseJsDocDocumentation(true);
options.setExternExports(false);
options.setExtraAnnotationNames(Arrays.asList(asdocTags));
options.setLanguageIn(LanguageMode.ECMASCRIPT6_STRICT);
options.setLanguageIn(LanguageMode.ECMASCRIPT5_STRICT);
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new NamespaceResolutionPass(model,
jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new ResolvePackagesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectTypesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new AddMemberPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectImportsPass(model, jscompiler));
//compiler.setErrorManager(testErrorManager);
jscompiler.initOptions(options);
// don't need custom error manager with es6->es5 language options
//jscompiler.setErrorManager(wrapErrorManager(jscompiler.getErrorManager()));
model.setJSCompiler(jscompiler);
}
代码示例来源:origin: org.apache.royale.compiler/compiler-externc
private void initializeCompiler()
{
jscompiler = new Compiler();
options = new JXCompilerOptions();
//options.setLanguageIn(LanguageMode.ECMASCRIPT6_TYPED);
//options.setLanguageOut(LanguageMode.ECMASCRIPT6_TYPED);
options.setPreserveTypeAnnotations(true);
options.setPrettyPrint(true);
options.setLineLengthThreshold(80);
options.setPreferSingleQuotes(true);
options.setIdeMode(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
options.setExternExports(false);
options.setExtraAnnotationNames(Arrays.asList(asdocTags));
options.setLanguageIn(LanguageMode.ECMASCRIPT_2015);
options.setLanguageIn(LanguageMode.ECMASCRIPT5_STRICT);
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new NamespaceResolutionPass(model,
jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new ResolvePackagesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectTypesPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new AddMemberPass(model, jscompiler));
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, new CollectImportsPass(model, jscompiler));
//compiler.setErrorManager(testErrorManager);
jscompiler.initOptions(options);
// don't need custom error manager with es6->es5 language options
//jscompiler.setErrorManager(wrapErrorManager(jscompiler.getErrorManager()));
model.setJSCompiler(jscompiler);
}
内容来源于网络,如有侵权,请联系作者删除!