I've just committed the first implementation of Python model. Big
I've found that programming with AST tree using the visitor
pattern was unwieldy. As a fix I created Python model. Python
model has information about Classes, Functions, Locals, Function
calls, etc, wrapped inside a more usable API.
The model is a tree of nodes. Each node is a Python construct, a
class, import statement, etc. It also tries to infer where locals
are defined and stores this info inside Scope.
Check out the package notes inside org.python.pydev.editor.model
for further documentation.
I've reworked the Outline view and Navigation actions so that
they use the new model. The code is a lot simpler.
The model should be used for any feature that needs Python
structure. Instead of traversing the AST tree, extend the model
to support the features you need.
Dana, I think that with some work you can use the model for
CodeAssist. The list of locals defined is inside Scope. I LOVE
the little easter egg :-) How did you put up that popup? Now that
the model is there, I'd like to experiment. For example, I'd love
to see the usage of a local variable (all lines where it is
worked on) inside the popup when I ctrl-hover.
One big hole in the current model is that imports are not
processed, so all their definitions are missing. I'd love if
someone implemented the include processing. It a picky job, there
are many subtleties with the include paths.
The hyperlinks are now visible, and useful for debugging the
model. Any clickable items will be highlighted. I still need to
implement the goto action when you click on the link.
Have a great weekend,
Get latest updates about Open Source Projects, Conferences and News.