Am 19.05.2009 22:33, schrieb Enrico Tröger:
On Mon, 18 May 2009 19:54:24 +0200, Filip wrote:
This was already requested a couple of times. I'm not sure whether we want this. It would probably require quite some effort to parse import statements from an opened source file, find the corresponding Python files, parse them, merge the parsed information into tagmanager(the code which provides the main part of symbol completion data). Additionally, added symbols should maybe removed again when the source file is closed which also might not be that trivial.
I am not suggesting anything as complicated, as you say. I understand, that in situation like thos:
import sth
you want to find module sth.py and detect all symbols inside. I think enough is to add sth to namespace. It would became useful in following situation:
from sth import LongNameClass, AnotherLongNameClass
and simply add those two. You need to only parse imports and detect names, that were added to the local namespace.
Ha, I guess I was a bit off the road with my ideas...:).
Your suggestion was actually quite easy to implement, I did it in SVN. Geany now parses import statements for Python files and provide it as symbol compeltion. Currently it also lists them in the symbol list though I'm not yet completely sure whether we really want this. Awaiting some feedback of Python users :).
For testing the parser, I mainly used the following code snippet: import os, sys, errno, re, glob, gc, datetime, shutil try: import cPickle except: import pickle as cPickle import Runner, TaskGen, Node, Scripting, Utils, Environment, Task, Logs, Options from Logs import debug, error, info from Constants import *
Are there other variants of "import" statements possible? You know, my Python knowledge is very limited :).
Regards, Enrico
Can we have this for C'ish #includes as well, if not already done that is. The tricky part is the various include dirs which are totally custom in many projects :(
Best regards.