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


Java CheckLevel类代码示例

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


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

示例1: TypeCheck

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry,
    Scope topScope,
    ScopeCreator scopeCreator,
    CheckLevel reportMissingOverride,
    CheckLevel reportUnknownTypes) {
  this.compiler = compiler;
  this.validator = compiler.getTypeValidator();
  this.reverseInterpreter = reverseInterpreter;
  this.typeRegistry = typeRegistry;
  this.topScope = topScope;
  this.scopeCreator = scopeCreator;
  this.reportMissingOverride = reportMissingOverride;
  this.reportUnknownTypes = reportUnknownTypes;
  this.inferJSDocInfo = new InferJSDocInfo(compiler);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:TypeCheck.java

示例2: getProcessor

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
@Override
protected CompilerPass getProcessor(final Compiler compiler) {
  return new CompilerPass() {

    @Override
    public void process(Node externs, Node root) {
      new TypeCheck(compiler,
          new SemanticReverseAbstractInterpreter(
              compiler.getCodingConvention(),
              compiler.getTypeRegistry()),
          compiler.getTypeRegistry(),
          CheckLevel.ERROR,
          CheckLevel.ERROR).processForTesting(externs, root);

      new RemoveUnusedNames(
          compiler, canRemoveExterns).process(externs, root);

      // Use to remove side-effect-free artifacts that are left over.
      new UnreachableCodeElimination(compiler, true).process(externs, root);
    }
  };
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:RemoveUnusedNamesTest.java

示例3: testTypeCheckStandaloneAST

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public void testTypeCheckStandaloneAST() throws Exception {
  Node n = compiler.parseTestCode("function Foo() { }");
  typeCheck(n);
  TypedScopeCreator scopeCreator = new TypedScopeCreator(compiler);
  Scope topScope = scopeCreator.createScope(n, null);

  Node second = compiler.parseTestCode("new Foo");

  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, second);
  externAndJsRoot.setIsSyntheticBlock(true);

  new TypeCheck(
      compiler,
      new SemanticReverseAbstractInterpreter(
          compiler.getCodingConvention(), registry),
      registry, topScope, scopeCreator, CheckLevel.WARNING, CheckLevel.OFF)
      .process(null, second);

  assertEquals(1, compiler.getWarningCount());
  assertEquals("cannot instantiate non-constructor",
      compiler.getWarnings()[0].description);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:24,代码来源:TypeCheckTest.java

示例4: testNoSymbolMapStripsCallAndDoesntIssueWarnings

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public void testNoSymbolMapStripsCallAndDoesntIssueWarnings() {
  String input = "[goog.getCssName('test'), goog.getCssName(base, 'active')]";
  Compiler compiler = new Compiler();
  ErrorManager errorMan = new BasicErrorManager() {
    @Override protected void printSummary() {}
    @Override public void println(CheckLevel level, JSError error) {}
  };
  compiler.setErrorManager(errorMan);
  Node root = compiler.parseTestCode(input);
  useReplacementMap = false;
  ReplaceCssNames replacer = new ReplaceCssNames(compiler, null);
  replacer.process(null, root);
  assertEquals("[\"test\",base+\"-active\"]", compiler.toSource(root));
  assertEquals("There should be no errors", 0, errorMan.getErrorCount());
  assertEquals("There should be no warnings", 0, errorMan.getWarningCount());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:ReplaceCssNamesTest.java

示例5: testRequiresAreCaughtBeforeProcessed

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public void testRequiresAreCaughtBeforeProcessed() {
  String js = "var foo = {}; var bar = new foo.bar.goo();";
  JSSourceFile input = JSSourceFile.fromCode("foo.js", js);
  Compiler compiler = new Compiler();
  CompilerOptions opts = new CompilerOptions();
  opts.checkRequires = CheckLevel.WARNING;
  opts.closurePass = true;

  Result result = compiler.compile(new JSSourceFile[] {},
      new JSSourceFile[] {input}, opts);
  JSError[] warnings = result.warnings;
  assertNotNull(warnings);
  assertTrue(warnings.length > 0);

  String expectation = "'foo.bar.goo' used but not goog.require'd";

  for (JSError warning : warnings) {
    if (expectation.equals(warning.description)) {
      return;
    }
  }

  fail("Could not find the following warning:" + expectation);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:CheckRequiresForConstructorsTest.java

示例6: getCompilerOptions

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

示例7: report

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
@Override
public void report(CheckLevel level, JSError error) {
  // Ignore warnings in non-debug mode.
  if (!debug && level == CheckLevel.WARNING) return;

  if (reportClutzMissingTypes
      && error.description.contains("Bad type annotation. Unknown type")) {
    // Prepend an error that hints at missing externs/dependencies.
    reportClutzMissingTypes = false;
    // Leave out the location on purpose, the specific places of missing types are reported from
    // the original message; without a location this error sorts first, so that it is seen first.
    this.report(CheckLevel.ERROR, JSError.make(DeclarationGenerator.CLUTZ_MISSING_TYPES));
    // Fall through, still report the actual error below.
  }
  super.report(level, error);
}
 
开发者ID:angular,项目名称:clutz,代码行数:17,代码来源:ClutzErrorManager.java

示例8: level

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
@Override public CheckLevel level(JSError error) {
  if (error.sourceName == null) {
    return null;
  }

  // Ignore all warnings and errors in the React library itself -- it
  // generally compiles as intended, but it uses non-standard JSDoc which
  // throws off the compiler.
  if (React.isReactSourceName(error.sourceName)) {
    return CheckLevel.OFF;
  }

  // Rewrite propTypes warnings to be more legible.
  if (compiler != null && compilerPass != null &&
      error.getType().key.equals("JSC_TYPE_MISMATCH") &&
      handlePropTypesWarning(error)) {
    return CheckLevel.OFF;
  }

  return null;
}
 
开发者ID:mihaip,项目名称:react-closure-compiler,代码行数:22,代码来源:ReactWarningsGuard.java

示例9: initCompilationResources

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

示例10: getSecureCompilerOptions

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
/**
 * Returns compiler options which are safe for compilation of a cajoled
 * module. The set of options is similar to the one which is used by
 * CompilationLevel in simple mode. The main difference is that variable
 * renaming and closurePass options are turned off.
 */
private CompilerOptions getSecureCompilerOptions() {
  CompilerOptions options = new CompilerOptions();

  options.variableRenaming = VariableRenamingPolicy.OFF;
  options.setInlineVariables(Reach.LOCAL_ONLY);
  options.inlineLocalFunctions = true;
  options.checkGlobalThisLevel = CheckLevel.OFF;
  options.coalesceVariableNames = true;
  options.deadAssignmentElimination = true;
  options.collapseVariableDeclarations = true;
  options.convertToDottedProperties = true;
  options.labelRenaming = true;
  options.removeDeadCode = true;
  options.optimizeArgumentsArray = true;
  options.removeUnusedVars = false;
  options.removeUnusedLocalVars = true;

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

示例11: TypeCheck

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public TypeCheck(AbstractCompiler compiler,
    ReverseAbstractInterpreter reverseInterpreter,
    JSTypeRegistry typeRegistry,
    Scope topScope,
    MemoizedScopeCreator scopeCreator,
    CheckLevel reportMissingOverride,
    CheckLevel reportUnknownTypes) {
  this.compiler = compiler;
  this.validator = compiler.getTypeValidator();
  this.reverseInterpreter = reverseInterpreter;
  this.typeRegistry = typeRegistry;
  this.topScope = topScope;
  this.scopeCreator = scopeCreator;
  this.reportMissingOverride = reportMissingOverride;
  this.reportUnknownTypes = reportUnknownTypes;
  this.inferJSDocInfo = new InferJSDocInfo(compiler);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:TypeCheck.java

示例12: testTypeCheckStandaloneAST

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public void testTypeCheckStandaloneAST() throws Exception {
  Node n = compiler.parseTestCode("function Foo() { }");
  typeCheck(n);
  MemoizedScopeCreator scopeCreator =
      new MemoizedScopeCreator(new TypedScopeCreator(compiler));
  Scope topScope = scopeCreator.createScope(n, null);

  Node second = compiler.parseTestCode("new Foo");

  Node externs = new Node(Token.BLOCK);
  Node externAndJsRoot = new Node(Token.BLOCK, externs, second);
  externAndJsRoot.setIsSyntheticBlock(true);

  new TypeCheck(
      compiler,
      new SemanticReverseAbstractInterpreter(
          compiler.getCodingConvention(), registry),
      registry, topScope, scopeCreator, CheckLevel.WARNING, CheckLevel.OFF)
      .process(null, second);

  assertEquals(1, compiler.getWarningCount());
  assertEquals("cannot instantiate non-constructor",
      compiler.getWarnings()[0].description);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:LooseTypeCheckTest.java

示例13: testRequiresAreCaughtBeforeProcessed

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
public void testRequiresAreCaughtBeforeProcessed() {
  String js = "var foo = {}; var bar = new foo.bar.goo();";
  SourceFile input = SourceFile.fromCode("foo.js", js);
  Compiler compiler = new Compiler();
  CompilerOptions opts = new CompilerOptions();
  opts.checkRequires = CheckLevel.WARNING;
  opts.closurePass = true;

  Result result = compiler.compile(ImmutableList.<SourceFile>of(),
      ImmutableList.of(input), opts);
  JSError[] warnings = result.warnings;
  assertNotNull(warnings);
  assertTrue(warnings.length > 0);

  String expectation = "'foo.bar.goo' used but not goog.require'd";

  for (JSError warning : warnings) {
    if (expectation.equals(warning.description)) {
      return;
    }
  }

  fail("Could not find the following warning:" + expectation);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:25,代码来源:CheckRequiresForConstructorsTest.java

示例14: println

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void println(CheckLevel level, JSError error) {
	EType type = fileTypes.get(error.sourceName);
	boolean isLoadedFromClosureCompilerExterns = error.sourceName
			.startsWith("externs.zip/");
	boolean isLibrary = (type == EType.CODE_LIBRARY || isLoadedFromClosureCompilerExterns);

	if (isLibrary && level != CheckLevel.ERROR
			&& !reportLibraryWarnings) {
		return;
	}

	if (isFalsePositive(error)) {
		return;
	}

	messages.add("JavaScript problem (level: " + level + ") in "
			+ error.sourceName + ", line " + error.lineNumber + ": "
			+ error.description);
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:22,代码来源:ConQATJavaScriptCompiler.java

示例15: println

import com.google.javascript.jscomp.CheckLevel; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void println(CheckLevel level, JSError error) {
	if (level == CheckLevel.ERROR) {
		this.error = error;
	}
	ITextElement element = uniformPathToElementMap
			.get(error.sourceName);
	if (element == null) {
		getLogger().error("No element found for " + error.sourceName);
	} else {
		try {
			ResourceUtils.createAndAttachFindingForFilteredLine(group,
					error.description, element, error.lineNumber, KEY);
		} catch (ConQATException e) {
			getLogger().error(
					"Offset conversion failed: " + e.getMessage(), e);
		}
	}
}
 
开发者ID:vimaier,项目名称:conqat,代码行数:21,代码来源:ClosureAnalyzer.java


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