tern.java icon indicating copy to clipboard operation
tern.java copied to clipboard

Extension point to generate tern plugin/JSON Type definition from JavaScript sources

Open angelozerr opened this issue 10 years ago • 2 comments

Tern is able to analyse any JavaScript files sources to provide completion, hyperlink, hover, refactoring, but in some cases it is better to have a tern plugin/JSON Type definition :

  • when the JavaScript framework is complex and provides complex feature like node.js require function which returns a special type according parameter id:
var f = require('fs')
f. // here f has file system type
  • when there are a lot of JavaScript files, tern can takes some times to analyse those JavaScript files.

It exists several mean to generate tern plugin/JSON Type definition from JavaScript sources like:

  • use tern condense https://github.com/marijnh/tern/blob/master/bin/condense
  • use jsdoc2tern to generate tern plugin from JSDoc https://github.com/angelozerr/jsdoc2tern
  • for YUI https://github.com/angelozerr/tern-yui3/tree/master/generator
  • for Phaser https://github.com/angelozerr/tern-phaser/tree/master/generator
  • other generator?

It should be cool, that tern.java provides an extension point for those each generator. After that, user will able to select a folder, click on right button to have a menu Tern -> Generate, it opens a Wizard Page and user can select a generator. The click on Finish button of this wizard generate tern plugin/JSON Type Definition and install the generated tern plugin/JSON Type Definition in the tern repository and update the .tern-project.

With this feature, user will able to:

  • generate a tern plugin//JSON Type Definition for her version of the JavaScript frameworks that it uses.
  • improve performance when tern starts when there are a lot of JavaScript files (because the analyse of JavaScript files is already done, but it means that if he changes the JavaSCript sources files of the framework, it will need to regenerate it).

@demonfiddler what do you think about this feature? Could you be interest with this extension point to generate your own tern module with your generator (XSD, etc).

angelozerr avatar Sep 17 '15 12:09 angelozerr

Thanks, @angelozerr this would ceratinly be a useful addition to the Tern IDE toolset. BTW my apologies for the delayed response - too many things happening at once here.

In our own particular case we've already (partially) solved the problem of how to generate the JSON definition, since this must necessarily be done as part of our automated Maven build rather than manually in an IDE.

demonfiddler avatar Sep 25 '15 08:09 demonfiddler

Thanks @demonfiddler for your answer. I will wait to see if a lot of people could be interested with this feature to implement it.

angelozerr avatar Sep 25 '15 11:09 angelozerr