• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java SimpleErrorReporter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: testTypeResolutionModes

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testTypeResolutionModes() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();

  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(reporter);
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  JSTypeRegistry lazyNameRegistry = new JSTypeRegistry(reporter);
  lazyNameRegistry.setResolveMode(ResolveMode.LAZY_NAMES);

  JSTypeRegistry immediateRegistry = new JSTypeRegistry(reporter);
  immediateRegistry.setResolveMode(ResolveMode.IMMEDIATE);

  Node expr = new Node(Token.QMARK, Node.newString("foo"));
  StaticScope<JSType> empty = new EmptyScope();

  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnresolvedTypeExpression);
  assertTrue(type.isUnknownType());
  assertEquals("?", type.toString());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  type = lazyNameRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnionType);
  assertTrue(type.isUnknownType());
  assertEquals("(foo|null)", type.toString());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  type = immediateRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnknownType);
  assertEquals("Expected warnings", 1, reporter.warnings().size());
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:37,代码来源:JSTypeRegistryTest.java


示例2: testForceResolve

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testForceResolve() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();

  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(reporter);
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  Node expr = new Node(Token.QMARK, Node.newString("foo"));
  StaticScope<JSType> empty = new EmptyScope();

  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertFalse(type.isResolved());
  assertTrue(type.forceResolve(reporter, empty).isResolved());
  assertEquals("Expected warnings", 1, reporter.warnings().size());
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:16,代码来源:JSTypeRegistryTest.java


示例3: testAllTypeResolvesImmediately

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testAllTypeResolvesImmediately() {
  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(
      new SimpleErrorReporter());
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  Node expr = new Node(Token.STAR);
  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", new EmptyScope());
  assertTrue(type instanceof AllType);
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:11,代码来源:JSTypeRegistryTest.java


示例4: testTypeResolutionModes

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testTypeResolutionModes() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();

  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(reporter);
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  JSTypeRegistry lazyNameRegistry = new JSTypeRegistry(reporter);
  lazyNameRegistry.setResolveMode(ResolveMode.LAZY_NAMES);

  JSTypeRegistry immediateRegistry = new JSTypeRegistry(reporter);
  immediateRegistry.setResolveMode(ResolveMode.IMMEDIATE);

  Node expr = new Node(Token.QMARK, Node.newString("foo"));
  StaticScope<JSType> empty = MapBasedScope.emptyScope();

  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnresolvedTypeExpression);
  assertTrue(type.isUnknownType());
  assertEquals("?", type.toString());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  type = lazyNameRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnionType);
  assertTrue(type.isUnknownType());
  assertEquals("(foo|null)", type.toString());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  type = immediateRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertTrue(type instanceof UnknownType);
  assertEquals("Expected warnings", 1, reporter.warnings().size());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:37,代码来源:JSTypeRegistryTest.java


示例5: testForceResolve

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testForceResolve() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();

  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(reporter);
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  Node expr = new Node(Token.QMARK, Node.newString("foo"));
  StaticScope<JSType> empty = MapBasedScope.emptyScope();

  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", empty);
  assertFalse(type.isResolved());
  assertTrue(type.forceResolve(reporter, empty).isResolved());
  assertEquals("Expected warnings", 1, reporter.warnings().size());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:16,代码来源:JSTypeRegistryTest.java


示例6: testAllTypeResolvesImmediately

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testAllTypeResolvesImmediately() {
  JSTypeRegistry lazyExprRegistry = new JSTypeRegistry(
      new SimpleErrorReporter());
  lazyExprRegistry.setResolveMode(ResolveMode.LAZY_EXPRESSIONS);

  Node expr = new Node(Token.STAR);
  JSType type = lazyExprRegistry.createFromTypeNodes(
      expr, "source.js", MapBasedScope.emptyScope());
  assertTrue(type instanceof AllType);
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:11,代码来源:JSTypeRegistryTest.java


示例7: addNewWarning

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private void addNewWarning(String messageId, String messageArg, Node nodeWarning) {
  // TODO(lpino): Use the exact lineno and charno, it is currently using
  // the lineno and charno of the parent @template
  // TODO(lpino): Use only constants as parameters of this method
  errorReporter.warning(
      "Bad type annotation. "
          + SimpleErrorReporter.getMessage1(messageId, messageArg),
          sourceFile.getName(),
          templateLineno,
          templateCharno);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:12,代码来源:TypeTransformationParser.java


示例8: addTypeWarning

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private void addTypeWarning(String messageId, String messageArg, int lineno, int charno) {
  errorReporter.warning(
      "Bad type annotation. " + SimpleErrorReporter.getMessage1(messageId, messageArg)
          + BAD_TYPE_WIKI_LINK,
      getSourceName(),
      lineno,
      charno);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:9,代码来源:JsDocInfoParser.java


示例9: addTypeWarning

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
void addTypeWarning(String messageId, String messageArg, int lineno,
                int charno) {
  errorReporter.warning(
      "Bad type annotation. " +
      SimpleErrorReporter.getMessage1(messageId, messageArg),
      getSourceName(), lineno, null, charno);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:8,代码来源:JsDocInfoParser.java


示例10: RhinoErrorReporter

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private RhinoErrorReporter(AbstractCompiler compiler) {
  this.compiler = compiler;
  typeMap = ImmutableMap.<Pattern, DiagnosticType>builder()
      // Trailing comma
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.extra.trailing.comma")),
          TRAILING_COMMA)

      // Duplicate parameter
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.dup.parms")),
          DUPLICATE_PARAM)

      // Unknown @annotations.
      .put(replacePlaceHolders(
          SimpleErrorReporter.getMessage0("msg.bad.jsdoc.tag")),
          BAD_JSDOC_ANNOTATION)

      // Unexpected @type annotations
      .put(Pattern.compile("^Type annotations are not allowed here.*"),
          MISPLACED_TYPE_ANNOTATION)

      // Unexpected @type annotations
      .put(Pattern.compile("^Keywords and reserved words" +
          " are not allowed as unquoted property.*"),
          INVALID_ES3_PROP_NAME)

      // Type annotation errors.
      .put(Pattern.compile("^Bad type annotation.*"),
          TYPE_PARSE_ERROR)

      // Parse tree too deep.
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.too.deep.parser.recursion")),
          PARSE_TREE_TOO_DEEP)
      .build();
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:41,代码来源:RhinoErrorReporter.java


示例11: testGenerationIncrementing1

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testGenerationIncrementing1() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();
  final JSTypeRegistry typeRegistry = new JSTypeRegistry(reporter);

  StaticScope<JSType> scope = new AbstractStaticScope<JSType>() {
        @Override
        public StaticSlot<JSType> getSlot(final String name) {
          return new SimpleSlot(
              name,
              typeRegistry.getNativeType(JSTypeNative.UNKNOWN_TYPE),
              false);
        }
      };

  ObjectType namedType =
      (ObjectType) typeRegistry.getType(scope, "Foo", null, 0, 0);
  ObjectType subNamed =
      typeRegistry.createObjectType(typeRegistry.createObjectType(namedType));

  // Subclass of named type is initially unresolved.
  typeRegistry.setLastGeneration(false);
  typeRegistry.resolveTypesInScope(scope);
  assertTrue(subNamed.isUnknownType());

  // Subclass of named type is still unresolved, even though the named type is
  // now present in the registry.
  typeRegistry.declareType("Foo",
                           typeRegistry.createAnonymousObjectType(null));
  typeRegistry.resolveTypesInScope(scope);
  assertTrue(subNamed.isUnknownType());

  assertNull("Unexpected errors: " + reporter.errors(),
      reporter.errors());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  // After incrementing the generation, resolve works again.
  typeRegistry.incrementGeneration();
  typeRegistry.setLastGeneration(true);
  typeRegistry.resolveTypesInScope(scope);
  assertFalse(subNamed.isUnknownType());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:43,代码来源:JSTypeRegistryTest.java


示例12: testGenerationIncrementing2

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
public void testGenerationIncrementing2() {
  SimpleErrorReporter reporter = new SimpleErrorReporter();
  final JSTypeRegistry typeRegistry = new JSTypeRegistry(reporter);

  StaticScope<JSType> scope = new AbstractStaticScope<JSType>() {
        @Override
        public StaticSlot<JSType> getSlot(final String name) {
          return new SimpleSlot(
              name,
              typeRegistry.getNativeType(JSTypeNative.UNKNOWN_TYPE),
              false);
        }
      };

  ObjectType namedType =
      (ObjectType) typeRegistry.getType(scope, "Foo", null, 0, 0);
  FunctionType functionType = typeRegistry.createFunctionType(namedType);

  // Subclass of named type is initially unresolved.
  typeRegistry.setLastGeneration(false);
  typeRegistry.resolveTypesInScope(scope);
  assertTrue(functionType.getReturnType().isUnknownType());
  functionType.resolve(reporter, scope);
  assertTrue(functionType.getReturnType().isUnknownType());

  // Subclass of named type is still unresolved, even though the named type is
  // now present in the registry.
  typeRegistry.declareType("Foo",
                           typeRegistry.createAnonymousObjectType(null));
  typeRegistry.resolveTypesInScope(scope);
  assertTrue(functionType.getReturnType().isUnknownType());

  assertNull("Unexpected errors: " + reporter.errors(),
      reporter.errors());
  assertNull("Unexpected warnings: " + reporter.warnings(),
      reporter.warnings());

  // After incrementing the generation, resolve works again.
  typeRegistry.incrementGeneration();
  typeRegistry.setLastGeneration(true);
  typeRegistry.resolveTypesInScope(scope);
  assertFalse(functionType.getReturnType().isUnknownType());
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:44,代码来源:JSTypeRegistryTest.java


示例13: RhinoErrorReporter

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private RhinoErrorReporter(AbstractCompiler compiler) {
  this.compiler = compiler;
  typeMap =
      ImmutableMap.<Pattern, DiagnosticType>builder()
          // Trailing comma
          .put(
              Pattern.compile("Trailing comma is not legal in an ECMA-262 object initializer"),
              TRAILING_COMMA)

          // Duplicate parameter
          .put(replacePlaceHolders("Duplicate parameter name \"{0}\""), DUPLICATE_PARAM)

          .put(Pattern.compile("Unnecessary escape:.*"), UNNECESSARY_ESCAPE)

          .put(Pattern.compile("^invalid param name.*"), INVALID_PARAM)

          // Unknown @annotations.
          .put(
              replacePlaceHolders(SimpleErrorReporter.getMessage0("msg.bad.jsdoc.tag")),
              BAD_JSDOC_ANNOTATION)

          .put(
              Pattern.compile("^" + Pattern.quote(
                  "Non-JSDoc comment has annotations. "
                      + "Did you mean to start it with '/**'?")),
              JSDOC_IN_BLOCK_COMMENT)

          .put(
              Pattern.compile(
                  "^Keywords and reserved words are not allowed as unquoted property.*"),
              INVALID_ES3_PROP_NAME)

          .put(Pattern.compile("^Too many template parameters"), TOO_MANY_TEMPLATE_PARAMS)

          // Type annotation warnings.
          .put(
              Pattern.compile(".*Type annotations should have curly braces.*"),
              JSDOC_MISSING_BRACES_WARNING)

          .put(Pattern.compile("Missing type declaration\\."), JSDOC_MISSING_TYPE_WARNING)

          // Unresolved types that aren't forward declared.
          .put(Pattern.compile(".*Unknown type.*"), UNRECOGNIZED_TYPE_ERROR)

          // Type annotation errors.
          .put(Pattern.compile("^Bad type annotation.*"), TYPE_PARSE_ERROR)

          // Parse tree too deep.
          .put(Pattern.compile("Too deep recursion while parsing"), PARSE_TREE_TOO_DEEP)

          // Old-style octal literals
          .put(Pattern.compile("^Octal .*literal.*"), INVALID_OCTAL_LITERAL)

          .put(Pattern.compile("^String continuations.*"), STRING_CONTINUATION)

          .put(
              Pattern.compile("^this language feature is only supported for ECMASCRIPT6 mode.*"),
              ES6_FEATURE)

          .put(Pattern.compile("^type syntax is only supported in ES6 typed mode.*"), ES6_TYPED)

          .put(Pattern.compile("^Can only have JSDoc or inline type.*"), MISPLACED_TYPE_SYNTAX)

          .build();
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:66,代码来源:RhinoErrorReporter.java


示例14: addParserWarning

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private void addParserWarning(String messageId, String messageArg, int lineno, int charno) {
  errorReporter.warning(
      SimpleErrorReporter.getMessage1(messageId, messageArg), getSourceName(), lineno, charno);
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:5,代码来源:JsDocInfoParser.java


示例15: RhinoErrorReporter

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
private RhinoErrorReporter(AbstractCompiler compiler) {
  this.compiler = compiler;
  typeMap = ImmutableMap.<Pattern, DiagnosticType>builder()
      // Trailing comma
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.extra.trailing.comma")),
          TRAILING_COMMA)

      // Duplicate parameter
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.dup.parms")),
          DUPLICATE_PARAM)

      // Unknown @annotations.
      .put(replacePlaceHolders(
          SimpleErrorReporter.getMessage0("msg.bad.jsdoc.tag")),
          BAD_JSDOC_ANNOTATION)

      // Unexpected @type annotations
      .put(Pattern.compile("^Type annotations are not allowed here.*"),
          MISPLACED_TYPE_ANNOTATION)

      // Unexpected @type annotations
      .put(Pattern.compile("^Keywords and reserved words" +
          " are not allowed as unquoted property.*"),
          INVALID_ES3_PROP_NAME)

      // Type annotation errors.
      .put(Pattern.compile("^Bad type annotation.*"),
          TYPE_PARSE_ERROR)

      // Parse tree too deep.
      .put(replacePlaceHolders(
          com.google.javascript.rhino.head.ScriptRuntime.getMessage0(
              "msg.too.deep.parser.recursion")),
          PARSE_TREE_TOO_DEEP)

      // Octal literals
      .put(Pattern.compile("^Octal .*literal.*"),
          INVALID_OCTAL_LITERAL)

      .build();
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:46,代码来源:RhinoErrorReporter.java


示例16: addParserWarning

import com.google.javascript.rhino.SimpleErrorReporter; //导入依赖的package包/类
void addParserWarning(String messageId, String messageArg, int lineno,
    int charno) {
  errorReporter.warning(
      SimpleErrorReporter.getMessage1(messageId, messageArg),
      getSourceName(), lineno, null, charno);
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:7,代码来源:JsDocInfoParser.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PodBuilder类代码示例发布时间:2022-05-23
下一篇:
Java HListView类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap