use of net.sourceforge.pmd.lang.jsp.ast.Token in project pmd by pmd.
the class JSPTokenizer method tokenize.
public void tokenize(SourceCode sourceCode, Tokens tokenEntries) {
StringBuilder buffer = sourceCode.getCodeBuffer();
LanguageVersionHandler languageVersionHandler = LanguageRegistry.getLanguage(JspLanguageModule.NAME).getDefaultVersion().getLanguageVersionHandler();
Reader reader = null;
try {
reader = new StringReader(buffer.toString());
reader = IOUtil.skipBOM(reader);
TokenManager tokenMgr = languageVersionHandler.getParser(languageVersionHandler.getDefaultParserOptions()).getTokenManager(sourceCode.getFileName(), reader);
Token currentToken = (Token) tokenMgr.getNextToken();
while (currentToken.image.length() > 0) {
tokenEntries.add(new TokenEntry(String.valueOf(currentToken.kind), sourceCode.getFileName(), currentToken.beginLine));
currentToken = (Token) tokenMgr.getNextToken();
}
} finally {
IOUtils.closeQuietly(reader);
}
tokenEntries.add(TokenEntry.getEOF());
}
Aggregations