[Pydev-code] Autocompletion observations.
Brought to you by:
fabioz
From: Fabio Z. <fa...@es...> - 2004-08-11 15:17:15
|
Hi Dana, As I said previously, I have some issues on the current state of the code completion... First of all, I want to say that it works great for the imports (I think you already know why, but I will explain it here because I think that the rest of the list might want to know how things work... And maybe even go and correct it)... The way code completion is done is through an python Interactive Interpreter. That means that it is basically a shell, and that we get output from it... The good thing is that imports in the top of the code always have instant evaluation on a shell, however, having a class requires some really rigorous indentation. What I mean is: I I have a class that's written: class A: def a(self): pass a = A() It won't be able to evaluate correctly in the interactive interpreter, because we need extra lines after the class, so, in the declaration below it will be correct (even that it appears that it is the same, in the interactive interpreter, it is not because of the line above a = A()). class A: def a(self): pass a = A() So, if we follow this approach, we have to give it the file really correct (for the interpreter), so that it can get code completions (it also strange that we're not able to get the values when defining self in a class, but I didn't really get into it... If you have any ideas, you could post it to the list...) E.g. class C(object): def __init__(self): self.a = 1 self.b = 2 def foo(self): self. <-- does not get me any code completion Another thing is that writing a temporary file so that the interpreter can get it is not a good approach. The code at tipper.py has in the main: if __name__ == '__main__': import sys,os f = open (sys.argv[1]) theDoc = f.read() GenerateTip(theDoc) So, as we have the CPython process in Java anyway, we can do that ourselves, without having to write to a temporary file so that it can interpret the code we have. You could call the GenerateTip yourself with a string with the code. It could be much faster than writing to a temp file. Well, I think that's it, I know these may be tricky issues, and the imports code completion is already a major contribution (and as I said before, it works very well...) Ah, I also made some changes in the code completion and refactored the classes, so that the responsibilities were separated, and the code completions could be gotten not only on '.', but also with a qualifier... - the version in cvs has a bug because it doesn't recalculate qlen - I already changed that in my machine, but I still couldn't commit that because for some reson, I cannot synchronize with sourcefoge... (I think it is down...) Well, to complete.... nice work!! []s Fabio Zadrozny ------------------------------------------------------ Software Developer ESSS - Engineering Simulation and Scientific Software www.esss.com.br |