-
Notifications
You must be signed in to change notification settings - Fork 52
Creating Tern Plugins
Tern Toolings are for helping with extending Tern IDE, and not for Tern IDE users.
See https://github.com/marijnh/tern/issues/443
https://github.com/angelozerr/tern-jug tern plugin example
Server plugins gives you the capability to generate a simple tern plugin.
Open the wizard selection (Ctrl+N) and select Tern / Server plugin :
Click on Next button and choose as container a project which has tern nature (Configure / Convert to Tern project...)
After click on Finish button, a tern plugin is generated in the project root folder :
At this step, our tern plugin is generated inside root project and looks like this :
(function(mod) {
if (typeof exports == "object" && typeof module == "object") { // CommonJS
var path = require("path"), ternDir = path.resolve(process.argv[1], "..");
return mod(require(ternDir + "/../lib/tern"), require(ternDir + "/../lib/tern"));
}
if (typeof define == "function" && define.amd) // AMD
return define([ "tern/lib/infer", "tern/lib/tern" ], mod);
mod(tern, tern);
})(function(infer, tern) {
"use strict";
tern.registerPlugin("mylibrary", function(server, options) {
return {
defs : defs
};
});
var defs = {
"!name": "mylibrary",
"!define": {
"point": {
"x": "number",
"y": "number"
}
},
"MyConstructor": {
"!type": "fn(arg: string)",
"staticFunction": "fn() -> bool",
"prototype": {
"property": "[number]",
"clone": "fn() -> +MyConstructor",
"getPoint": "fn(i: number) -> point"
}
},
"someOtherGlobal": "string"
}
});
Now we will use it.
By default, the JS files which are hosted in the root project, cannot be used as tern plugin. To use our generated tern plugin, we must enable loading local plugin :
Close the project properties page, reopen it, go to Tern / Modules and check your generated tern plugin :
Create a JS file and test the generated tern plugin :
This wiki is to summarize knowledge.
Please create issues for particular problems.
Tern plugins and JSON Tern definition are generally references as modules inside tern.java project. #63
TODO see #19 #20 #43 #125 and marijnh/tern#443
Since 0.7.0 plugin list is not hard-coded and you can use your own tern repository.
- Tern IDE
- Tern Toolings
-
Tern Modules
- AngularJS
- AlloyUI
- Browser
- Bootstrap
- CKEditor
- CordovaJS
- Dojo Toolkit
- ECMAScript
- ExtJS
- Game
- jQuery
- JSDoc Support
- Liferay
- Meteor
- Node.js
- Qooxdoo
- snabbt.js
- RequireJS
- Tabris.js
- three.js
- Titanium
- YUI Library
- Completion
- Linter (Validator)
- Tests
- JavaScript Build
- New and Noteworthy