Permalink
Browse files

Move standard language definitions into a single ecmascript.json file

To avoid a multiplying set of ecmaX.json files.
  • Loading branch information...
1 parent 7f42452 commit a53d2ee43d091a44fb4291779a786ed3fc010ba3 @marijnh marijnh committed Aug 16, 2016
Showing with 1,218 additions and 1,256 deletions.
  1. +1 −1 bin/condense
  2. +2 −4 bin/tern
  3. +0 −976 defs/ecma5.json
  4. +0 −12 defs/ecma7.json
  5. +1,190 −236 defs/{ecma6.json → ecmascript.json}
  6. +3 −3 doc/demo/index.html
  7. +1 −1 doc/manual.html
  8. +1 −1 doc/manual.txt
  9. +2 −3 index.html
  10. +8 −8 lib/def.js
  11. +4 −4 lib/infer.js
  12. +2 −2 test/condense.js
  13. +1 −1 test/fragments.js
  14. +1 −1 test/reload.js
  15. +1 −1 test/runcases.js
  16. +1 −2 test/util.js
View
@@ -31,7 +31,7 @@ function loadDef(name) {
defs.push(JSON.parse(fs.readFileSync(found, "utf8")));
}
-loadDef("ecma5");
+loadDef("ecmascript");
function loadPlugin(name, val) {
var found = findFile(name, "plugin", ".js");
View
@@ -98,10 +98,8 @@ var distDir = path.resolve(__dirname, "..");
function findDefs(projectDir, config) {
var defs = [], src = config.libs.slice();
- if (config.ecmaScript) {
- if (src.indexOf("ecma6") == -1 && config.ecmaVersion >= 6) src.unshift("ecma6")
- if (src.indexOf("ecma5") == -1) src.unshift("ecma5")
- }
+ if (config.ecmaScript && src.indexOf("ecmascript") == -1)
+ src.unshift("ecmascript")
for (var i = 0; i < src.length; ++i) {
var file = src[i];
if (!/\.json$/.test(file)) file = file + ".json";
View
Oops, something went wrong.
View
@@ -1,12 +0,0 @@
-{
- "!name": "ecma7",
- "Array": {
- "prototype": {
- "includes": {
- "!type": "fn(value: ?) -> bool",
- "!url": "https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/includes",
- "!doc": "Determines whether an array includes a certain element, returning true or false as appropriate."
- }
- }
- }
-}
Oops, something went wrong.
View
@@ -72,7 +72,7 @@
<div style="display: none" id="projects">
<project id="simple"
data-plugins="doc_comments complete_strings"
- data-libs="ecma5 browser">
+ data-libs="ecmascript browser">
<pre id="test">
// Use ctrl-space to complete something
co
@@ -104,7 +104,7 @@
<project id="requirejs"
data-plugins="requirejs doc_comments complete_strings"
- data-libs="ecma5 browser jquery">
+ data-libs="ecmascript browser jquery">
<pre id="main.js">
// A simple set of three modules, connected with requirejs
@@ -163,7 +163,7 @@
<project id="ES6"
data-plugins="es_modules doc_comments complete_strings"
- data-libs="ecma5 ecma6">
+ data-libs="ecmascript">
<pre id="index.js">
// Tern can do ECMAScript 6 (2015) too!
View
@@ -1039,7 +1039,7 @@
defined.</p>
<p> Finally, a function can be annotated with effects that it has. These
aren&#8217;t currently documented, but you can search for <code>!effects</code> in
-<code>defs/ecma5.json</code> to see some examples. Similarly, a function type
+<code>defs/ecmascript.json</code> to see some examples. Similarly, a function type
string&#8217;s return type may contain the variables <code>!0</code> (the first
argument&#8217;s type, <code>!N</code> for the N-1th), <code>!this</code> (the self type of the
call), and a special property <code>!ret</code> (the return type of a function).</p>
View
@@ -533,7 +533,7 @@ defined.
Finally, a function can be annotated with effects that it has. These
aren't currently documented, but you can search for `!effects` in
-`defs/ecma5.json` to see some examples. Similarly, a function type
+`defs/ecmascript.json` to see some examples. Similarly, a function type
string's return type may contain the variables `!0` (the first
argument's type, `!N` for the N-1th), `!this` (the self type of the
call), and a special property `!ret` (the return type of a function).
View
@@ -167,7 +167,7 @@
<ul class="release-note">
<li>Parse input as ES6 (but ignore most ES6 constructs for now)</li>
- <li>Improved type inference for promises (as defined in the <code>ecma6</code> json file)</li>
+ <li>Improved type inference for promises</li>
<li>Fix another source of exponential complexity blowup</li>
<li>Complete module names in the requirejs plugin</li>
<li>Improved type guessing for overridden properties</li>
@@ -209,8 +209,7 @@
<li>Add support for union types. The strings for types will now
often contain <code>|</code> characters separating alternatives.
Such types are also allowed in JSDoc comments.</li>
- <li>Add a
- rough <a href="defs/ecma6.json"><code>ecma6.json</code></a> type
+ <li>Add rough ECMAScript 6 type
definition, which adds some new variables and properties from ES6.
(note that this is still a far way off from real ES6 support.)</li>
<li>Various small bugfixes (<a href="https://github.com/ternjs/tern/compare/0.8.0...0.9.0">full list of patches</a>)</li>
View
@@ -1,6 +1,6 @@
// Type description parser
//
-// Type description JSON files (such as ecma5.json and browser.json)
+// Type description JSON files (such as ecmascript.json and browser.json)
// are used to
//
// A) describe types that come from native code
@@ -618,14 +618,14 @@
});
infer.registerFunction("Promise_ctor", function(_self, args, argNodes) {
- var defs6 = infer.cx().definitions.ecma6
- if (!defs6 || args.length < 1) return infer.ANull;
- var self = new infer.Obj(defs6["Promise.prototype"]);
+ var defs = infer.cx().definitions.ecmascript
+ if (!defs || args.length < 1) return infer.ANull;
+ var self = new infer.Obj(defs["Promise.prototype"]);
var valProp = self.defProp(":t", argNodes && argNodes[0]);
var valArg = new infer.AVal;
valArg.propagate(valProp);
var exec = new infer.Fn("execute", infer.ANull, [valArg], ["value"], infer.ANull);
- var reject = defs6.Promise_reject;
+ var reject = defs.Promise_reject;
args[0].propagate(new infer.IsCallee(infer.ANull, [exec, reject], null, infer.ANull));
return self;
});
@@ -644,10 +644,10 @@
infer.registerFunction("Promise_then", function(self, args, argNodes) {
var fn = args.length && args[0].getFunctionType();
- var defs6 = infer.cx().definitions.ecma6
- if (!fn || !defs6) return self;
+ var defs = infer.cx().definitions.ecmascript
+ if (!fn || !defs) return self;
- var result = new infer.Obj(defs6["Promise.prototype"]);
+ var result = new infer.Obj(defs["Promise.prototype"]);
var value = result.defProp(":t", argNodes && argNodes[0]), ty;
if (fn.retval.isEmpty() && (ty = self.getType()) instanceof infer.Obj && ty.hasProp(":t"))
ty.getProp(":t").propagate(value, WG_PROMISE_KEEP_VALUE);
View
@@ -825,7 +825,7 @@
this.props = Object.create(null);
this.protos = Object.create(null);
this.origins = [];
- this.curOrigin = "ecma5";
+ this.curOrigin = "ecmascript";
this.paths = Object.create(null);
this.definitions = Object.create(null);
this.purgeGen = 0;
@@ -1123,8 +1123,8 @@
if (node.param.type == "Identifier") {
var v = addVar(scope, node.param);
c(node.body, scope, "Statement");
- var e5 = cx.definitions.ecma5;
- if (e5 && v.isEmpty()) getInstance(e5["Error.prototype"]).propagate(v, WG_CATCH_ERROR);
+ var ecma = cx.definitions.ecmascript;
+ if (ecma && v.isEmpty()) getInstance(ecma["Error.prototype"]).propagate(v, WG_CATCH_ERROR);
} else {
c(node.param, patternScopes(scope), "Pattern")
}
@@ -1808,7 +1808,7 @@
retObj.defProp("done").addType(cx.bool)
output.propagate(retObj.defProp("value"))
var method = new Fn(null, ANull, input ? [input] : [], input ? ["?"] : [], retObj)
- var result = new Obj(cx.definitions.ecma6 && cx.definitions.ecma6.generator_prototype || true)
+ var result = new Obj(cx.definitions.ecmascript && cx.definitions.ecmascript.generator_prototype || true)
result.defProp("next").addType(method)
return result
}
View
@@ -9,7 +9,7 @@ function jsonFile(name) { return util.resolve(condenseDir + "/" + name.replace(/
function runTest(options) {
var server = new tern.Server({
- defs: [util.ecma5, util.browser],
+ defs: [util.ecmascript, util.browser],
plugins: options.plugins,
projectDir: util.resolve(condenseDir),
getFile: function(name) {
@@ -30,7 +30,7 @@ function runTest(options) {
// Test loading the condensed defs.
var server2 = new tern.Server({
- defs: [util.ecma5, util.browser, condensed],
+ defs: [util.ecmascript, util.browser, condensed],
plugins: options.plugins
});
server2.flush(function() {
View
@@ -4,7 +4,7 @@ var fs = require("fs");
var file = fs.readFileSync(util.resolve("test/data/large.js"), "utf8");
-var server = new tern.Server({defs: [util.ecma5]});
+var server = new tern.Server({defs: [util.ecmascript]});
var curTest;
function fail(msg) { throw curTest + ": " + msg; }
View
@@ -8,7 +8,7 @@ function test(name, f) {
if (!added) { util.addFile(); added = true; }
util.addTest();
- f(new tern.Server({defs: [util.ecma5], debug: true}));
+ f(new tern.Server({defs: [util.ecmascript], debug: true}));
});
}
View
@@ -19,7 +19,7 @@ var defData = {
};
function getDefs(text) {
- var spec = /\/\/ environment=(\w+)\n/g, m, defs = [util.ecma5, util.ecma6];
+ var spec = /\/\/ environment=(\w+)\n/g, m, defs = [util.ecmascript];
while (m = spec.exec(text)) {
var data = defData[m[1]];
if (!data) throw new Error("Unknown environment: " + m[1]);
View
@@ -3,8 +3,7 @@ var fs = require("fs"), path = require("path");
var projectDir = path.resolve(__dirname, "..");
exports.resolve = function(pth) { return path.resolve(projectDir, pth); };
-exports.ecma5 = JSON.parse(fs.readFileSync(exports.resolve("defs/ecma5.json")), "utf8");
-exports.ecma6 = JSON.parse(fs.readFileSync(exports.resolve("defs/ecma6.json")), "utf8");
+exports.ecmascript = JSON.parse(fs.readFileSync(exports.resolve("defs/ecmascript.json")), "utf8");
exports.browser = JSON.parse(fs.readFileSync(exports.resolve("defs/browser.json")), "utf8");
exports.jquery = JSON.parse(fs.readFileSync(exports.resolve("defs/jquery.json")), "utf8");
exports.underscore = JSON.parse(fs.readFileSync(exports.resolve("defs/underscore.json")), "utf8");

0 comments on commit a53d2ee

Please sign in to comment.