tern.java
tern.java copied to clipboard
Improve performance with JS Editor and tern completion
When completion is done, the full js content is sent to the tern server. It can be slow if js file is big. To fix this problem, "partial" tern doc should be managed (only sent the update of the js editor).
I assume this should say "When editor is saved" instead of "When completion is done"?
I assume this should say "When editor is saved" instead of "When completion is done"?
No. Today when completion, hyperlink, hover is done, the full JS content coming from the editor is posted to the tern server ("full" type is used for that).
With tern it's possible to post a "partial" JS content to execute completion, hyperlink, hover. This feature is interesting when the editor has a big JS. See http://ternjs.net/doc/manual.html and search "part"
The completion with big file file like ember.js doesn't work because timeout is every time thrown because it takes too time to analyze the file.
If you take the demo http://ternjs.net/doc/demo/#simple and you copy/paste ember.js, teh first time completion is slow and teh second time it is fast, because it uses "part" file.
To add this feature inside tern.java, we need to know the start and end offset where update was done. To do that we must add a listener for IDocument to track sart + end offset.**My idea is to use TernDocumentFile and have ONE instance per editor of TernDocumentFile to add adocument listener to track start/end offset of the update (today we create an instance each time for completion, hyperlink)
@piotrtomiak are you OK to have ONE instance of TernDocumentFile per editor?
@angelozerr - I have done support for part files through comparison. I will update you on whether we can contribute this.
@piotrtomiak I'm sorry I have not understood? You have already implemented tern file "part" (see http://ternjs.net/doc/manual.html) instead of "full" (like today?). If it that and you can contribute it, it should really fantastic, otherwise I will implement it and are you OK to have ONE instance of TernDocumentFile per editor?
@angelozerr yeah, exactly. Not much coding :) I will create PR soon, today or tomorrow morning.
@angelozerr yeah, exactly. Not much coding :) I will create PR soon, today or tomorrow morning.
Wow, very cool! I'm very exciting with your PR:) Thanks!