Re: [Pydev-code] Autocompletion observations.
Brought to you by:
fabioz
From: Dana M. <dan...@ya...> - 2004-08-11 18:30:29
|
--- Fabio Zadrozny <fa...@es...> wrote: > 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 > Yes, you're absolutely right. I am sure that we gets lots of comments and/or bug reports saying "code completion does not work on my code." The Pyalamode interactive interpreter shell, on which I based code completion will actually report back a syntax error for code shown in your first example, and thus forces a person to write code that observes all the indent-dedent rules strictly The reason behind the strict coding rule is that we read in the entire buffer in CPython, up to the activation character and we eval each line separately. We actually throw a syntax exception in the external CPython interpreter on that particular code, but I swallow the output to sys.stdout that doesn't look like an autocompletion tip. > > 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. > So, I will investigate doing that too. Your addition of a cache is very nice though and means we only pay a first time penalty right now. > 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!! > Right, sourceforge was unavailable for a while. I had same problem > []s > > Fabio Zadrozny > ------------------------------------------------------ > Software Developer > ESSS - Engineering Simulation and Scientific Software www.esss.com.br > > > > ------------------------------------------------------- > SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank > Media > 100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33 > Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift. > http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285 > _______________________________________________ > Pydev-code mailing list > Pyd...@li... > https://lists.sourceforge.net/lists/listinfo/pydev-code > ===== _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/ Dana Moore _/ _/ BBN Technologies LLC _/ _/ M: 240.350.4196 _/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! http://promotions.yahoo.com/new_mail |