JulianEberius / SublimeRope

ST2 only, use SublimePythonIDE with ST3: Adds Python completions and some IDE-like functions to Sublime Text 2, through the use of the Rope library
GNU General Public License v2.0
250 stars 26 forks source link

Reorganization and refactor of the plugin. Cache addition to ast.parse in rope library #49

Closed DamnWidget closed 11 years ago

DamnWidget commented 11 years ago

I refactored a big part of the plugin code, joining all the EventListeners into the same handler and fixing some code style inconsistencies.

Investigating issue #48 reported by @glyph I noticed about how many times rope was compiling the code to generate the AST, when the autocompletion when typing is active it was several times per seccond .

Share the AST between calls is hard because the autocompletion stuff does use of the rope.base.ast.parse method to compile/parse part of the buffer in order to do his stuff. I finally added a cache decorator to the parse function in rope.base.ast module to share AST between save states and between autocompletions in order to save some time of compilation/parsing

The cache only caches 1MB of data, when this limit is reached then it uses a FIFO approach in order to save memory.