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


Java Token类代码示例

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


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

示例1: match

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
private CT match(TK tk, TokenKind open) {
    Token tok = advance();
    db("match desired-tk=%s, open=%s, seen-tok=%s", tk, open, tok.kind);
    if (stack.isEmpty()) {
        return new CT(ERROR, tok, "Encountered '" + tok + "' with no opening '" + open + "'");
    }
    Token p = stack.pop();
    if (p.kind != open) {
        return new CT(ERROR, tok, "No match for '" + p + "' instead encountered '" + tok + "'");
    }
    return new CT(tk, tok);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:CompletenessAnalyzer.java

示例2: comment

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
private Comment comment(String docString) {
    StringBuilder docComment = new StringBuilder()
                               .append("/**")
                               .append(docString)
                               .append("*/");
    Scanner scanner = scanners.newScanner(docComment, true);
    scanner.nextToken();
    Token token = scanner.token();
    return token.comment(CommentStyle.JAVADOC);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Documentifier.java

示例3: assertKind

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
void assertKind(String input, JavaTokenizer tokenizer, TokenKind kind, String expectedText) {
    Token token = tokenizer.readToken();

    if (token.kind != kind) {
        throw new AssertionError("Unexpected token kind: " + token.kind);
    }

    String actualText = input.substring(token.pos, token.endPos);

    if (!Objects.equals(actualText, expectedText)) {
        throw new AssertionError("Unexpected token text: " + actualText);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:JavaLexerTest.java

示例4: CT

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
private CT(TK tk, Token tok, String msg) {
    this.kind = tk;
    this.endPos = tok.endPos;
    this.message = msg;
    //throw new InternalError(msg); /* for debugging */
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CompletenessAnalyzer.java

示例5: advance

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
private Token advance() {
    Token prev = current;
    scanner.nextToken();
    current = scanner.token();
    return prev;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:CompletenessAnalyzer.java

示例6: nextToken

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
public void nextToken() {
    super.nextToken();
    Token tk = token();
    System.err.format("Saw token %s %n", tk.kind);
    test.numTokens++;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:7,代码来源:TestJavacTaskScanner.java

示例7: readToken

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
@Override public Token readToken() {
	Token token = super.readToken();
	prevEndPosition = ((PositionUnicodeReader)reader).pos();
	return token;
}
 
开发者ID:git03394538,项目名称:lombok-ianchiu,代码行数:6,代码来源:CommentCollectingTokenizer.java

示例8: ErrorProneToken

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
ErrorProneToken(Token token) {
  this.token = token;
}
 
开发者ID:google,项目名称:error-prone,代码行数:4,代码来源:ErrorProneToken.java

示例9: scan

import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
@Override
public Void scan(Tree tree, Context context) {
  if (tree == null) {
    return null;
  }
  JCCompilationUnit compilationUnit = context.get(JCCompilationUnit.class);
  for (T beforeTemplate : rule().beforeTemplates()) {
    matchLoop:
    for (M match : beforeTemplate.match((JCTree) tree, context)) {
      if (rule().rejectMatchesWithComments()) {
        String matchContents = match.getRange(compilationUnit);
        JavaTokenizer tokenizer =
            new JavaTokenizer(
                ScannerFactory.instance(context), CharBuffer.wrap(matchContents)) {};
        for (Token token = tokenizer.readToken();
            token.kind != TokenKind.EOF;
            token = tokenizer.readToken()) {
          if (token.comments != null && !token.comments.isEmpty()) {
            continue matchLoop;
          }
        }
      }
      Description.Builder builder =
          Description.builder(
              match.getLocation(),
              rule().qualifiedTemplateClass(),
              "",
              SeverityLevel.WARNING,
              "");

      if (rule().afterTemplates().isEmpty()) {
        builder.addFix(SuggestedFix.prefixWith(match.getLocation(), "/* match found */ "));
      } else {
        for (T afterTemplate : rule().afterTemplates()) {
          builder.addFix(afterTemplate.replace(match));
        }
      }
      listener().onDescribed(builder.build());
    }
  }
  return super.scan(tree, context);
}
 
开发者ID:google,项目名称:error-prone,代码行数:43,代码来源:RefasterScanner.java


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