Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development
Python Code Completion
dmoore:
I've started working on a Code Completion plugin for Python. Sources are here:
--- Code: ---svn checkout svn://svn.berlios.de/cbilplugin/trunk/PythonCodeCompletion
--- End code ---
Build Instructions for Linux and Windows
The project files (respectively PythonCodeCompletion-unix.cbp and PythonCodeCompletion.cbp) will create a packaged cbPlugin, that you can install from Plugins->Manage Plugins
1. Get the sources, using the command above.
2. Make sure you have codeblocks-dev package installed and jedi (and python, of course)
3. In Code::Blocks, open the project file and build target All
4. You should see PythonCodeCompletion.cbplugin in the root of the project folder, install it from Plugins -> Manage Plugins
Features
The current version supports the features of jedi for code assist, providing completion popups and calltips.
Todo
* Better integration with C::B (depends on Alpha's progress with CodeCompletion overhaul)
* Symbol browser
* Configuration options
Screenshots
How it's done
This plugin uses jedi, a python library, as the engine for the code completion running in a separate process and communicates with it via XMLRPC. Python provides a lot of nice introspection features making it easy to parse python source and extract symbols (even from the builtin libs) that jedi takes advantage of. Jedi improves on the limitations of rope, the library that was being used in an earlier version of this plugin.
dmoore:
New:
1. Windows project file (which means you can now build on linux, the linux project file is now named PythonCodeCompletion-unix.cbp)
2. Call tips with call sig and docstrings for standard library functions
3. Now can do the XMLRPC communication with the python completion process over pipe as an alternative to a socket. (Pipe is currently hardcoded as default.)
4. Parsing files outside of the standard lib
5. Understanding symbol from context (i.e. should know module sys only after it is imported, or function f when it is defined)
Coming:
4. Parsing files outside of the standard lib
5. Understanding symbol from context (i.e. should know module sys only after it is imported, or function f when it is defined)
6. Symbol/module browsing
7. Use python specific icons for graphic representation of symbol types (module, class, function, attribute etc.)
8. Configuration options
9. User-defined rules for determining return types that can't be determined using introspection (e.g. return type of numpy.array -> ndarray)
dmoore:
Update: Now using Rope for code completion. I've updated the original post with new build instructions. WARNING: Rope litters your project folders with hidden .ropeproject folders.
ollydbg:
Pretty nice!
I see we have C/C++ code completion plugin(in trunk), Fortran code completion plugin, python code completion plugin. Maybe, we need to a common interface for all those plugins. ;)
dmoore:
--- Quote from: ollydbg on October 13, 2012, 01:51:35 pm ---I see we have C/C++ code completion plugin(in trunk), Fortran code completion plugin, python code completion plugin. Maybe, we need to a common interface for all those plugins. ;)
--- End quote ---
Indeed. :)
For calltips and the code completion lists, not too much needs to change, I think. Code completion for python doesn't appear to get in the way of the C/C++ one and, mostly, vice versa. One thing that does get in the way occasionally are the keyword completions. Does anyone know how I can disable those?
Related to sharing GUI, it would be nice if:
* the shortcut keys (e.g. ctrl + space, ctrl+shift+space) worked for all CC plugins.
* For symbol browsing (which I haven't even begun to implement for python yet), share the symbol tab in the manager pane across plugins, though not sure how feasible that is. How would one separate the symbols for different languages?
* the goto declaration/implementation stuff had a shared GUI (or at least didn't show inappropriately).
Navigation
[0] Message Index
[#] Next page
Go to full version