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


Java DiagnosticGroups类代码示例

本文整理汇总了Java中com.google.javascript.jscomp.DiagnosticGroups的典型用法代码示例。如果您正苦于以下问题:Java DiagnosticGroups类的具体用法?Java DiagnosticGroups怎么用?Java DiagnosticGroups使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


DiagnosticGroups类属于com.google.javascript.jscomp包,在下文中一共展示了DiagnosticGroups类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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.DiagnosticGroups; //导入依赖的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: getCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例4: createCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例5: getOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例6: getCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例7: setUp

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的package包/类
@Before
public void setUp() {
  errorManager = new FixingErrorManager();
  compiler = new Compiler(errorManager);
  compiler.disableThreads();
  errorManager.setCompiler(compiler);

  options = RefactoringDriver.getCompilerOptions();
  options.setWarningLevel(DiagnosticGroups.ANALYZER_CHECKS, WARNING);
  options.setWarningLevel(DiagnosticGroups.CHECK_VARIABLES, ERROR);
  options.setWarningLevel(DiagnosticGroups.DEBUGGER_STATEMENT_PRESENT, ERROR);
  options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, WARNING);
  options.setWarningLevel(DiagnosticGroups.STRICT_MISSING_REQUIRE, ERROR);
  options.setWarningLevel(DiagnosticGroups.EXTRA_REQUIRE, ERROR);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:16,代码来源:ErrorToFixMapperTest.java

示例8: process

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例9: testPropsValidator

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例10: createCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例11: getOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例12: getOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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

示例13: createCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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);
  options.setOutputCharset(this.outputEncoding);

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

  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.sourceMapFormat = Format.valueOf(sourceMapFormat);
  }

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

示例14: visit

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的package包/类
@Override
public void visit(Warning n, Object ctx) throws Exception {
	super.visit(n, ctx);
	if (n.getSeverity() != null && n.getType() != null) {
		switch (n.getType()) {
		case AGGRESSIVE_VAR_CHECK:
			jsOptions
					.setAggressiveVarCheck(mapSeverityType(n.getSeverity()));
			break;
		case BROKEN_REQUIRES_LEVEL:
			jsOptions.setBrokenClosureRequiresLevel(mapSeverityType(n
					.getSeverity()));
			break;
		case CHECK_GLOBAL_NAMES_LEVEL:
			jsOptions.setCheckGlobalNamesLevel(mapSeverityType(n
					.getSeverity()));
			break;
		case CHECK_GLOBAL_THIS_LEVEL:
			jsOptions.setCheckGlobalThisLevel(mapSeverityType(n
					.getSeverity()));
			break;
		// case CHECK_MISSING_GET_CSS_NAME_LEVEL:
		// jsOptions.setCheckMissingGetCssNameLevel(mapSeverityType(n
		// .getSeverity()));
		// break;
		case CHECK_MISSING_RETURN:
			jsOptions
					.setCheckMissingReturn(mapSeverityType(n.getSeverity()));
			break;
		case CHECK_REQUIRES:
			jsOptions.setWarningLevel(
					DiagnosticGroups.MISSING_REQUIRE,
					mapSeverityType(n.getSeverity()));
			break;
		// case CHECK_UNREACHABLE_CODE:
		// jsOptions.setCheckUnreachableCode(mapSeverityType(n
		// .getSeverity()));
		// break;
		case REPORT_MISSING_OVERRIDE:
			jsOptions.setReportMissingOverride(mapSeverityType(n
					.getSeverity()));
			break;
		default:
			DiagnosticGroup group = mapWarningType(n.getType());
			CheckLevel level = mapSeverityType(n.getSeverity());
			if (group != null && level != null) {
				jsOptions.setWarningLevel(group, level);
			}
			break;
		}
	}

	if (n.getSeverity() != null) {
		n.getSeverity().accept(this, ctx);
	}
	if (n.getType() != null) {
		n.getType().accept(this, ctx);
	}
}
 
开发者ID:DigiArea,项目名称:closurefx-builder,代码行数:60,代码来源:Closurer.java

示例15: createCompilerOptions

import com.google.javascript.jscomp.DiagnosticGroups; //导入依赖的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);
  }

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

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


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