本文整理汇总了Java中com.google.javascript.jscomp.CompilerOptions.setChecksOnly方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerOptions.setChecksOnly方法的具体用法?Java CompilerOptions.setChecksOnly怎么用?Java CompilerOptions.setChecksOnly使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.javascript.jscomp.CompilerOptions
的用法示例。
在下文中一共展示了CompilerOptions.setChecksOnly方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCompilerOptions
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
public CompilerOptions getCompilerOptions() {
final CompilerOptions options = new CompilerOptions();
options.setClosurePass(true);
options.setCheckGlobalNamesLevel(CheckLevel.ERROR);
// Report duplicate definitions, e.g. for accidentally duplicated externs.
options.setWarningLevel(DiagnosticGroups.DUPLICATE_VARS, CheckLevel.ERROR);
options.setLanguage(CompilerOptions.LanguageMode.ECMASCRIPT_2015);
options.setLanguageOut(CompilerOptions.LanguageMode.NO_TRANSPILE);
// Do not transpile module declarations
options.setWrapGoogModulesForWhitespaceOnly(false);
// Stop escaping the characters "=&<>"
options.setTrustedStrings(true);
options.setPreferSingleQuotes(true);
// Compiler passes must be disabled to disable down-transpilation to ES5.
options.skipAllCompilerPasses();
// turns off optimizations.
options.setChecksOnly(true);
options.setPreserveDetailedSourceInfo(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
return options;
}
示例2: createCompilerOptions
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions createCompilerOptions() {
CompilerOptions options = new CompilerOptions();
options.setLanguageOut(ECMASCRIPT5);
options.setChecksOnly(true);
options.setStrictModeInput(true);
options.setCheckTypes(true);
options.setPreserveDetailedSourceInfo(true);
return options;
}
示例3: getCompilerOptions
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
public CompilerOptions getCompilerOptions() {
final CompilerOptions options = new CompilerOptions();
options.setClosurePass(true);
DependencyOptions deps = new DependencyOptions();
deps.setDependencySorting(true);
options.setDependencyOptions(deps);
if (!this.entryPoints.isEmpty()) {
options.setManageClosureDependencies(this.entryPoints);
}
// All diagnostics are WARNINGs (or off) and thus ignored unless debug == true.
// Only report issues (and fail for them) that are specifically causing problems for Clutz.
// The idea is to not do a general sanity check of Closure code, just make sure Clutz works.
// Report missing types as errors.
options.setCheckGlobalNamesLevel(CheckLevel.ERROR);
// Report duplicate definitions, e.g. for accidentally duplicated externs.
options.setWarningLevel(DiagnosticGroups.DUPLICATE_VARS, CheckLevel.ERROR);
// Late Provides are errors by default, but they do not prevent clutz from transpiling.
options.setWarningLevel(DiagnosticGroups.LATE_PROVIDE, CheckLevel.OFF);
options.setLanguage(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT5);
options.setCheckTypes(true);
options.setInferTypes(true);
// turns off optimizations.
options.setChecksOnly(true);
options.setPreserveDetailedSourceInfo(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
if (partialInput) {
options.setAssumeForwardDeclaredForMissingTypes(true);
options.setWarningLevel(DiagnosticGroups.MISSING_SOURCES_WARNINGS, CheckLevel.OFF);
}
return options;
}
示例4: getCompilerOptions
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@VisibleForTesting
public static CompilerOptions getCompilerOptions() {
CompilerOptions options = new CompilerOptions();
options.setLanguageIn(LanguageMode.ECMASCRIPT_NEXT);
options.setLanguageOut(LanguageMode.ECMASCRIPT5);
options.setSummaryDetailLevel(0);
DependencyOptions deps = new DependencyOptions();
deps.setDependencySorting(true);
options.setDependencyOptions(deps);
options.setChecksOnly(true);
options.setContinueAfterErrors(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_NO_WHITESPACE);
options.setCheckSuspiciousCode(true);
options.setCheckSymbols(true);
options.setCheckTypes(true);
options.setBrokenClosureRequiresLevel(CheckLevel.OFF);
// TODO(bangert): Remove this -- we want to rewrite code before closure syntax is removed.
// Unfortunately, setClosurePass is required, or code doesn't type check.
options.setClosurePass(true);
options.setGenerateExports(true);
options.setPreserveClosurePrimitives(true);
options.setWarningLevel(DiagnosticGroups.STRICT_MISSING_REQUIRE, CheckLevel.WARNING);
options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE, CheckLevel.WARNING);
options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING);
return options;
}
示例5: compile
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected RunResult compile(String js1, String fileName1, String js2, String fileName2) {
Compiler compiler = new Compiler();
CompilerOptions options = getCompilerOptions();
options.setChecksOnly(true);
List<SourceFile> inputs = ImmutableList.of(SourceFile.fromCode(fileName1, js1));
if (js2 != null && fileName2 != null) {
inputs =
ImmutableList.of(
SourceFile.fromCode(fileName1, js1), SourceFile.fromCode(fileName2, js2));
}
Result result = compiler.compile(EXTERNS, inputs, options);
assertTrue("compilation failed", result.success);
String source = compiler.toSource();
StringBuilder sb = new StringBuilder();
try {
result.sourceMap.validate(true);
result.sourceMap.appendTo(sb, "testcode");
} catch (IOException e) {
throw new RuntimeException("unexpected exception", e);
}
RunResult rr = new RunResult();
rr.generatedSource = source;
rr.sourceMap = result.sourceMap;
rr.sourceMapFileContent = sb.toString();
return rr;
}
示例6: provideCompilerOptions
import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Provides
CompilerOptions provideCompilerOptions(
AliasTransformListener transformListener,
ModuleCollectionPass moduleCollectionPass,
ProvidedSymbolPass providedSymbolPass,
TypeCollectionPass typeCollectionPass,
@Modules ImmutableSet<Path> modulePaths)
throws IOException {
CompilerOptions options = new CompilerOptions();
if (modulePaths.isEmpty()) {
options.setEnvironment(CompilerOptions.Environment.BROWSER);
options.setModuleResolutionMode(ModuleLoader.ResolutionMode.BROWSER);
} else {
options.setEnvironment(CompilerOptions.Environment.CUSTOM);
options.setModuleResolutionMode(ModuleLoader.ResolutionMode.NODE);
}
options.setModuleRoots(ImmutableList.of());
options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
options.setLanguageOut(LanguageMode.ECMASCRIPT5);
options.setCodingConvention(new ClosureCodingConvention());
CompilationLevel.ADVANCED_OPTIMIZATIONS.setOptionsForCompilationLevel(options);
CompilationLevel.ADVANCED_OPTIMIZATIONS.setTypeBasedOptimizationOptions(options);
options.setChecksOnly(true);
options.setContinueAfterErrors(true);
options.setAllowHotswapReplaceScript(true);
options.setPreserveDetailedSourceInfo(true);
options.setParseJsDocDocumentation(Config.JsDocParsing.INCLUDE_DESCRIPTIONS_WITH_WHITESPACE);
// For easier debugging.
options.setPrettyPrint(true);
options.setAliasTransformationHandler(transformListener);
options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, moduleCollectionPass);
options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, providedSymbolPass);
options.addCustomPass(CustomPassExecutionTime.BEFORE_OPTIMIZATIONS, typeCollectionPass);
return options;
}