当前位置: 首页>>代码示例>>Java>>正文


Java CompilerOptions.setWarningLevel方法代码示例

本文整理汇总了Java中com.google.javascript.jscomp.CompilerOptions.setWarningLevel方法的典型用法代码示例。如果您正苦于以下问题:Java CompilerOptions.setWarningLevel方法的具体用法?Java CompilerOptions.setWarningLevel怎么用?Java CompilerOptions.setWarningLevel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.jscomp.CompilerOptions的用法示例。


在下文中一共展示了CompilerOptions.setWarningLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:angular,项目名称:clutz,代码行数:27,代码来源:Options.java

示例2: initCompilationResources

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions initCompilationResources() {
  CompilerOptions options = new CompilerOptions();
  CompilationLevel.SIMPLE_OPTIMIZATIONS.setOptionsForCompilationLevel( options );

  options.setSourceMapOutputPath( "." );

  WarningLevel.QUIET.setOptionsForWarningLevel( options );
  options.setWarningLevel( DiagnosticGroups.LINT_CHECKS, CheckLevel.OFF );

  options.setLanguageIn( CompilerOptions.LanguageMode.ECMASCRIPT5 );

  // make sure these are clear
  this.lastPrefix = null;
  this.lastLocationMapping = null;

  return options;
}
 
开发者ID:pentaho,项目名称:pentaho-osgi-bundles,代码行数:18,代码来源:WebjarsURLConnection.java

示例3: setOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected void setOptions(CompilerOptions options) {
  options.setLanguageIn(LanguageMode.ECMASCRIPT_NEXT);
  // TODO(sdh): It would be nice to allow people to output code in
  // strict mode.  But currently we swallow all the input language
  // strictness checks, and there are various tests that are never
  // compiled and so are broken when we output 'use strict'.  We
  // could consider adding some sort of logging/warning/error in
  // cases where the input was not strict, though there could still
  // be semantic differences even if syntax is strict.  Possibly
  // the first step would be to allow the option of outputting strict
  // and then change the default and see what breaks.  b/33005948
  options.setLanguageOut(LanguageMode.ECMASCRIPT5);
  options.setQuoteKeywordProperties(true);
  options.setSkipNonTranspilationPasses(true);
  options.setVariableRenaming(VariableRenamingPolicy.OFF);
  options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
  options.setWrapGoogModulesForWhitespaceOnly(false);
  options.setPrettyPrint(true);
  options.setSourceMapOutputPath("/dev/null");
  options.setSourceMapIncludeSourcesContent(true);
  options.setWarningLevel(ES5_WARNINGS, CheckLevel.OFF);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:BaseTranspiler.java

示例4: setOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
protected void setOptions(CompilerOptions options) {
  options.setLanguageIn(LanguageMode.ECMASCRIPT_2017);
    // TODO(sdh): It would be nice to allow people to output code in
    // strict mode.  But currently we swallow all the input language
    // strictness checks, and there are various tests that are never
    // compiled and so are broken when we output 'use strict'.  We
    // could consider adding some sort of logging/warning/error in
    // cases where the input was not strict, though there could still
    // be semantic differences even if syntax is strict.  Possibly
    // the first step would be to allow the option of outputting strict
    // and then change the default and see what breaks.  b/33005948
    options.setLanguageOut(LanguageMode.ECMASCRIPT5);
    options.setQuoteKeywordProperties(true);
    options.setSkipNonTranspilationPasses(true);
    options.setVariableRenaming(VariableRenamingPolicy.OFF);
    options.setPropertyRenaming(PropertyRenamingPolicy.OFF);
    options.setWrapGoogModulesForWhitespaceOnly(false);
    options.setPrettyPrint(true);
    options.setSourceMapOutputPath("/dev/null");
    options.setSourceMapIncludeSourcesContent(true);
    options.setWarningLevel(ES5_WARNINGS, CheckLevel.OFF);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:23,代码来源:CompilerBasedTransformer.java

示例5: 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;
}
 
开发者ID:angular,项目名称:clutz,代码行数:38,代码来源:Options.java

示例6: build

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
public static String build(Task task, List<File> inputs) {
  List<SourceFile> externs;
  try {
    externs = CommandLineRunner.getDefaultExterns();
  } catch (IOException e) {
    throw new BuildException(e);
  }

  List<SourceFile> jsInputs = new ArrayList<SourceFile>();
  for (File f : inputs) {
    jsInputs.add(SourceFile.fromFile(f));
  }

  CompilerOptions options = new CompilerOptions();
  CompilationLevel.ADVANCED_OPTIMIZATIONS
      .setOptionsForCompilationLevel(options);
  WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
  for (DiagnosticGroup dg : diagnosticGroups) {
    options.setWarningLevel(dg, CheckLevel.ERROR);
  }

  options.setCodingConvention(new GoogleCodingConvention());

  Compiler compiler = new Compiler();
  MessageFormatter formatter =
      options.errorFormat.toFormatter(compiler, false);
  AntErrorManager errorManager = new AntErrorManager(formatter, task);
  compiler.setErrorManager(errorManager);

  Result r = compiler.compile(externs, jsInputs, options);
  if (!r.success) {
    return null;
  }

  String wrapped = "(function(){" + compiler.toSource() + "})();\n";
  return wrapped;
}
 
开发者ID:google,项目名称:caja,代码行数:38,代码来源:ClosureCompiler.java

示例7: createCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions createCompilerOptions() {
  CompilerOptions options = new CompilerOptions();

  this.compilationLevel.setOptionsForCompilationLevel(options);
  if (this.debugOptions) {
    this.compilationLevel.setDebugOptionsForCompilationLevel(options);
  }

  options.prettyPrint = this.prettyPrint;
  options.printInputDelimiter = this.printInputDelimiter;
  options.generateExports = this.generateExports;

  options.setLanguageIn(this.languageIn);

  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);

  if (replaceProperties) {
    convertPropertiesMap(options);
  }

  convertDefineParameters(options);

  for (Warning warning : warnings) {
    CheckLevel level = warning.getLevel();
    String groupName = warning.getGroup();
    DiagnosticGroup group = new DiagnosticGroups().forName(groupName);
    if (group == null) {
      throw new BuildException(
          "Unrecognized 'warning' option value (" + groupName + ")");
    }
    options.setWarningLevel(group, level);
  }

  return options;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:37,代码来源:CompileTask.java

示例8: getOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected CompilerOptions getOptions() {
  CompilerOptions options = super.getOptions();
  if (checkLevel != null) {
    options.setWarningLevel(
        DiagnosticGroups.DEBUGGER_STATEMENT_PRESENT,
        checkLevel);
  }
  return options;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:CheckDebuggerStatementTest.java

示例9: 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;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:31,代码来源:RefactoringDriver.java

示例10: process

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
public String process(final String filename, final String source, final Config conf)
    throws Exception {
  final CompilerOptions copts = new CompilerOptions();
  copts.setCodingConvention(new ClosureCodingConvention());
  copts.setOutputCharset("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);
}
 
开发者ID:jooby-project,项目名称:jooby,代码行数:28,代码来源:ClosureCompiler.java

示例11: getOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected CompilerOptions getOptions() {
  CompilerOptions options = super.getOptions();
  options.setWarningLevel(DiagnosticGroups.ACCESS_CONTROLS, CheckLevel.ERROR);
  return options;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:7,代码来源:CheckAccessControlsTest.java

示例12: testPropsValidator

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Test public void testPropsValidator() {
  Compiler compiler = new Compiler(
      new PrintStream(ByteStreams.nullOutputStream())); // Silence logging
  CompilerOptions options = new CompilerOptions();
  CompilationLevel.ADVANCED_OPTIMIZATIONS
      .setOptionsForCompilationLevel(options);
  WarningLevel.VERBOSE.setOptionsForWarningLevel(options);
  options.setLanguageIn(CompilerOptions.LanguageMode.ECMASCRIPT5);
  options.setWarningLevel(
      DiagnosticGroups.MISSING_PROPERTIES, CheckLevel.ERROR);
  // Report warnings as errors to make tests simpler
  options.addWarningsGuard(new StrictWarningsGuard());
  ReactCompilerPass.Options passOptions = new ReactCompilerPass.Options();
  passOptions.propTypesTypeChecking = true;
  ReactCompilerPass compilerPass = new ReactCompilerPass(
      compiler, passOptions);
  options.addCustomPass(CustomPassExecutionTime.BEFORE_CHECKS, compilerPass);
  options.addWarningsGuard(new ReactWarningsGuard(compiler, compilerPass));
  String inputJs = "var Comp = React.createClass({" +
      "propTypes: {" +
        "strProp: React.PropTypes.string" +
      "}," +
      "render: function() {return null;}" +
    "});\n" +
    "React.createElement(Comp, {strProp: 1});";
  List<SourceFile> inputs = ImmutableList.of(
      SourceFile.fromCode("/src/react.js", "/** @providesModule React */"),
      SourceFile.fromCode("/src/test.js", inputJs));
  List<SourceFile> externs = ImmutableList.of(
      SourceFile.fromCode(
        "externs",
        "/** @constructor */ function Element() {};\n" +
        "/** @constructor */ function Event() {};"));
  Result result = compiler.compile(externs, inputs, options);
  assertFalse(result.success);
  assertEquals(1, result.errors.length);
  JSError error = result.errors[0];
  assertFalse(
      error.description,
      error.description.contains("Comp$$PropsValidator"));
  assertTrue(
      error.description,
      error.description.contains("\"strProp\" was expected to be of type"));
  assertEquals(
      PropTypesExtractor.PROP_TYPES_VALIDATION_MISMATCH, error.getType());
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:47,代码来源:ReactWarningsGuardTest.java

示例13: createCompilerOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
private CompilerOptions createCompilerOptions() {
  CompilerOptions options = new CompilerOptions();

  this.compilationLevel.setOptionsForCompilationLevel(options);
  if (this.debugOptions) {
    this.compilationLevel.setDebugOptionsForCompilationLevel(options);
  }

  options.setEnvironment(this.environment);

  options.setPrettyPrint(this.prettyPrint);
  options.setPrintInputDelimiter(this.printInputDelimiter);
  options.setPreferSingleQuotes(this.preferSingleQuotes);
  options.setGenerateExports(this.generateExports);

  options.setLanguageIn(this.languageIn);
  options.setLanguageOut(this.languageOut);
  options.setOutputCharset(this.outputEncoding);

  this.warningLevel.setOptionsForWarningLevel(options);
  options.setManageClosureDependencies(manageDependencies);
  convertEntryPointParameters(options);
  options.setTrustedStrings(true);
  options.setAngularPass(angularPass);

  if (replaceProperties) {
    convertPropertiesMap(options);
  }

  convertDefineParameters(options);

  for (Warning warning : warnings) {
    CheckLevel level = warning.getLevel();
    String groupName = warning.getGroup();
    DiagnosticGroup group = new DiagnosticGroups().forName(groupName);
    if (group == null) {
      throw new BuildException(
          "Unrecognized 'warning' option value (" + groupName + ")");
    }
    options.setWarningLevel(group, level);
  }

  if (!Strings.isNullOrEmpty(sourceMapFormat)) {
    options.setSourceMapFormat(Format.valueOf(sourceMapFormat));
  }

  if (!Strings.isNullOrEmpty(sourceMapLocationMapping)) {
    String[] tokens = sourceMapLocationMapping.split("\\|", -1);
    LocationMapping lm = new LocationMapping(tokens[0], tokens[1]);
    options.setSourceMapLocationMappings(Arrays.asList(lm));
  }

  options.setApplyInputSourceMaps(applyInputSourceMaps);

  if (sourceMapOutputFile != null) {
    File parentFile = sourceMapOutputFile.getParentFile();
    if (parentFile.mkdirs()) {
      log("Created missing parent directory " + parentFile, Project.MSG_DEBUG);
    }
    options.setSourceMapOutputPath(parentFile.getAbsolutePath());
  }
  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:64,代码来源:CompileTask.java

示例14: getOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected CompilerOptions getOptions(CompilerOptions options) {
  super.getOptions(options);
  options.setWarningLevel(DiagnosticGroups.ANALYZER_CHECKS, CheckLevel.WARNING);
  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:7,代码来源:CheckNullableReturnTest.java

示例15: getOptions

import com.google.javascript.jscomp.CompilerOptions; //导入方法依赖的package包/类
@Override
protected CompilerOptions getOptions(CompilerOptions options) {
  super.getOptions(options);
  options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.WARNING);
  return options;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:7,代码来源:CheckInterfacesTest.java


注:本文中的com.google.javascript.jscomp.CompilerOptions.setWarningLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。