JDK-6278108 : Provide access to lexer in Tree API
  • Type: Enhancement
  • Component: tools
  • Sub-Component: javac
  • Affected Version: 5.0
  • Priority: P4
  • Status: Open
  • Resolution: Unresolved
  • OS: generic
  • CPU: generic
  • Submitted: 2005-05-31
  • Updated: 2016-05-19
Related Reports
Relates :  
Relates :  
Description
In order to resolve issues as described in 4813736, the
compiler should provide access to the lexer.

###@###.### 2005-05-31 11:55:17 GMT

Comments
We are not planning to fix this in 8.
09-05-2013

EVALUATION Due to lack of requirements, this was not part of the major work on the Tree API. Now it seems unlikely that we will be able to do this in Mustang.
02-12-2005

SUGGESTED FIX In the tree utility classes we provide this method: Iterable<LexerToken> getTokensForNode(ComplilationUnit file, Tree node); The LexerToken would look something like this: interface LexerToken { int getBeginPosition(); int getEndPosition(); TokenKind getKind(); } enum TokenKind { ... } ###@###.### writes: Attached is the TokenList class I use to re-lex and provide a position->token map. Its Token class is similar to your LexerToken, but it also provides name, value, and toString support needed for translation to source. It's not an interface, but then not all utility classes need to be (even for a JSR). It's been fast enough to not require tuning so far. If you find it useful, toss it into com.sun.tools.javac.util with my blessing. ###@###.### 2005-05-31 11:58:59 GMT
31-05-2005

EVALUATION We will consider providing access to the Lexer as part of 4813736 (Tree API). ###@###.### 2005-05-31 11:58:59 GMT
31-05-2005