本文整理汇总了Java中org.netbeans.api.lexer.Language.tokenId方法的典型用法代码示例。如果您正苦于以下问题:Java Language.tokenId方法的具体用法?Java Language.tokenId怎么用?Java Language.tokenId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.netbeans.api.lexer.Language
的用法示例。
在下文中一共展示了Language.tokenId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: WrapTokenIdCache
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private WrapTokenIdCache(Language<T> language) {
this.language = language;
int arrayLen = language.maxOrdinal() + 1;
plainWids = new WrapTokenId[arrayLen];
noDefaultEmbeddingWids = new WrapTokenId[arrayLen];
for (int i = 0; i < arrayLen; i++) {
T id = language.tokenId(i);
plainWids[i] = new WrapTokenId<T>(id);
noDefaultEmbeddingWids[i] = new WrapTokenId<T>(id, LanguageIds.NULL_LANGUAGE_ONLY);
}
lastWids = new WrapTokenId[arrayLen][];
}
示例2: nextToken
import org.netbeans.api.lexer.Language; //导入方法依赖的package包/类
public AbstractToken<T> nextToken() {
if (lexer == null) {
return null;
}
while (true) {
AbstractToken<T> token = (AbstractToken<T>)lexer.nextToken();
if (token == null) {
checkLexerInputFinished();
return null;
}
// if (LOG.isLoggable(Level.FINE)) {
// LOG.fine("NEXT-TOKEN: off=" + tokenStartOffset + ", len=" + tokenLength // NOI18N
// + ", " + token.dumpInfo() + '\n');
// }
// Check if token id of the new token belongs to the language
Language<T> language = languageOperation.language();
// Check that the id belongs to the language
if (!isSkipToken(token) && !language.tokenIds().contains(token.id())) {
String msgPrefix = "Invalid TokenId=" + token.id()
+ " returned from lexer="
+ lexer + " for language=" + language + ":\n";
if (token.id().ordinal() > language.maxOrdinal()) {
throw new IllegalStateException(msgPrefix +
"Language.maxOrdinal()=" + language.maxOrdinal() + " < " + token.id().ordinal());
} else { // Ordinal ok but different id with that ordinal contained in language
throw new IllegalStateException(msgPrefix +
"Language contains no or different tokenId with ordinal="
+ token.id().ordinal() + ": " + language.tokenId(token.id().ordinal()));
}
}
// Skip token's chars
tokenStartOffset += tokenLength;
if (!isSkipToken(token))
return token;
} // Continue to fetch non-skip token
}