RE: [Pydev-code] Next release
Brought to you by:
fabioz
From: Fabio Z. <fa...@in...> - 2004-09-22 12:09:38
|
Hi Aleks,=20 Ok then, I'm going to do a clean up on code completion too... I'm giving some examples on how should refactor / code completion work below. Examples -------------------------------------------------------------------- Refactor Examples (activates on right mouse click - there is usually a keyboard key that emulates that): On: class C: def a(self): a =3D 2 b =3D 3 c =3D a+b #this should be refactored. return c c =3D C() Marking 'a+b' and making an extract method refactor for a method called 'plusMet' should give you: class C: def a(self): a =3D 2 b =3D 3 c =3D self.plusMet(a, b) #this should be refactored. return c def plusMet(self, a, b): return a+b c =3D C() And with the same class, marking C (it must be the class definition) = should give you: class G: def a(self): a =3D 2 b =3D 3 c =3D a+b #this should be refactored. return c c =3D G() Until now, extract method has given me no problems, but rename does not always work... It has to scan all the PYTHONPATH and does not always = find all the references (and sometimes may have problems parsing some files too...) Methods or variables can be renamed too. And as a helper, a Refactor Results View has been contributed. After any refactoring it should show which files were changed, however, it only = works correctly if it is opened (if you do a refactor and open it later it = won't show the results - that's a bug). ----------------------------------------------------------------- Code completion examples: Imports completion goes for the sys.path, that is, if you go in python = and: import sys print sys.path - those are the locations searched to get the imports = tips. Directories if they contain an __init__.py=20 Files: .py, .py, .pyo, .pyd, .dll So, if you go: (| Marks Ctrl+Space) import | a list of the imports that can be gotten = should appear. import comp| completes imports that start with comp import compiler.| completes with compiler sub-modules and = classes import compiler.ast.| completes with compiler.ast sub-modules and classes from compiler import | completes with compiler sub-modules and = classes from compiler import ast.| completes with compiler.ast sub-modules and classes Now for other completions: If you have a file from compiler import * And just Ctrl+Space, it should appear all the globals, in this case all compiler submodules and classes. If you had just=20 Import compiler=20 Ctrl+Space would bring you '__builtins__' and 'compiler' suggestions For class code completion: Suppose you have: import compiler=20 class C(compiler.visitor.ASTVisitor): def __init__(self): self.| would bring you all the code available from this class. compiler.| would bring all that is contained within the compiler module There is a catch in this completion: as I rely on our ModelUtils to know = in which class I am, it only works correctly once it is parsed correctly = (at least once) - if this doesn't happen, you're getting an error such as = 'name self. Not defined', because as it can't determine it as a class in ModelUtils, it tries to complete as if it was a simple token - this = could be worked with some kind of fast parser, just to determine in which class = we are... Well, I think that's most of it... []s Fabio Zadrozny ------------------------------------------------------ Software Developer ESSS - Engineering Simulation and Scientific Software www.esss.com.br -----Original Message----- From: pyd...@li... [mailto:pyd...@li...] On Behalf Of Aleks Totic Sent: ter=E7a-feira, 21 de setembro de 2004 23:38 To: pyd...@li... Subject: Re: [Pydev-code] Next release Hi Fabio, this is great news, way beyond what I was thinking about. I am=20 sure the pydev users will love it. About feature freeze, that was=20 just a suggestion, it seems as if everything you've done is ready=20 to ship. You've My current plan is to compile what we have, clean up the debugger=20 bugs, and ship it, late tomorrow as 0.6. About documentation,=20 I'll do what I can. Can you give me some good examples of how=20 your features work? Maybe a python file with comments like "you=20 can refactor this, you can do code completion on these". For imports code completion, what are you using as your path? Aleks Fabio Zadrozny wrote: > Hi All, >=20 > I've been working full time the last week in pydev (thanks to some = support > from my company), so, I have been able to introduce the following = features > in the plugin (yes Aleks, I saw you said freeze the features, but I = was > REALLY, REALLY in need for that): >=20 > Python shell integration > - Using a python shell and communicating through sockets (for > refactoring, search and code completion). >=20 > Refactoring: > Completed: > - Bicycle repair man (BRM) integration (support for rename and > extract method).=20 > - Added a view to show which files were affected by the last > refactoring > Missing: > - Undo of the refactoring (it is supported by BRM but not > integrated). > - There are other refactorings that can be integrated.=20 > - Only appearing on right click menu... Some keybindings could be > used also. >=20 > Search: > Using Bicycle repair man go to definition search on key F3. It is > used because our search was only on the current buffer (and that was really > annoying).=20 >=20 > Code completion: > Basically, this was a rewrite from the python side of the code > completion. I think there are better ways to do it, but time is never > enough, so, code completion now works on: > - import ... > - from ...=20 > - from a import ... > - self. > - any other token that we are able to get on the module > level, that is, variables initialized inside methods or other scopes = are not > gotten (they weren't earlier either, so, that's not a retrocess). >=20 > So, missing for this feature is: > - Work on inner scopes: this would require some good work > with the python ast... > - It still doesn't work on method parameters, but it could > be added without too much effort (I will do it as soon as I can, but I still > don't know when I will be able to do it - so, if anyone = volunteers...). >=20 > Well, I think that's it... The bad part is that I didn't put it in = pydev > help (if someone volunteers...) >=20 > Anyway, I think that's enough for a 0.6 release, and if those features prove > to be stable, it should be enough for a stable 1.0 release... >=20 ------------------------------------------------------- This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170 Project Admins to receive an Apple iPod Mini FREE for your judgement on who ports your project to Linux PPC the best. Sponsored by IBM. Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php _______________________________________________ Pydev-code mailing list Pyd...@li... https://lists.sourceforge.net/lists/listinfo/pydev-code |