Dan, is there a reason to sort out the "isRoutine" members instead of just showing them all?
I find it practical to also show classes of imported modules as I use modules as some kind of namespaces.
Something different now: because Python is dynamic typed a lot of this autocomplete stuff can't work but I'm thinking of providing a "best effort": something along the lines of:
t = Time()
t. # would then trigger the autocomplete on Time() objects
Does anyone think of this as useful or is it something noone really finds necessary?
I fully agree, this would be very useful.
A few questions:
1. Where would autocomplete not work?
2. Why is it necessary to:
t = Time()?
3. How do you propose accomplishing this?
Namely, if I set wxdialog = wx.libs.dialog,
how do I check for wxdialog? Do I have to parse the entire file for assignment statements?
4. Are there any other editors with autocomplete for python? If so, how do they handle situations like this?
If this is something you would like to do,
try getting it to work the way you would like.
Then you can either release it as your own plugin
(AutocompleteUltra!!!), or send it to me, and I may add it to the autocomplete plugin.
Autocomplete right now only works for functions that are on module level. Classes and data constants don't get listed... no big deal, I just like it otherwise :) AFAIK there is no way to colorize the listings in the autocomplete popup to show the difference.
"t= Time()" is just an example. In my own code where all are classes to a module (from import of dll) I do get to write a lot of
"s = bass.Source()", I know I could import * from bass, but somehow I got used to stuff like this. The nice thing is that autocomplete can show all classes of the bass module. After I've written that "s" is unknown to autocomplete for the obvious reasons, so writing "s." doesn't triggering anything.
How to accomplish this... I'm afraid there is no other way than parsing the whole file. I'm planning to write this myself, so it's not a feature request or so :) Well considering there is already an Autocomplete I will makes some mods to yours and send it to you and see if you like it ;-)
One thing I'm worrying about is the fact that the whole file needs some intensive parsing. This kind of static analysis is useful for the CallTips too, so a kind of shared interface could be nice and then scanning like each second or after some significant detected change would even be better... does anyone have some ideas about this? Anyhow, I'll try it first with a straightforward approach.
The classes thing is a good point.
We can leave it, add in classes and sort everything alphabetically, or add in classes and sort by type (routine, class, etc).
This will need some intensive parsing. I'd suggest using regular expressions, as they are MUCH faster than simply parsing with python alone.
If you can get something working, send it over.
I will either add it in as is, or if it is too intensive (and slows things down too much), I will make it an option.
We'll see what you come up with, and either add it directly to drpython, or add it into tracebacks too.
PS Some notes on parsing:
Besides speed, identifying assignments that you want to look at could be rather tricky.
Here is some psuedo code:
For each assignment:
Find LeftSide of the assignment, and the RightSide.
If the LeftSide matches the current autocomplete target, and if the RightSide is something you can import, then import RightSide.
So I'll give it a shot but will probably start with some "not so intelligent" analysis. In PyAlaMode (included in wxWindows 2.5) you can do the stuff I propose, and they have a "Update namespace" feature that reparses the whole thing.
I don't know how far they parse the code. There are also the "parser" and "compiler" packages that are shipped with Python. They look very powerful but rather complex too for the task at hand.
I would advise trying on several methods for speed.
Sounds good, I look forward to seeing this.
Log in to post a comment.