本文整理汇总了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);
}
示例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);
}
示例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);
}
}
示例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 */
}
示例5: advance
import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
private Token advance() {
Token prev = current;
scanner.nextToken();
current = scanner.token();
return prev;
}
示例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++;
}
示例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;
}
示例8: ErrorProneToken
import com.sun.tools.javac.parser.Tokens.Token; //导入依赖的package包/类
ErrorProneToken(Token token) {
this.token = token;
}
示例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);
}