|
From: <tor...@t-...> - 2002-01-25 14:02:19
|
I'm working on a Python-aware editor in Java (plugin for Eclipse).
Can anybody give me a hint how to create an outline of a Python source
via
Jython in an efficient manner? Efficient means: the outline is
recalculated
every time the source code within the editor is changed.
Currently I'm only aware of the following "brute-force" approach:
1. creation of an abstract syntax tree via the parser facade
org.python.core.parser.parse(..., "exec", ...)
2. walking through the whole AST by visiting EVERY node via a
specialization of
org.python.parser.Vistor
This specialized visitor simply visits ALL childrens of a node. But
only
some special Python elements (class defs, func defs and imports) are
handled.
Is there an "optimized" way through the AST where only these special
nodes
(class defs, func defs and imports) are visited?
Or better, is it possible to build not the whole parse tree but a
subset only
including these nodes I'm interested in?
Thanx.
Torsten
|