Bug 464823 - [tern] Support loading plugins on the fly
Summary: [tern] Support loading plugins on the fly
Status: RESOLVED FIXED
Alias: None
Product: Orion (Archived)
Classification: ECD
Component: JS Tools (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 11.0   Edit
Assignee: Michael Rennie CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 393711 432940
Blocks: 464824 470316
  Show dependency tree
 
Reported: 2015-04-16 14:15 EDT by Michael Rennie CLA
Modified: 2015-11-25 17:39 EST (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Rennie CLA 2015-04-16 14:15:33 EDT
With the fix to bug 432940, Tern is our default assist handler. To avoid force-loading a tonne of plugins, we need to add support for loading plugins on-demand. This will be useful for plugins added / removed / enabled from preferences and will work better with defined eslint-env directives.
Comment 1 Angelo ZERR CLA 2015-04-18 02:14:39 EDT
If you wish to do that, I think you need to create a new instance of Tern server with the new plugins to load.
Comment 2 Michael Rennie CLA 2015-04-20 11:29:01 EDT
(In reply to Angelo ZERR from comment #1)
> If you wish to do that, I think you need to create a new instance of Tern
> server with the new plugins to load.

I think we might be able to do it by trying:

1. load the plugin with require
2. using 'exports.registerPlugin' to make Tern aware of the new plugin
3. setting the defs from the plugin in Tern's list of defs
4. setting the passes from the plugin in Tern  
5. issuing a #reset() on the server

These are pretty much the steps The Tern constructor uses.
Comment 3 Michael Rennie CLA 2015-05-20 16:06:48 EDT
I pushed the skeleton for a plugin that will allow us to ask the server what plugins it has, and to install / remove plugins:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=8c34523ae99801def505e0c921c34ba69e741488
Comment 4 Michael Rennie CLA 2015-05-21 15:08:37 EDT
Pushed the complete plugins API + handler + listeners to:

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=f009111dba9ca7144d386670f3eb9922dbbea24c

The first implementation in the new API is a new request called 'installed_plugins', which, as you guessed, returns the complete listing of plugins currently known to Tern - these are all of the plugins defined when the server start and the ones that were added, and can include plugins defined but that could not be loaded by Tern.

There are three other requests:
1. install_plugins - once implemented will allow a plugin(s) to be installed in Tern
2. remove_plugins - once implemented will allow a plugin(s) to be removed from Tern
3. plugin_enablement - once implemented will allow a plugin(s) to be enabled / disabled. I'm not so sure about the usefulness of this one though, its basically a remove to disable and and install to add. Maybe we can work it to turn them off without removing so we don;t lose plugin state.
Comment 5 Michael Rennie CLA 2015-11-25 17:39:03 EST
Pushed fix to allow plugin and definition files to be loaded on demand when a tern project file is detected. If for any reason the loading fails, or the .tern-project file has problems (syntax or otherwise), the worker falls back to loading the default configuration.

http://git.eclipse.org/c/orion/org.eclipse.orion.client.git/commit/?id=ddcc5f06cd249f7a27a1974a1979f5aa0559b861

Also added a new test suite for .tern-project file tests and a skeleton plugin for ESLint

Since the hooks are in place to load plugins / defs as we need, I am going to close this bug as fixed, and have opened bug 483053 for the work to enable installing plugins via the pref page (or some other way).