PyDev

Code Completion


Notes for release 0.7.1

(Code completion disabled by default - see notes on the preferences page):
Code completion has some changes in version 0.7.1, most notable, the parameters of a method are also gotten when completing and the autocompletion has been completely disabled (mainly because of complaints on the editor hanging and because most of the time you don't have valid completions - it only works for the tokens gotten from the global scope and on self - so, forget about trying to complete on parameters...).

But even with those limitations, this feature is already usable, but still has to be used with care, as it executes the current editor code to get it's completions. That means that one should be very careful on what is put in the global context when using code completion.

So, that means that if you put sys.exec("rm -r *") in the  top level of any module, it would probably would really delete all you have... Not good hummm... But if you did it, you would never be able  to import that module from python from anywhere, because it would do the same thing...(so, that makes me feel not so guilty :-) ).


Now, how to use it:
(Here are some snapshots on the current uses)

Code completion works on imports, on the current class and on the global context - it uses the current pythonpath in order to do that, so, 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
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

Import compiler

Ctrl+Space would bring you '__builtins__' and 'compiler' suggestions


For class code completion:

import compiler
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

Note on code completion:

Currently code completion does not work on methods after '(' and on any variable that is passed in as a parameter. Right now it works only on 'self', on the imports and on global variables