public static void wipeCharPositionInfoAndWhitespaceTokens(CodeBuffTokenStream tokens) {
tokens.fill();
CommonToken dummy = new CommonToken(Token.INVALID_TYPE, "");
dummy.setChannel(Token.HIDDEN_CHANNEL);
Token firstRealToken = tokens.getNextRealToken(-1);
for (int i = 0; i<tokens.size(); i++) {
if ( i==firstRealToken.getTokenIndex() ) continue; // don't wack first token
CommonToken t = (CommonToken)tokens.get(i);
if ( t.getText().matches("\\s+") ) {
tokens.getTokens().set(i, dummy); // wack whitespace token so we can't use it during prediction
}
else {
t.setLine(0);
t.setCharPositionInLine(-1);
}
}
}
Formatter.java 文件源码
java
阅读 40
收藏 0
点赞 0
评论 0
项目:codebuff
作者:
评论列表
文章目录