Phillip Lord writes:
 > >>>>> "Paul" == Paul Kinnucan <[EMAIL PROTECTED]> writes:
 > 
 >   Paul> Phillip Lord writes:
 >   >>
 >   >> Here is the latest version of jde-import-all, which works with
 >   >> jde-2.3.3.
 >   >>
 > 
 >   Paul> Hi Philip,
 > 
 >   Paul> How about leveraging semantic to find a candidate list of
 >   Paul> classes to import? The following function uses the semantic
 >   Paul> lexer to get a list of all Java tokens in the current
 >   Paul> buffer. It then extracts all identifiers in the list that
 >   Paul> start with an upper case character and have at least one lower
 >   Paul> case character, and that do not appear in an import statement
 >   Paul> or inner or outer class declaration.
 > 
 > Paul
 > 
 > 
 > I'd thought about using semantic. I thought that the parser was not
 > doing a full parse though...does it actually work its way down into
 > method definitions or just forward-sexp over them? 


 > 
 > If it does work in identifying all the types then semantic is clearly
 > the way to go. 
 > 
 >   Paul> A more rigorous approach might use David Ponce's wisent parser
 >   Paul> generator to generate a parser that builds a list of class
 >   Paul> names as a side effect of parsing the buffer.
 > 
 > Yes I would agree. I'm unlikely to have time to do this though. I was
 > looking for a quick solution which basically worked!
 > 

Hi Philip,

The function I sent you uses the semantic lexer. The lexer returns a
list of all the tokens in a buffer (skipping over comments and
strings). This includes all identifiers used in method bodies. The
problem is to determine which of these identifiers is a reference to a
class that needs to be imported. The most rigorous way to do this
would be to use a parser to determine the context of each identifier
and deduce from that whether it is a user-defined type (UDT)
identifier. The function I sent you uses a heuristic approach, i.e.,
it assumes that any identifier that starts with an uppercase letter,
is not in an import statement, is not the name of a class declared in
the buffer, and contains at least one noninitial lowercase letter is a
UDT identifier. I sent you the function so that you could try it out
and see if it works as well as the regular expression-based function
you used.

Note that the code I sent you includes a test command that allows
you to try out the UDT extractor interactively on a buffer.

I plan to use David Ponce's wisent parser generator to create 
a parser for extracting UDT identifiers from the current buffer.
In the meantime, I thought we could use the function that I posted
as a more compact, cleaner, and clearer alternative to
the regular-expression-based parser that jde-import-all currently
uses to extract UDT identifiers from the current buffer..

Paul


Reply via email to