RE: [Pydev-code] Autocompletion in PyDev. A first working version
Brought to you by:
fabioz
From: Dana M. <dan...@ya...> - 2004-06-16 18:09:05
|
--- Fabio Zadrozny <fa...@in...> wrote: > Hi Dana... > > I'm also wondering... can't we use python itself to do that? > I miss the question - to do what (i.e., what does "that" refer to? > My main problem, the way it is, is that it doesn't work with most of > my code because of importing errors (I have a part of it done in c++, so, jython would never be able to get that)... IMPORTS ======= The Java Deve env mandates pathing be associated with the project via the "Properties..." menu item. Can't we do the same thing here? C++ ==== Is there a viable solution for the C++ at all? For example, does PyAlaMode autocomplete C++? I don't think so, but you can tell us. Can you send me a a sample that includes both C++ and Python so that I can test with PyAlaMode to see what it does fo autocompletion, or can you do that and report back to us. Am I correct in thinking that all we're using Jython for is to run a couple Python modules. These modules introspect a piece of code. I _believe_ that Jython's attractiveness here is that it handles the object translation from internal Java structures to internal Python structures, and nothing more than that. The Python modules in the jar do the heavy lifting. I grant that the interpreter here is Jython rather than CPython. Am I thinking incorrectly/incompletely, naively here? > getting the pythonpath might be a problem too (but not as difficult to solve). We can make PYTHONPATH a Project Property (from the "Properties ..." menu) > > I know it is just a first working version (and I don't wanna be a > pain in the ass), but based in jython, I think that I would never be able to use it... (unless of course, I don't use any c++ modules and that we are able to get most of the python modules working into jython - and I think that all that don't work in jython right now are in c++ - or depend on features available on newer versions of python, as jython currently supports version 2.1 - I think - ). > Is Jython's failure to be fully version compliant a problem? If we're just running a module to introspect code (which was actually a direct port from CPython) then does Jython's version skew actually present a problem? If it does, then perhaps one that can be worked separately; perhaps Kevin Altis might have a comment or two on this topic. > So, basically, what I want to say is that it is good the way it is for Jython development, but when it comes to develop in python, I think that jython just hasn't arrived there yet... (still version 2.1) and for some things like dependency on c++ modules, it probably never will (and this has never been its purpose). Correct statements, both. Is there are better way to invoke Python introspection directly from Eclipse? I suppose we might spawn a separate command line thread "python introspector.py" and pipe the result to standard out or a temp file and then read that stream? > Of course, we could let the user choose what to use, if we want to extend the plug-in to develop in jython, but I think that it must support python without dependency on jython. What's everyone else think? I suppose we could spawn Python as I have suggested; we can certainly assume that the use _will_ have Python on their system. therefore it's not entirely lame-brain to think about spawning Python to do this job, but I would rather fix the defects in the current implementation rather than experiment with a new solution, especially if PyAlaMode and other similar completion capabilities yield no different result. > > []s > > Fabio > > -----Original Message----- > From: pyd...@li... > [mailto:pyd...@li...] On Behalf Of Dana > Moore > Sent: segunda-feira, 14 de junho de 2004 14:50 > To: pyd...@li... > Subject: RE: [Pydev-code] Autocompletion in PyDev. A first working > version > > Fabio, > yeah, there are some rough edges. > I checked PyAlaMode with the same code. > See comments inline: > > --- Fabio Zadrozny <fa...@in...> wrote: > > I also couldn't use it. I got the error below when trying to > > autocomplete in > > the following code: > > > > Code: > > > > class Test(object): > > > > def __init__(self): > > self.rara() > > > > def rara(self): > > self.i = 2 > > # self. <-- Error on autocomplete here > PyAlaMode didn't know what to do with 'self.' here either and didn't > offer any autocompletion suggestions, so I think ours is at least at > that level > > > > > t = Test() > > #t. <-- Error on autocomplete here > > > > > Yeah, looks like what I will have to do with classes based on other > classes is to introspect the superclass(es). > I may have something fixed and in the hopper in a day or so. > I may have to "steal" better Python introspection code (from > PyAlaMode > maybe). Mine obviously does not recurse into antecedent classes. > Thanks Fabio! > > > Errors: > > Traceback (innermost last): > > File "<string>", line 1, in ? > > NameError: object > > > > Traceback (innermost last): > > File "<string>", line 1, in ? > > NameError: object > > > > Is there something I'm missing to do it work? > > > > []s > > > > Fabio > > > > -----Original Message----- > > From: pyd...@li... > > [mailto:pyd...@li...] On Behalf Of Aleks > > Totic > > Sent: segunda-feira, 14 de junho de 2004 03:47 > > To: pyd...@li... > > Subject: Re: [Pydev-code] Autocompletion in PyDev. A first working > > version > > > > Very cool. I fixed a few compile errors: jython lib classpath, > > and inclusion of test directory inside CompletionProcessor, and > > checked it in. > > > > Can you tell me what kind of autocompletion smarts can I expect? > > My first couple of tries failed, I'd like to see it in action. > > > > Aleks > > > > Dana Moore wrote: > > > Checked in a first working version of autocomplete. > > > it only autocompletes '.' and not (yet) '(', but it's getting > > there. > > > If you check out the org.pydev.jython and org.python.pydev.editor > > you > > > should be able to see it in motion. > > > It works this way: > > > 1. The org.pydev.jython plugin wraps jython.jar and a > jythonlib.jar > > > (right now this is about 1.1M; I just picked up the > > #JYTHON_HOME/LIB on > > > mymachine and jar'ed it. We can probably do a better and more > > compact > > > one by leaving out some things which just happen to have got > swept > > up > > > from my system. > > > 2. At any rate, within that jar are several Python modules which > do > > > code introspection (we probablt need to drop them into a source > > > directory and have a build for the lib itself at some point in > > time, > > > but first things first. > > > 3. The PythonCompletionProcessor.java grabs the module being > edited > > and > > > comiles the code ahead of the activating partial expression in > the > > > buffer: > > > LL 118: interp.exec(theCode); > > > It then pulls up the actiuvating expression > > > LL 119: String xCommand = "theList = > > > jintrospect.getAutoCompleteList(command='"+theActivationToken+"', > > > locals=locals())"; > > > > > > and then uses Jython to introspect the code: > > > LL 121 interp.exec(xCommand); > > > creates a PyList from the suggestions: > > > LL 122 PyList theList = (PyList) interp.get("theList"); > > > and returns that. > > > LL123 return theList; > > > Which in turn gets turned into autocompletion proposals. > > > What's kind of significant about this is that (I believe) it > marks > > the > > > first time that the Java based Eclipse editor has used a facility > > of > > > the (non Java) language being edited as leverage. > > > > > > Going forward, I should like to complete the other things that > > ought to > > > trigger a code introspection (other than the '.' method > invocation > > > signifier). Although Parthaum, if you want to give this a go, it > > should > > > be easy do; the code is basically there in > > > PythonCompletionProcessor.java. Right now, "(" is listed as an > > > autocompleter, but it does the wrong thing. > > > > > > I suppose that doing as well as PyAlaMode is probably good enough > > for > > > this spiral, but while we're going down this path, it would be > nice > > to > > > have a decent set of CTRL-SPACE expanders/completers as well. For > > > example, if you type in 'sysout'CTRL-SPACE in the java > development > > > envt, it substitutes "System.out.println()". and even more > > > sophistication for the phrase "for" which calls up the various > > > potential expansions: > > > for - iterate over array > > > for - iterate over array with temporary variable > > > for - iterate over collection > > > > > > So what other nice expansions can we think of which are Python > > > specific? Maybe an exoander for the venerable expression: > === message truncated === ===== _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ _/ Dana Moore _/ _/ BBN Technologies LLC _/ _/ M: 240.350.4196 _/ _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/ __________________________________ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail |