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

share the AST and do less parsing #48

Closed glyph closed 11 years ago

glyph commented 11 years ago

On every edit (sometimes after a timeout), https://github.com/SublimeLinter/SublimeLinter parses Python to run pyflakes and pep8. Then, on every save, SublimeRope parses it again to run pyflakes again, and then parses it again for rope to do its thing.

It would be great if these passes could all share one AST (and ideally, one run of pyflakes!) to avoid duplicate work and make saving faster.

DamnWidget commented 11 years ago

Hi @glyph

I was working already in parse the file once with rope library and add our stuff upon it to don't use pyflakes at all. I don't know what @JulianEberius thinks about it, he already wrote some lintering feature

JulianEberius commented 11 years ago

Hi,

SublimeRope now shares the parse results between its own calls (one PyFlakes, one Rope => only one parse call). It do not think it is possible to share calls with SublimeLinter (ST2's plugin isolation would have to be very weak!).

I would recommend to choose one of the plugins, or at least disable the PyFlakes linting that SublimeRope does when using SublimeLinter (or the other way around). To do so for SublimeRope, set "pyflakes_linting" to false.

Regards, Julian

glyph commented 11 years ago

For what it's worth, it's totally possible to share calls with SublimeLinter; Sublime Text 2 has no isolation between plugins. They're just all hanging out in the same global Python interpreter space and can freely share things by setting global variables. That's terrible for security of course, but it's excellent for integration.

DamnWidget commented 11 years ago

Yup, I'm used to call SublimeRope space methods from my SublimePySide plug in but the problem with SublimeLinter I think is just the project is maintained by their own development team with no relation at all with us, they don't have any need to share their AST in the global namespace.

I think this type of integration will be very hard or impossible to apply.

JulianEberius commented 11 years ago

Oh ok. Python has a sub-interpreter C-API that allows multiple Python interpreters in one process. But if that is not used then of course we could monkey-patch SublimeLinter. Don't think that is a good way forward though. Is sharing parse results even that much of a deal? Has anyone measured the overhead? For know I would simply recommend people to disable SublimeLinter for Python buffers or use only one of the two plugins.

glyph commented 11 years ago

I wasn't suggesting monkey-patching; I was suggesting that you send a friendly note over to the developers of SublimeLinter and have an explicit public API via which the ASTs might be shared. Obviously it's impossible to do in a way which is robust in the face of updates if you don't have any explicit collaboration with the other code :).