At 07:39 AM 6/21/99 -0700, Brian Anderson wrote:
>I'd love to see this revision. Also the speedbar should show handle inner
>(tell me the full class name) and anonymous (show me the method the
>anonymous classs is in)classes better. Finally my pet peeve (since you
>asked), the speedbar doesn't handle all valid method names such as those
>with underscores.
>
The speedbar relies on the buffer mode to parse the contents of a buffer and
return something to display. In the JDE's case, the JDE returns an imenu
structure with the classes, methods, and variables. The imenu structure
created by java-mode uses regular expressions to parse a Java buffer. I
found that java-mode's REs, while comprehensive, were very slow because
they used recursive expressions. When I say slow, I mean really slow as in
hours to parse buffers containing some types of common constructs, such as
if-then statements. I rewrote the REs to be faster; the tradeoff is that
the JDE RE's are somewhat less accurate when it comes to parsing the
buffer. Using RE's to parse a syntax as complex as Java's is tricky
business and generally entails a lot of painstaking cut-and-try work.
Everytime you think you've accounted for every syntactic quirk of the
language, you find another counter example. If anyone wants to take a shot
at improving the JDE's stab at RE's, please feel free. We'd all be
grateful. Meanwhile, I have been considering using the JDE's new Java
parser to construct the speedbar display structure. The advantage is that
the parser would enable a fast and fully accurate parsing of the buffer
into classes, including inner and anonymous, methods and fields. This
approach poses some problems. A drawback is that it would require starting
up the BeanShell the first time you open a Java buffer. Also, what to do if
a source file has parse errors from which the parser cannot recover? I'd be
greatful to get other's views on this approach.
Regards,
Paul