diff --git a/.travis.yml b/.travis.yml index fc1508961db72f..6dc8e2bdbaa6cf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,3 +2,4 @@ language: node_js node_js: - node - lts/* + - 6 diff --git a/CHANGELOG.md b/CHANGELOG.md index e6fa641e560801..1596d71684aa2f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,73 @@ # Change Log +## [v10.2.0](https://github.com/w3c/webidl2.js/tree/v10.2.0) (2018-01-30) +[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.1.0...v10.2.0) + +**Merged pull requests:** + +- Type on union idlType [\#135](https://github.com/w3c/webidl2.js/pull/135) ([saschanaz](https://github.com/saschanaz)) +- feat: add argument/return type [\#134](https://github.com/w3c/webidl2.js/pull/134) ([saschanaz](https://github.com/saschanaz)) +- feat: add dictionary/typedef-type [\#133](https://github.com/w3c/webidl2.js/pull/133) ([saschanaz](https://github.com/saschanaz)) +- feat: add const-type for idlTypes [\#132](https://github.com/w3c/webidl2.js/pull/132) ([saschanaz](https://github.com/saschanaz)) +- feat: add types on idlTypes [\#131](https://github.com/w3c/webidl2.js/pull/131) ([saschanaz](https://github.com/saschanaz)) +- Auto acquisition for parser result changes [\#130](https://github.com/w3c/webidl2.js/pull/130) ([saschanaz](https://github.com/saschanaz)) + +## [v10.1.0](https://github.com/w3c/webidl2.js/tree/v10.1.0) (2018-01-19) +[Full Changelog](https://github.com/w3c/webidl2.js/compare/v10.0.0...v10.1.0) + +**Closed issues:** + +- Support `raises` and `setraises` [\#128](https://github.com/w3c/webidl2.js/issues/128) +- Support `legacycaller` [\#127](https://github.com/w3c/webidl2.js/issues/127) +- Improve "No semicolon after enum" message [\#119](https://github.com/w3c/webidl2.js/issues/119) + +**Merged pull requests:** + +- Let error messages include the current definition name [\#129](https://github.com/w3c/webidl2.js/pull/129) ([saschanaz](https://github.com/saschanaz)) + +## [v10.0.0](https://github.com/w3c/webidl2.js/tree/v10.0.0) (2017-12-20) +[Full Changelog](https://github.com/w3c/webidl2.js/compare/v9.0.0...v10.0.0) + +**Closed issues:** + +- Always return an array for idlType, etc. [\#113](https://github.com/w3c/webidl2.js/issues/113) +- Maintain writer.js or not? [\#109](https://github.com/w3c/webidl2.js/issues/109) + +**Merged pull requests:** + +- Remove typeExtAttrs from docs [\#124](https://github.com/w3c/webidl2.js/pull/124) ([saschanaz](https://github.com/saschanaz)) +- Remove iterator documentation [\#123](https://github.com/w3c/webidl2.js/pull/123) ([saschanaz](https://github.com/saschanaz)) +- Maintain writer.js [\#122](https://github.com/w3c/webidl2.js/pull/122) ([saschanaz](https://github.com/saschanaz)) +- BREAKING CHANGE: remove deprecated iterator operation [\#121](https://github.com/w3c/webidl2.js/pull/121) ([saschanaz](https://github.com/saschanaz)) +- Use for-of on tests [\#120](https://github.com/w3c/webidl2.js/pull/120) ([saschanaz](https://github.com/saschanaz)) +- docs\(README\): iterables ildType is always array [\#118](https://github.com/w3c/webidl2.js/pull/118) ([marcoscaceres](https://github.com/marcoscaceres)) + +## [v9.0.0](https://github.com/w3c/webidl2.js/tree/v9.0.0) (2017-11-30) +[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.1.0...v9.0.0) + +**Closed issues:** + +- Code quality [\#116](https://github.com/w3c/webidl2.js/issues/116) +- Unable to parse HTMLAllCollection interface [\#114](https://github.com/w3c/webidl2.js/issues/114) +- Add support for mixin syntax [\#112](https://github.com/w3c/webidl2.js/issues/112) +- Whitespace issues [\#111](https://github.com/w3c/webidl2.js/issues/111) + +**Merged pull requests:** + +- Consistent array type for iterable.idlType [\#117](https://github.com/w3c/webidl2.js/pull/117) ([saschanaz](https://github.com/saschanaz)) +- Revert "chore: drop Node 6 support \(\#102\)" [\#115](https://github.com/w3c/webidl2.js/pull/115) ([TimothyGu](https://github.com/TimothyGu)) + +## [v8.1.0](https://github.com/w3c/webidl2.js/tree/v8.1.0) (2017-11-03) +[Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.1...v8.1.0) + +**Closed issues:** + +- Extended Attributes `rhs` should always be there [\#96](https://github.com/w3c/webidl2.js/issues/96) + +**Merged pull requests:** + +- Always add rhs property [\#110](https://github.com/w3c/webidl2.js/pull/110) ([saschanaz](https://github.com/saschanaz)) + ## [v8.0.1](https://github.com/w3c/webidl2.js/tree/v8.0.1) (2017-11-03) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v8.0.0...v8.0.1) @@ -9,7 +77,7 @@ **Merged pull requests:** -- Remove m postfix from all\_ws\(\) [\#108](https://github.com/w3c/webidl2.js/pull/108) ([SaschaNaz](https://github.com/SaschaNaz)) +- Remove m postfix from all\_ws\(\) [\#108](https://github.com/w3c/webidl2.js/pull/108) ([saschanaz](https://github.com/saschanaz)) ## [v8.0.0](https://github.com/w3c/webidl2.js/tree/v8.0.0) (2017-11-03) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v7.0.0...v8.0.0) @@ -21,9 +89,9 @@ **Merged pull requests:** -- Support mixins + includes statements [\#105](https://github.com/w3c/webidl2.js/pull/105) ([SaschaNaz](https://github.com/SaschaNaz)) +- Support mixins + includes statements [\#105](https://github.com/w3c/webidl2.js/pull/105) ([saschanaz](https://github.com/saschanaz)) - chore: drop Node 6 support [\#102](https://github.com/w3c/webidl2.js/pull/102) ([marcoscaceres](https://github.com/marcoscaceres)) -- BREAKING CHANGE: drop creator support [\#101](https://github.com/w3c/webidl2.js/pull/101) ([SaschaNaz](https://github.com/SaschaNaz)) +- BREAKING CHANGE: drop creator support [\#101](https://github.com/w3c/webidl2.js/pull/101) ([saschanaz](https://github.com/saschanaz)) - Normalize some whitespace to pass wpt's lint [\#99](https://github.com/w3c/webidl2.js/pull/99) ([foolip](https://github.com/foolip)) ## [v7.0.0](https://github.com/w3c/webidl2.js/tree/v7.0.0) (2017-10-27) @@ -54,7 +122,7 @@ **Merged pull requests:** -- Use ES2015 syntax for tests [\#88](https://github.com/w3c/webidl2.js/pull/88) ([SaschaNaz](https://github.com/SaschaNaz)) +- Use ES2015 syntax for tests [\#88](https://github.com/w3c/webidl2.js/pull/88) ([saschanaz](https://github.com/saschanaz)) ## [v6.0.0](https://github.com/w3c/webidl2.js/tree/v6.0.0) (2017-10-17) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v5.0.0...v6.0.0) @@ -73,7 +141,7 @@ **Merged pull requests:** -- BREAKING CHANGE: Use ES2015 syntax [\#84](https://github.com/w3c/webidl2.js/pull/84) ([SaschaNaz](https://github.com/SaschaNaz)) +- BREAKING CHANGE: Use ES2015 syntax [\#84](https://github.com/w3c/webidl2.js/pull/84) ([saschanaz](https://github.com/saschanaz)) ## [v4.2.0](https://github.com/w3c/webidl2.js/tree/v4.2.0) (2017-10-16) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v4.1.0...v4.2.0) @@ -85,8 +153,8 @@ **Merged pull requests:** -- Check duplicated names [\#80](https://github.com/w3c/webidl2.js/pull/80) ([SaschaNaz](https://github.com/SaschaNaz)) -- Remove legacycaller [\#79](https://github.com/w3c/webidl2.js/pull/79) ([SaschaNaz](https://github.com/SaschaNaz)) +- Check duplicated names [\#80](https://github.com/w3c/webidl2.js/pull/80) ([saschanaz](https://github.com/saschanaz)) +- Remove legacycaller [\#79](https://github.com/w3c/webidl2.js/pull/79) ([saschanaz](https://github.com/saschanaz)) - Add "sequence" property to IDL Type AST definition [\#76](https://github.com/w3c/webidl2.js/pull/76) ([lerouche](https://github.com/lerouche)) ## [v4.1.0](https://github.com/w3c/webidl2.js/tree/v4.1.0) (2017-07-04) @@ -98,7 +166,7 @@ **Merged pull requests:** -- Support TypeWithExtendedAttributes on generics [\#75](https://github.com/w3c/webidl2.js/pull/75) ([SaschaNaz](https://github.com/SaschaNaz)) +- Support TypeWithExtendedAttributes on generics [\#75](https://github.com/w3c/webidl2.js/pull/75) ([saschanaz](https://github.com/saschanaz)) ## [v4.0.0](https://github.com/w3c/webidl2.js/tree/v4.0.0) (2017-06-27) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.2...v4.0.0) @@ -112,7 +180,7 @@ **Merged pull requests:** - BREAKING CHANGE: remove serializers \(closes \#73\) [\#74](https://github.com/w3c/webidl2.js/pull/74) ([marcoscaceres](https://github.com/marcoscaceres)) -- Add documentation for namespaces [\#70](https://github.com/w3c/webidl2.js/pull/70) ([SaschaNaz](https://github.com/SaschaNaz)) +- Add documentation for namespaces [\#70](https://github.com/w3c/webidl2.js/pull/70) ([saschanaz](https://github.com/saschanaz)) ## [v3.0.2](https://github.com/w3c/webidl2.js/tree/v3.0.2) (2017-05-29) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v3.0.1...v3.0.2) @@ -123,7 +191,7 @@ **Merged pull requests:** -- Test for latest LTS/stable node versions [\#69](https://github.com/w3c/webidl2.js/pull/69) ([SaschaNaz](https://github.com/SaschaNaz)) +- Test for latest LTS/stable node versions [\#69](https://github.com/w3c/webidl2.js/pull/69) ([saschanaz](https://github.com/saschanaz)) ## [v3.0.1](https://github.com/w3c/webidl2.js/tree/v3.0.1) (2017-05-18) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.4.0...v3.0.1) @@ -135,8 +203,8 @@ **Merged pull requests:** -- Fix whitespace error on parsing extended attributes [\#68](https://github.com/w3c/webidl2.js/pull/68) ([SaschaNaz](https://github.com/SaschaNaz)) -- Remove deprecated IDL arrays and exceptions [\#67](https://github.com/w3c/webidl2.js/pull/67) ([SaschaNaz](https://github.com/SaschaNaz)) +- Fix whitespace error on parsing extended attributes [\#68](https://github.com/w3c/webidl2.js/pull/68) ([saschanaz](https://github.com/saschanaz)) +- Remove deprecated IDL arrays and exceptions [\#67](https://github.com/w3c/webidl2.js/pull/67) ([saschanaz](https://github.com/saschanaz)) ## [v2.4.0](https://github.com/w3c/webidl2.js/tree/v2.4.0) (2017-04-12) [Full Changelog](https://github.com/w3c/webidl2.js/compare/v2.1.0...v2.4.0) @@ -157,7 +225,7 @@ - Update webidl2.js [\#63](https://github.com/w3c/webidl2.js/pull/63) ([tqeto](https://github.com/tqeto)) - Remove support for MapClass \(no longer valid in WebIDL\) [\#62](https://github.com/w3c/webidl2.js/pull/62) ([dontcallmedom](https://github.com/dontcallmedom)) - Add support for annotated types [\#61](https://github.com/w3c/webidl2.js/pull/61) ([dontcallmedom](https://github.com/dontcallmedom)) -- Support namespaces [\#58](https://github.com/w3c/webidl2.js/pull/58) ([SaschaNaz](https://github.com/SaschaNaz)) +- Support namespaces [\#58](https://github.com/w3c/webidl2.js/pull/58) ([saschanaz](https://github.com/saschanaz)) - Add support for records [\#57](https://github.com/w3c/webidl2.js/pull/57) ([TimothyGu](https://github.com/TimothyGu)) - Refactor [\#50](https://github.com/w3c/webidl2.js/pull/50) ([marcoscaceres](https://github.com/marcoscaceres)) - feat\(lib\): add AMD export support \(closes \#48\) [\#49](https://github.com/w3c/webidl2.js/pull/49) ([marcoscaceres](https://github.com/marcoscaceres)) diff --git a/README.md b/README.md index 93cc78b9c48bd5..8791360d1c132d 100644 --- a/README.md +++ b/README.md @@ -310,7 +310,6 @@ A typedef looks like this: ```JS { "type": "typedef", - "typeExtAttrs": [], "idlType": { "sequence": true, "generic": "sequence", @@ -336,8 +335,6 @@ The fields are as follows: * `name`: The typedef's name. * `idlType`: An [IDL Type](#idl-type) describing what typedef's type. * `extAttrs`: A list of [extended attributes](#extended-attributes). -* `typeExtAttrs`: A list of [extended attributes](#extended-attributes) that apply to the -type rather than to the typedef as a whole. ### Implements @@ -489,34 +486,6 @@ The fields are as follows: * `value`: The constant value as described by [Const Values](#default-and-const-values) * `extAttrs`: A list of [extended attributes](#extended-attributes). -### Iterator Member - -Iterator members look like this - -```JS -{ - "type": "iterator", - "getter": false, - "setter": false, - "deleter": false, - "static": false, - "stringifier": false, - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "Session2" - }, - "iteratorObject": "SessionIterator", - "extAttrs": [] -} -``` - -* `type`: Always "iterator". -* `iteratorObject`: The string on the right-hand side; absent if there isn't one. -* the rest: same as on [operations](#operation-member). - ### Arguments The arguments (e.g. for an operation) look like this: @@ -611,7 +580,7 @@ These appear as members of interfaces that look like this: The fields are as follows: * `type`: Always one of "iterable", "legacyiterable", "maplike" or "setlike". -* `idlType`: An [IDL Type](#idl-type) (or an array of two types) representing the declared type arguments. +* `idlType`: An array with one or more [IDL Types](#idl-type) representing the declared type arguments. * `readonly`: Whether the maplike or setlike is declared as read only. * `extAttrs`: A list of [extended attributes](#extended-attributes). diff --git a/lib/webidl2.js b/lib/webidl2.js index 2f116c40d94bfc..a7a61d957b55c5 100644 --- a/lib/webidl2.js +++ b/lib/webidl2.js @@ -1,32 +1,82 @@ "use strict"; (() => { + // These regular expressions use the sticky flag so they will only match at + // the current location (ie. the offset of lastIndex). + const tokenRe = { + // This expression uses a lookahead assertion to catch false matches + // against integers early. + "float": /-?(?=[0-9]*\.|[0-9]+[eE])(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/y, + "integer": /-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/y, + "identifier": /[A-Z_a-z][0-9A-Z_a-z-]*/y, + "string": /"[^"]*"/y, + "whitespace": /[\t\n\r ]+/y, + "comment": /((\/(\/.*|\*([^*]|\*[^\/])*\*\/)[\t\n\r ]*)+)/y, + "other": /[^\t\n\r 0-9A-Z_a-z]/y + }; + + function attemptTokenMatch(str, type, re, lastIndex, tokens) { + re.lastIndex = lastIndex; + const result = re.exec(str); + if (result) { + tokens.push({ type, value: result[0] }); + return re.lastIndex; + } + return -1; + } + function tokenise(str) { const tokens = []; - const re = { - "float": /^-?(([0-9]+\.[0-9]*|[0-9]*\.[0-9]+)([Ee][-+]?[0-9]+)?|[0-9]+[Ee][-+]?[0-9]+)/, - "integer": /^-?(0([Xx][0-9A-Fa-f]+|[0-7]*)|[1-9][0-9]*)/, - "identifier": /^[A-Z_a-z][0-9A-Z_a-z-]*/, - "string": /^"[^"]*"/, - "whitespace": /^(?:[\t\n\r ]+|[\t\n\r ]*((\/\/.*|\/\*(.|\n|\r)*?\*\/)[\t\n\r ]*))+/, - "other": /^[^\t\n\r 0-9A-Z_a-z]/ - }; - const types = ["float", "integer", "identifier", "string", "whitespace", "other"]; - while (str.length > 0) { - let matched = false; - for (const type of types) { - str = str.replace(re[type], tok => { - tokens.push({ type, value: tok }); - matched = true; - return ""; - }); - if (matched) break; + let lastIndex = 0; + while (lastIndex < str.length) { + const nextChar = str.charAt(lastIndex); + let result = -1; + if (/[-0-9.]/.test(nextChar)) { + result = attemptTokenMatch(str, "float", tokenRe.float, lastIndex, + tokens); + if (result === -1) { + result = attemptTokenMatch(str, "integer", tokenRe.integer, lastIndex, + tokens); + } + if (result === -1) { + // '-' and '.' can also match "other". + result = attemptTokenMatch(str, "other", tokenRe.other, + lastIndex, tokens); + } + } else if (/[A-Z_a-z]/.test(nextChar)) { + result = attemptTokenMatch(str, "identifier", tokenRe.identifier, + lastIndex, tokens); + } else if (nextChar === '"') { + result = attemptTokenMatch(str, "string", tokenRe.string, + lastIndex, tokens); + if (result === -1) { + // '"' can also match "other". + result = attemptTokenMatch(str, "other", tokenRe.other, + lastIndex, tokens); + } + } else if (/[\t\n\r ]/.test(nextChar)) { + result = attemptTokenMatch(str, "whitespace", tokenRe.whitespace, + lastIndex, tokens); + } else if (nextChar === '/') { + // The parser expects comments to be labelled as "whitespace". + result = attemptTokenMatch(str, "whitespace", tokenRe.comment, + lastIndex, tokens); + if (result === -1) { + // '/' can also match "other". + result = attemptTokenMatch(str, "other", tokenRe.other, + lastIndex, tokens); + } + } else { + result = attemptTokenMatch(str, "other", tokenRe.other, + lastIndex, tokens); + } + if (result === -1) { + throw new Error("Token stream not progressing"); } - if (matched) continue; - throw new Error("Token stream not progressing"); + lastIndex = result; } return tokens; - }; + } class WebIDLParseError { constructor(str, line, input, tokens) { @@ -45,6 +95,7 @@ let line = 1; tokens = tokens.slice(); const names = new Map(); + let current = null; const FLOAT = "float"; const INT = "integer"; @@ -57,7 +108,7 @@ getter: false, setter: false, deleter: false, - "static": false, + static: false, stringifier: false }); @@ -69,8 +120,18 @@ tok += tokens[numTokens].value; numTokens++; } - throw new WebIDLParseError(str, line, tok, tokens.slice(0, maxTokens)); - }; + + let message; + if (current) { + message = `Got an error during or right after parsing \`${current.partial ? "partial " : ""}${current.type} ${current.name}\`: ${str}` + } + else { + // throwing before any valid definition + message = `Got an error before parsing any named definition: ${str}`; + } + + throw new WebIDLParseError(message, line, tok, tokens.slice(0, maxTokens)); + } function sanitize_name(name, type) { if (names.has(name)) { @@ -86,23 +147,34 @@ if (!tokens.length || tokens[0].type !== type) return; if (typeof value === "undefined" || tokens[0].value === value) { last_token = tokens.shift(); - if (type === ID) last_token.value = last_token.value.replace(/^_/, ""); + if (type === ID && last_token.value.startsWith('_')) + last_token.value = last_token.value.substring(1); return last_token; } - }; + } + + function count(str, char) { + let total = 0; + for (let i = str.indexOf(char); i !== -1; i = str.indexOf(char, i + 1)) { + ++total; + } + return total; + } function ws() { if (!tokens.length) return; if (tokens[0].type === "whitespace") { const t = tokens.shift(); - t.value.replace(/\n/g, m => { - line++; - return m; - }); + line += count(t.value, '\n'); return t; } - }; + } + const all_ws_re = { + "ws": /([\t\n\r ]+)/y, + "line-comment": /\/\/(.*)\r?\n?/y, + "multiline-comment": /\/\*((?:[^*]|\*[^/])*)\*\//y + }; function all_ws(store, pea) { // pea == post extended attribute, tpea = same for types const t = { type: "whitespace", value: "" }; while (true) { @@ -113,30 +185,30 @@ if (t.value.length > 0) { if (store) { let w = t.value; - const re = { - "ws": /^([\t\n\r ]+)/, - "line-comment": /^\/\/(.*)\r?\n?/, - "multiline-comment": /^\/\*((?:.|\n|\r)*?)\*\// - }; - const wsTypes = []; - for (const k in re) wsTypes.push(k); - while (w.length) { + let lastIndex = 0; + while (lastIndex < w.length) { let matched = false; - for (const type of wsTypes) { - w = w.replace(re[type], (tok, m1) => { - store.push({ type: type + (pea ? ("-" + pea) : ""), value: m1 }); + // Servo doesn't support using "const" in this construction yet. + // See https://github.com/servo/servo/issues/20231. + // |type| can be made const once Servo supports it. + for (let type in all_ws_re) { + const re = all_ws_re[type]; + re.lastIndex = lastIndex; + const result = re.exec(w); + if (result) { + store.push({ type: type + (pea ? ("-" + pea) : ""), value: result[1] }); matched = true; - return ""; - }); - if (matched) break; + lastIndex = re.lastIndex; + break; + } } - if (matched) continue; - throw new Error("Surprising white space construct."); // this shouldn't happen + if (!matched) + throw new Error("Surprising white space construct."); // this shouldn't happen } } return t; } - }; + } function integer_type() { let ret = ""; @@ -151,7 +223,7 @@ return ret; } if (ret) error("Failed to parse integer type"); - }; + } function float_type() { let ret = ""; @@ -161,7 +233,7 @@ if (consume(ID, "float")) return ret + "float"; if (consume(ID, "double")) return ret + "double"; if (ret) error("Failed to parse float type"); - }; + } function primitive_type() { const num_type = integer_type() || float_type(); @@ -170,7 +242,7 @@ if (consume(ID, "boolean")) return "boolean"; if (consume(ID, "byte")) return "byte"; if (consume(ID, "octet")) return "octet"; - }; + } function const_value() { if (consume(ID, "true")) return { type: "boolean", value: true }; @@ -185,7 +257,7 @@ if (consume(ID, "Infinity")) return { type: "Infinity", negative: true }; else tokens.unshift(tok); } - }; + } function type_suffix(obj) { while (true) { @@ -195,11 +267,11 @@ obj.nullable = true; } else return; } - }; + } - function single_type() { + function single_type(typeName) { const prim = primitive_type(); - const ret = { sequence: false, generic: null, nullable: false, union: false }; + const ret = { type: typeName || null, sequence: false, generic: null, nullable: false, union: false }; let name; let value; if (prim) { @@ -217,7 +289,7 @@ const types = []; do { all_ws(); - types.push(type_with_extended_attributes() || error("Error parsing generic type " + value)); + types.push(type_with_extended_attributes(typeName) || error("Error parsing generic type " + value)); all_ws(); } while (consume(OTHER, ",")); @@ -246,12 +318,12 @@ type_suffix(ret); if (ret.nullable && ret.idlType === "any") error("Type any cannot be made nullable"); return ret; - }; + } - function union_type() { + function union_type(typeName) { all_ws(); if (!consume(OTHER, "(")) return; - const ret = { sequence: false, generic: null, nullable: false, union: true, idlType: [] }; + const ret = { type: typeName || null, sequence: false, generic: null, nullable: false, union: true, idlType: [] }; const fst = type_with_extended_attributes() || error("Union type with no content"); ret.idlType.push(fst); while (true) { @@ -263,18 +335,18 @@ if (!consume(OTHER, ")")) error("Unterminated union type"); type_suffix(ret); return ret; - }; + } - function type() { - return single_type() || union_type(); - }; + function type(typeName) { + return single_type(typeName) || union_type(typeName); + } - function type_with_extended_attributes() { + function type_with_extended_attributes(typeName) { const extAttrs = extended_attrs(); - const ret = single_type() || union_type(); + const ret = single_type(typeName) || union_type(typeName); if (extAttrs.length && ret) ret.extAttrs = extAttrs; return ret; - }; + } function argument(store) { const ret = { optional: false, variadic: false }; @@ -285,7 +357,7 @@ ret.optional = true; all_ws(); } - ret.idlType = type_with_extended_attributes(); + ret.idlType = type_with_extended_attributes("argument-type"); if (!ret.idlType) { if (opt_token) tokens.unshift(opt_token); return; @@ -320,7 +392,7 @@ } } return ret; - }; + } function argument_list(store) { const ret = []; @@ -333,7 +405,7 @@ const nxt = argument(store ? ret : null) || error("Trailing comma in arguments list"); ret.push(nxt); } - }; + } function simple_extended_attr(store) { all_ws(); @@ -384,7 +456,7 @@ consume(OTHER, ")") || error("Unexpected token in extended attribute argument list"); } return ret; - }; + } // Note: we parse something simpler than the official syntax. It's all that ever // seems to be used @@ -404,7 +476,7 @@ all_ws(); consume(OTHER, "]") || error("No end of extended attribute"); return eas; - }; + } function default_() { all_ws(); @@ -418,11 +490,11 @@ return { type: "sequence", value: [] }; } else { const str = consume(STR) || error("No value for default"); - str.value = str.value.replace(/^"/, "").replace(/"$/, ""); + str.value = str.value.slice(1, -1); return str; } } - }; + } function const_(store) { all_ws(store, "pea"); @@ -434,7 +506,7 @@ typ = consume(ID) || error("No type for const"); typ = typ.value; } - ret.idlType = typ; + ret.idlType = { type: "const-type", idlType: typ }; all_ws(); if (consume(OTHER, "?")) { ret.nullable = true; @@ -451,7 +523,7 @@ all_ws(); consume(OTHER, ";") || error("Unterminated const"); return ret; - }; + } function inheritance() { all_ws(); @@ -460,7 +532,7 @@ const inh = consume(ID) || error("No type in inheritance"); return inh.value; } - }; + } function operation_rest(ret, store) { all_ws(); @@ -475,7 +547,7 @@ all_ws(); consume(OTHER, ";") || error("Unterminated operation"); return ret; - }; + } function callback(store) { all_ws(store, "pea"); @@ -484,12 +556,11 @@ all_ws(); const tok = consume(ID, "interface"); if (tok) { - ret = interface_rest(); - ret.type = "callback interface"; + ret = interface_rest(false, store, "callback interface"); return ret; } const name = consume(ID) || error("No name for callback"); - ret = { type: "callback", name: sanitize_name(name.value, "callback") }; + ret = current = { type: "callback", name: sanitize_name(name.value, "callback") }; all_ws(); consume(OTHER, "=") || error("No assignment in callback"); all_ws(); @@ -502,14 +573,14 @@ all_ws(); consume(OTHER, ";") || error("Unterminated callback"); return ret; - }; + } function attribute(store) { all_ws(store, "pea"); const grabbed = []; const ret = { type: "attribute", - "static": false, + static: false, stringifier: false, inherit: false, readonly: false @@ -517,7 +588,7 @@ const w = all_ws(); if (w) grabbed.push(w); if (consume(ID, "inherit")) { - if (ret["static"] || ret.stringifier) error("Cannot have a static or stringifier inherit"); + if (ret.static || ret.stringifier) error("Cannot have a static or stringifier inherit"); ret.inherit = true; grabbed.push(last_token); const w = all_ws(); @@ -534,14 +605,14 @@ tokens = grabbed.concat(tokens); } return rest; - }; + } function attribute_rest(ret) { if (!consume(ID, "attribute")) { return; } all_ws(); - ret.idlType = type_with_extended_attributes() || error("No type in attribute"); + ret.idlType = type_with_extended_attributes("attribute-type") || error("No type in attribute"); if (ret.idlType.sequence) error("Attributes cannot accept sequence types"); if (ret.idlType.generic === "record") error("Attributes cannot accept record types"); all_ws(); @@ -550,17 +621,17 @@ all_ws(); consume(OTHER, ";") || error("Unterminated attribute"); return ret; - }; + } function return_type() { - const typ = type(); + const typ = type("return-type"); if (!typ) { if (consume(ID, "void")) { return "void"; } else error("No return type"); } return typ; - }; + } function operation(store) { all_ws(store, "pea"); @@ -580,24 +651,9 @@ } ret.idlType = return_type(); all_ws(); - if (consume(ID, "iterator")) { - all_ws(); - ret.type = "iterator"; - if (consume(ID, "object")) { - ret.iteratorObject = "object"; - } else if (consume(OTHER, "=")) { - all_ws(); - var name = consume(ID) || error("No right hand side in iterator"); - ret.iteratorObject = name.value; - } - all_ws(); - consume(OTHER, ";") || error("Unterminated iterator"); - return ret; - } else { - operation_rest(ret, store); - return ret; - } - }; + operation_rest(ret, store); + return ret; + } function static_member(store) { all_ws(store, "pea"); @@ -629,7 +685,7 @@ arr.push(name.value); } else break; } - }; + } function iterable_type() { if (consume(ID, "iterable")) return "iterable"; @@ -637,13 +693,13 @@ else if (consume(ID, "maplike")) return "maplike"; else if (consume(ID, "setlike")) return "setlike"; else return; - }; + } function readonly_iterable_type() { if (consume(ID, "maplike")) return "maplike"; else if (consume(ID, "setlike")) return "setlike"; else return; - }; + } function iterable(store) { all_ws(store, "pea"); @@ -670,17 +726,14 @@ delete ret.readonly; all_ws(); if (consume(OTHER, "<")) { - ret.idlType = type_with_extended_attributes() || error(`Error parsing ${ittype} declaration`); + ret.idlType = [type_with_extended_attributes()] || error(`Error parsing ${ittype} declaration`); all_ws(); if (secondTypeAllowed) { - let type2 = null; if (consume(OTHER, ",")) { all_ws(); - type2 = type_with_extended_attributes(); + ret.idlType.push(type_with_extended_attributes()); all_ws(); } - if (type2) - ret.idlType = [ret.idlType, type2]; else if (secondTypeRequired) error(`Missing second type argument in ${ittype} declaration`); } @@ -691,16 +744,16 @@ error(`Error parsing ${ittype} declaration`); return ret; - }; + } - function interface_rest(isPartial, store) { + function interface_rest(isPartial, store, typeName = "interface") { all_ws(); const name = consume(ID) || error("No name for interface"); const mems = []; - const ret = { - type: "interface", + const ret = current = { + type: typeName, name: isPartial ? name.value : sanitize_name(name.value, "interface"), - partial: false, + partial: isPartial, members: mems }; if (!isPartial) ret.inheritance = inheritance() || null; @@ -731,7 +784,7 @@ mem.extAttrs = ea; ret.members.push(mem); } - }; + } function mixin_rest(isPartial, store) { all_ws(); @@ -739,10 +792,10 @@ all_ws(); const name = consume(ID) || error("No name for interface mixin"); const mems = []; - const ret = { + const ret = current = { type: "interface mixin", name: isPartial ? name.value : sanitize_name(name.value, "interface mixin"), - partial: false, + partial: isPartial, members: mems }; all_ws(); @@ -785,7 +838,7 @@ all_ws(); const name = consume(ID) || error("No name for namespace"); const mems = []; - const ret = { + const ret = current = { type: "namespace", name: isPartial ? name.value : sanitize_name(name.value, "namespace"), partial: isPartial, @@ -815,7 +868,7 @@ const grabbed = []; const ret = { type: "attribute", - "static": false, + static: false, stringifier: false, inherit: false, readonly: false @@ -854,9 +907,8 @@ interface_(true, store) || namespace(true, store) || error("Partial doesn't apply to anything"); - thing.partial = true; return thing; - }; + } function dictionary(isPartial, store) { all_ws(isPartial ? null : store, "pea"); @@ -864,10 +916,10 @@ all_ws(); const name = consume(ID) || error("No name for dictionary"); const mems = []; - const ret = { + const ret = current = { type: "dictionary", name: isPartial ? name.value : sanitize_name(name.value, "dictionary"), - partial: false, + partial: isPartial, members: mems }; if (!isPartial) ret.inheritance = inheritance() || null; @@ -883,7 +935,7 @@ const ea = extended_attrs(store ? mems : null); all_ws(store ? mems : null, "pea"); const required = consume(ID, "required"); - const typ = type_with_extended_attributes() || error("No type for dictionary member"); + const typ = type_with_extended_attributes("dictionary-type") || error("No type for dictionary member"); all_ws(); const name = consume(ID) || error("No name for dictionary member"); const dflt = default_(); @@ -902,7 +954,7 @@ all_ws(); consume(OTHER, ";") || error("Unterminated dictionary member"); } - }; + } function enum_(store) { all_ws(store, "pea"); @@ -910,7 +962,7 @@ all_ws(); const name = consume(ID) || error("No name for enum"); const vals = []; - const ret = { + const ret = current = { type: "enum", name: sanitize_name(name.value, "enum"), values: vals @@ -926,7 +978,7 @@ return ret; } const val = consume(STR) || error("Unexpected value in enum"); - val.value = val.value.replace(/"/g, ""); + val.value = val.value.slice(1, -1); ret.values.push(val); all_ws(store ? vals : null); if (consume(OTHER, ",")) { @@ -937,7 +989,7 @@ saw_comma = false; } } - }; + } function typedef(store) { all_ws(store, "pea"); @@ -946,14 +998,15 @@ type: "typedef" }; all_ws(); - ret.idlType = type_with_extended_attributes() || error("No type in typedef"); + ret.idlType = type_with_extended_attributes("typedef-type") || error("No type in typedef"); all_ws(); const name = consume(ID) || error("No name in typedef"); ret.name = sanitize_name(name.value, "typedef"); + current = ret; all_ws(); consume(OTHER, ";") || error("Unterminated typedef"); return ret; - }; + } function implements_(store) { all_ws(store, "pea"); @@ -976,7 +1029,7 @@ tokens.unshift(w); tokens.unshift(target); } - }; + } function includes(store) { all_ws(store, "pea"); @@ -999,7 +1052,7 @@ tokens.unshift(w); tokens.unshift(target); } - }; + } function definition(store) { return callback(store) || @@ -1011,7 +1064,7 @@ implements_(store) || includes(store) || namespace(false, store); - }; + } function definitions(store) { if (!tokens.length) return []; @@ -1027,11 +1080,11 @@ defs.push(def); } return defs; - }; + } const res = definitions(opt.ws); if (tokens.length) error("Unrecognised tokens"); return res; - }; + } const obj = { parse(str, opt) { diff --git a/lib/writer.js b/lib/writer.js index 5e30e707e13c54..c00c0dd932221b 100644 --- a/lib/writer.js +++ b/lib/writer.js @@ -1,78 +1,71 @@ -(function() { +"use strict"; - var write = function(ast, opt) { - var curPea = "", - curTPea = "", - opt = opt || {}, - noop = function(str) { - return str; }, - optNames = "type".split(" "), - context = []; - for (var i = 0, n = optNames.length; i < n; i++) { - var o = optNames[i]; +(() => { + function write(ast, opt = {}) { + let curPea = ""; + let curTPea = ""; + const noop = str => str; + const optNames = "type".split(" "); + const context = []; + for (const o of optNames) { if (!opt[o]) opt[o] = noop; } - var literal = function(it) { + function literal(it) { return it.value; }; - var wsPea = function(it) { + function wsPea(it) { curPea += it.value; return ""; }; - var wsTPea = function(it) { + function wsTPea(it) { curTPea += it.value; return ""; }; - var lineComment = function(it) { - return "//" + it.value + "\n"; + function lineComment(it) { + return `//${it.value}\n`; }; - var multilineComment = function(it) { - return "/*" + it.value + "*/"; + function multilineComment(it) { + return `/*${it.value}*/`; }; - var type = function(it) { + function type(it) { if (typeof it === "string") return opt.type(it); // XXX should maintain some context - if (it.union) return "(" + it.idlType.map(type).join(" or ") + ")"; - var ret = ""; - if (it.generic) ret += it.generic + "<"; - else if (it.sequence) ret += "sequence<"; - if (Array.isArray(it.idlType)) ret += it.idlType.map(type).join(", "); - else ret += type(it.idlType); - if (it.array || it.generic === 'Array') { - for (var i = 0, n = it.nullableArray.length; i < n; i++) { - var val = it.nullableArray[i]; - if (val) ret += "?"; - ret += "[]"; - } + let ret = extended_attributes(it.extAttrs, curPea); + if (it.union) ret += `(${it.idlType.map(type).join(" or ")})`; + else { + if (it.generic) ret += `${it.generic}<`; + if (Array.isArray(it.idlType)) ret += it.idlType.map(type).join(", "); + else ret += type(it.idlType); + if (it.generic) ret += ">"; } - if (it.generic || it.sequence) ret += ">"; if (it.nullable) ret += "?"; return ret; }; - var const_value = function(it) { - var tp = it.type; + function const_value(it) { + const tp = it.type; if (tp === "boolean") return it.value ? "true" : "false"; else if (tp === "null") return "null"; else if (tp === "Infinity") return (it.negative ? "-" : "") + "Infinity"; else if (tp === "NaN") return "NaN"; else if (tp === "number") return it.value; - else return '"' + it.value + '"'; + else if (tp === "sequence") return "[]"; + else return `"${it.value}"`; }; - var argument = function(arg, pea) { - var ret = extended_attributes(arg.extAttrs, pea); + function argument(arg, pea) { + let ret = extended_attributes(arg.extAttrs, pea); if (arg.optional) ret += "optional "; ret += type(arg.idlType); if (arg.variadic) ret += "..."; - ret += " " + arg.name; - if (arg["default"]) ret += " = " + const_value(arg["default"]); + ret += ` ${arg.name}`; + if (arg["default"]) ret += ` = ${const_value(arg["default"])}`; return ret; }; - var args = function(its) { - var res = "", - pea = ""; - for (var i = 0, n = its.length; i < n; i++) { - var arg = its[i]; + function args(its) { + let res = ""; + let pea = ""; + for (let i = 0, n = its.length; i < n; i++) { + const arg = its[i]; if (arg.type === "ws") res += arg.value; else if (arg.type === "ws-pea") pea += arg.value; else { @@ -83,182 +76,198 @@ } return res; }; - var make_ext_at = function(it) { - if (it["arguments"] === null) return it.name; + function make_ext_at(it) { context.unshift(it); - var ret = it.name + "(" + (it["arguments"].length ? args(it["arguments"]) : "") + ")"; + let ret = it.name; + if (it.rhs) { + if (it.rhs.type === "identifier-list") ret += `=(${it.rhs.value.join(',')})`; + else ret += `=${it.rhs.value}`; + } + if (it.arguments) ret += `(${it["arguments"].length ? args(it["arguments"]) : ""})`; context.shift(); // XXX need to add more contexts, but not more than needed for ReSpec return ret; }; - var extended_attributes = function(eats, pea) { + function extended_attributes(eats, pea) { if (!eats || !eats.length) return ""; - return "[" + eats.map(make_ext_at).join(", ") + "]" + pea; + return `[${eats.map(make_ext_at).join(", ")}]${pea}`; }; - var modifiers = "getter setter creator deleter legacycaller stringifier static".split(" "); - var operation = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + const modifiers = "getter setter creator deleter legacycaller stringifier static".split(" "); + function operation(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; if (it.stringifier && !it.idlType) return "stringifier;"; - for (var i = 0, n = modifiers.length; i < n; i++) { - var mod = modifiers[i]; + for (const mod of modifiers) { if (it[mod]) ret += mod + " "; } ret += type(it.idlType) + " "; if (it.name) ret += it.name; - ret += "(" + args(it["arguments"]) + ");"; + ret += `(${args(it["arguments"])});`; return ret; }; - var attribute = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function attribute(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; if (it["static"]) ret += "static "; if (it.stringifier) ret += "stringifier "; if (it.readonly) ret += "readonly "; if (it.inherit) ret += "inherit "; - ret += "attribute " + type(it.idlType) + " " + it.name + ";"; + ret += `attribute ${type(it.idlType)} ${it.name};`; return ret; }; - var interface_ = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function interface_(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; if (it.partial) ret += "partial "; - ret += "interface " + it.name + " "; - if (it.inheritance) ret += ": " + it.inheritance + " "; - ret += "{" + iterate(it.members) + "};"; + ret += `interface ${it.name} `; + if (it.inheritance) ret += `: ${it.inheritance} `; + ret += `{${iterate(it.members)}};`; return ret; }; - var dictionary = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function interface_mixin(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; if (it.partial) ret += "partial "; - ret += "dictionary " + it.name + " "; - ret += "{" + iterate(it.members) + "};"; + ret += `interface mixin ${it.name} `; + ret += `{${iterate(it.members)}};`; + return ret; + } + + function namespace(it) { + let ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it.partial) ret += "partial "; + ret += `namespace ${it.name} `; + ret += `{${iterate(it.members)}};`; + return ret; + } + + function dictionary(it) { + let ret = extended_attributes(it.extAttrs, curPea); + curPea = ""; + if (it.partial) ret += "partial "; + ret += `dictionary ${it.name} `; + if (it.inheritance) ret += `: ${it.inheritance} `; + ret += `{${iterate(it.members)}};`; return ret; }; - var field = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function field(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; if (it.required) ret += "required "; - ret += type(it.idlType) + " " + it.name; - if (it["default"]) ret += " = " + const_value(it["default"]); + ret += `${type(it.idlType)} ${it.name}`; + if (it["default"]) ret += ` = ${const_value(it["default"])}`; ret += ";"; return ret; }; - var exception = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function const_(it) { + const ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - ret += "exception " + it.name + " "; - if (it.inheritance) ret += ": " + it.inheritance + " "; - ret += "{" + iterate(it.members) + "};"; - return ret; + return `${ret}const ${type(it.idlType)}${it.nullable ? "?" : ""} ${it.name} = ${const_value(it.value)};`; }; - var const_ = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function typedef(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - return ret + "const " + type(it.idlType) + " " + it.name + " = " + const_value(it.value) + ";"; + ret += `typedef ${extended_attributes(it.typeExtAttrs, curTPea)}`; + curTPea = ""; + return `${ret}${type(it.idlType)} ${it.name};`; }; - var typedef = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function implements_(it) { + const ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - ret += "typedef " + extended_attributes(it.typeExtAttrs, curTPea); - curTPea = ""; - return ret + type(it.idlType) + " " + it.name + ";"; + return `${ret}${it.target} implements ${it["implements"]};`; }; - var implements_ = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function includes(it) { + const ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - return ret + it.target + " implements " + it["implements"] + ";"; + return `${ret}${it.target} includes ${it.includes};`; }; - var callback = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function callback(it) { + const ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - return ret + "callback " + it.name + " = " + type(it.idlType) + - "(" + args(it["arguments"]) + ");"; + return `${ret}callback ${it.name} = ${type(it.idlType)}(${args(it["arguments"])});`; }; - var enum_ = function(it) { - var ret = extended_attributes(it.extAttrs, curPea); + function enum_(it) { + let ret = extended_attributes(it.extAttrs, curPea); curPea = ""; - ret += "enum " + it.name + " {"; - for (var i = 0, n = it.values.length; i < n; i++) { - var v = it.values[i]; - if (typeof v === "string") ret += '"' + v + '"'; + ret += `enum ${it.name} {`; + for (const v of it.values) { + if (v.type === "string") ret += `"${v.value}"`; else if (v.type === "ws") ret += v.value; else if (v.type === ",") ret += ","; } return ret + "};"; }; - var iterable = function(it) { - return "iterable<" + (it.idlType instanceof Array ? it.idlType.map(type).join(", ") : type(it.idlType)) + ">;"; + function iterable(it) { + return `iterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`; }; - var legacyiterable = function(it) { - return "legacyiterable<" + (it.idlType instanceof Array ? it.idlType.map(type).join(", ") : type(it.idlType)) + ">;"; + function legacyiterable(it) { + return `legacyiterable<${Array.isArray(it.idlType) ? it.idlType.map(type).join(", ") : type(it.idlType)}>;`; }; - var maplike = function(it) { - return (it.readonly ? "readonly " : "") + "maplike<" + - it.idlType.map(type).join(", ") + ">;"; + function maplike(it) { + return `${it.readonly ? "readonly " : ""}maplike<${it.idlType.map(type).join(", ")}>;`; }; - var setlike = function(it) { - return (it.readonly ? "readonly " : "") + "setlike<" + - type(it.idlType) + ">;"; + function setlike(it) { + return `${it.readonly ? "readonly " : ""}setlike<${type(it.idlType[0])}>;`; }; - var callbackInterface = function(it) { - return 'callback ' + interface_(it); + function callbackInterface(it) { + return `callback ${interface_(it)}`; }; - var table = { + const table = { ws: literal, "ws-pea": wsPea, "ws-tpea": wsTPea, "line-comment": lineComment, "multiline-comment": multilineComment, - "interface": interface_, - operation: operation, - attribute: attribute, - dictionary: dictionary, - field: field, - exception: exception, - "const": const_, - typedef: typedef, - "implements": implements_, - callback: callback, - "enum": enum_, - iterable: iterable, - legacyiterable: legacyiterable, - maplike: maplike, - setlike: setlike, + interface: interface_, + "interface mixin": interface_mixin, + namespace, + operation, + attribute, + dictionary, + field, + const: const_, + typedef, + implements: implements_, + includes, + callback, + enum: enum_, + iterable, + legacyiterable, + maplike, + setlike, "callback interface": callbackInterface }; - var dispatch = function(it) { + function dispatch(it) { + const dispatcher = table[it.type]; + if (!dispatcher) { + throw new Error(`Type "${it.type}" is unsupported`) + } return table[it.type](it); }; - var iterate = function(things) { + function iterate(things) { if (!things) return; - var ret = ""; - for (var i = 0, n = things.length; i < n; i++) ret += dispatch(things[i]); + let ret = ""; + for (const thing of things) ret += dispatch(thing); return ret; }; return iterate(ast); }; - var obj = { - write: function(ast, opt) { - if (!opt) opt = {}; - return write(ast, opt); - } + const obj = { + write }; if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') { module.exports = obj; } else if (typeof define === 'function' && define.amd) { - define([], function() { - return obj; - }); + define([], () => obj); } else { (self || window).WebIDL2Writer = obj; } -}()); +})(); diff --git a/package-lock.json b/package-lock.json index 53528713e57be6..a6f529d6c7f11d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,25 +1,52 @@ { "name": "webidl2", - "version": "4.2.0", + "version": "10.2.1", "lockfileVersion": 1, + "requires": true, "dependencies": { + "@babel/code-frame": { + "version": "7.0.0-beta.40", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.40.tgz", + "integrity": "sha512-eVXQSbu/RimU6OKcK2/gDJVTFcxXJI4sHbIqw2mhwMZeQ2as/8AhS9DGkEDoHMBBNJZ5B0US63lF56x+KDcxiA==", + "dev": true, + "requires": { + "@babel/highlight": "7.0.0-beta.40" + } + }, + "@babel/highlight": { + "version": "7.0.0-beta.40", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.0.0-beta.40.tgz", + "integrity": "sha512-mOhhTrzieV6VO7odgzFGFapiwRK0ei8RZRhfzHhb6cpX3QM8XXuCLXWjN8qBB7JReDdUR80V3LFfFrGUYevhNg==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "esutils": "2.0.2", + "js-tokens": "3.0.2" + } + }, "ansi-regex": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-0.2.1.tgz", - "integrity": "sha1-DY6UaWej2BQ/k+JOKYUl/BsiNfk=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", + "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", "dev": true }, "ansi-styles": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-1.1.0.tgz", - "integrity": "sha1-6uy/Zs1waIJ2Cy9GkVgrj1XXp94=", - "dev": true + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "requires": { + "color-convert": "1.9.1" + } }, "arr-diff": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-2.0.0.tgz", "integrity": "sha1-jzuCf5Vai9ZpaX5KQlasPOrjVs8=", - "dev": true + "dev": true, + "requires": { + "arr-flatten": "1.1.0" + } }, "arr-flatten": { "version": "1.1.0", @@ -40,34 +67,51 @@ "dev": true }, "brace-expansion": { - "version": "1.1.8", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.8.tgz", - "integrity": "sha1-wHshHHyVLsH479Uad+8NHTmQopI=", - "dev": true + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "dev": true, + "requires": { + "balanced-match": "1.0.0", + "concat-map": "0.0.1" + } }, "braces": { "version": "1.8.5", "resolved": "https://registry.npmjs.org/braces/-/braces-1.8.5.tgz", "integrity": "sha1-uneWLhLf+WnWt2cR6RS3N4V79qc=", - "dev": true + "dev": true, + "requires": { + "expand-range": "1.8.2", + "preserve": "0.2.0", + "repeat-element": "1.1.2" + } }, "browser-stdout": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.0.tgz", - "integrity": "sha1-81HTKWnTL6XXpVZxVCY9korjvR8=", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", + "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, "chalk": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-0.5.1.tgz", - "integrity": "sha1-Zjs6ZItotV0EaQ1JFnqoN4WPIXQ=", - "dev": true + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.2.tgz", + "integrity": "sha512-ZM4j2/ld/YZDc3Ma8PgN7gyAk+kHMMMyzLNryCPGhWrsfAuDVeuid5bpRFTDgMH9JBK2lA4dyyAkkZYF/WcqDQ==", + "dev": true, + "requires": { + "ansi-styles": "3.2.1", + "escape-string-regexp": "1.0.5", + "supports-color": "5.3.0" + } }, "color-convert": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.0.tgz", - "integrity": "sha1-Gsz5fdc5uYO/mU1W/sj5WFNkG3o=", - "dev": true + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "dev": true, + "requires": { + "color-name": "1.1.3" + } }, "color-name": { "version": "1.1.3", @@ -76,9 +120,9 @@ "dev": true }, "commander": { - "version": "2.9.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.9.0.tgz", - "integrity": "sha1-nJkJQXbhIkDLItbFFGCYQA/g99Q=", + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==", "dev": true }, "concat-map": { @@ -88,15 +132,24 @@ "dev": true }, "debug": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.0.tgz", - "integrity": "sha1-vFlryr52F/Edn6FTYe3tVgi4SZs=", - "dev": true + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.1.0.tgz", + "integrity": "sha512-OX8XqP7/1a9cqkxYw2yXss15f26NKWBpDXQd0/uK/KPqdQhxbPa994hnzjcE2VqQpDslf55723cKPUOGSmMY3g==", + "dev": true, + "requires": { + "ms": "2.0.0" + } }, "diff": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-3.2.0.tgz", - "integrity": "sha1-yc45Okt8vQsFinJck98pkCeGj/k=", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz", + "integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==", + "dev": true + }, + "diff-match-patch": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/diff-match-patch/-/diff-match-patch-1.0.0.tgz", + "integrity": "sha1-HMPIOkkNZ/ldkeOfatHy4Ia2MEg=", "dev": true }, "escape-string-regexp": { @@ -105,37 +158,52 @@ "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=", "dev": true }, + "esutils": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", + "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "dev": true + }, "expand-brackets": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-0.1.5.tgz", "integrity": "sha1-3wcoTjQqgHzXM6xa9yQR5YHRF3s=", - "dev": true + "dev": true, + "requires": { + "is-posix-bracket": "0.1.1" + } }, "expand-range": { "version": "1.8.2", "resolved": "https://registry.npmjs.org/expand-range/-/expand-range-1.8.2.tgz", "integrity": "sha1-opnv/TNf4nIeuujiV+x5ZE/IUzc=", - "dev": true + "dev": true, + "requires": { + "fill-range": "2.2.3" + } }, "expect": { - "version": "21.2.1", - "resolved": "https://registry.npmjs.org/expect/-/expect-21.2.1.tgz", - "integrity": "sha512-orfQQqFRTX0jH7znRIGi8ZMR8kTNpXklTTz8+HGTpmTKZo3Occ6JNB5FXMb8cRuiiC/GyDqsr30zUa66ACYlYw==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/expect/-/expect-22.4.0.tgz", + "integrity": "sha512-Fiy862jT3qc70hwIHwwCBNISmaqBrfWKKrtqyMJ6iwZr+6KXtcnHojZFtd63TPRvRl8EQTJ+YXYy2lK6/6u+Hw==", "dev": true, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true - } + "requires": { + "ansi-styles": "3.2.1", + "jest-diff": "22.4.0", + "jest-get-type": "22.1.0", + "jest-matcher-utils": "22.4.0", + "jest-message-util": "22.4.0", + "jest-regex-util": "22.1.0" } }, "extglob": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/extglob/-/extglob-0.3.2.tgz", "integrity": "sha1-Lhj/PS9JqydlzskCPwEdqo2DSaE=", - "dev": true + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } }, "filename-regex": { "version": "2.0.1", @@ -147,7 +215,14 @@ "version": "2.2.3", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-2.2.3.tgz", "integrity": "sha1-ULd9/X5Gm8dJJHCWNpn+eoSFpyM=", - "dev": true + "dev": true, + "requires": { + "is-number": "2.1.0", + "isobject": "2.1.0", + "randomatic": "1.1.7", + "repeat-element": "1.1.2", + "repeat-string": "1.6.1" + } }, "for-in": { "version": "1.0.2", @@ -159,7 +234,10 @@ "version": "0.1.5", "resolved": "https://registry.npmjs.org/for-own/-/for-own-0.1.5.tgz", "integrity": "sha1-UmXGgaTylNq78XyVCbZ2OqhFEM4=", - "dev": true + "dev": true, + "requires": { + "for-in": "1.0.2" + } }, "fs.realpath": { "version": "1.0.0", @@ -168,52 +246,65 @@ "dev": true }, "glob": { - "version": "7.1.1", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.1.tgz", - "integrity": "sha1-gFIR3wT6rxxjo2ADBs31reULLsg=", - "dev": true + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "dev": true, + "requires": { + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" + } }, "glob-base": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/glob-base/-/glob-base-0.3.0.tgz", "integrity": "sha1-27Fk9iIbHAscz4Kuoyi0l98Oo8Q=", - "dev": true + "dev": true, + "requires": { + "glob-parent": "2.0.0", + "is-glob": "2.0.1" + } }, "glob-parent": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-2.0.0.tgz", "integrity": "sha1-gTg9ctsFT8zPUzbaqQLxgvbtuyg=", - "dev": true - }, - "graceful-readlink": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/graceful-readlink/-/graceful-readlink-1.0.1.tgz", - "integrity": "sha1-TK+tdrxi8C+gObL5Tpo906ORpyU=", - "dev": true + "dev": true, + "requires": { + "is-glob": "2.0.1" + } }, "growl": { - "version": "1.9.2", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.9.2.tgz", - "integrity": "sha1-Dqd0NxXbjY3ixe3hd14bRayFwC8=", + "version": "1.10.3", + "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.3.tgz", + "integrity": "sha512-hKlsbA5Vu3xsh1Cg3J7jSmX/WaW6A5oBeqzM88oNbCRQFz+zUaXm6yxS4RVytp1scBoJzSYl4YAEOQIt6O8V1Q==", "dev": true }, - "has-ansi": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/has-ansi/-/has-ansi-0.1.0.tgz", - "integrity": "sha1-hPJlqujA5qiKEtcCKJS3VoiUxi4=", + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", + "he": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/he/-/he-1.1.1.tgz", + "integrity": "sha1-k0EP0hsAlzUVH4howvJx80J+I/0=", "dev": true }, "inflight": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", - "dev": true + "dev": true, + "requires": { + "once": "1.4.0", + "wrappy": "1.0.2" + } }, "inherits": { "version": "2.0.3", @@ -222,9 +313,9 @@ "dev": true }, "is-buffer": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", - "integrity": "sha1-Hzsm72E7IUuIy8ojzGwB2Hlh7sw=", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.6.tgz", + "integrity": "sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==", "dev": true }, "is-dotfile": { @@ -237,7 +328,10 @@ "version": "0.1.3", "resolved": "https://registry.npmjs.org/is-equal-shallow/-/is-equal-shallow-0.1.3.tgz", "integrity": "sha1-IjgJj8Ih3gvPpdnqxMRdY4qhxTQ=", - "dev": true + "dev": true, + "requires": { + "is-primitive": "2.0.0" + } }, "is-extendable": { "version": "0.1.1", @@ -255,13 +349,19 @@ "version": "2.0.1", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-2.0.1.tgz", "integrity": "sha1-0Jb5JqPe1WAPP9/ZEZjLCIjC2GM=", - "dev": true + "dev": true, + "requires": { + "is-extglob": "1.0.0" + } }, "is-number": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-2.1.0.tgz", "integrity": "sha1-Afy7s5NGOlSPL0ZszhbezknbkI8=", - "dev": true + "dev": true, + "requires": { + "kind-of": "3.2.2" + } }, "is-posix-bracket": { "version": "0.1.1", @@ -285,199 +385,113 @@ "version": "2.1.0", "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", - "dev": true + "dev": true, + "requires": { + "isarray": "1.0.0" + } }, "jest-diff": { - "version": "21.2.1", - "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-21.2.1.tgz", - "integrity": "sha512-E5fu6r7PvvPr5qAWE1RaUwIh/k6Zx/3OOkZ4rk5dBJkEWRrUuSgbMt2EO8IUTPTd6DOqU3LW6uTIwX5FRvXoFA==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/jest-diff/-/jest-diff-22.4.0.tgz", + "integrity": "sha512-+/t20WmnkOkB8MOaGaPziI8zWKxquMvYw4Ub+wOzi7AUhmpFXz43buWSxVoZo4J5RnCozpGbX3/FssjJ5KV9Nw==", "dev": true, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true - } + "requires": { + "chalk": "2.3.2", + "diff": "3.5.0", + "jest-get-type": "22.1.0", + "pretty-format": "22.4.0" } }, "jest-get-type": { - "version": "21.2.0", - "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-21.2.0.tgz", - "integrity": "sha512-y2fFw3C+D0yjNSDp7ab1kcd6NUYfy3waPTlD8yWkAtiocJdBRQqNoRqVfMNxgj+IjT0V5cBIHJO0z9vuSSZ43Q==", + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/jest-get-type/-/jest-get-type-22.1.0.tgz", + "integrity": "sha512-nD97IVOlNP6fjIN5i7j5XRH+hFsHL7VlauBbzRvueaaUe70uohrkz7pL/N8lx/IAwZRTJ//wOdVgh85OgM7g3w==", "dev": true }, "jest-matcher-utils": { - "version": "21.2.1", - "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-21.2.1.tgz", - "integrity": "sha512-kn56My+sekD43dwQPrXBl9Zn9tAqwoy25xxe7/iY4u+mG8P3ALj5IK7MLHZ4Mi3xW7uWVCjGY8cm4PqgbsqMCg==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/jest-matcher-utils/-/jest-matcher-utils-22.4.0.tgz", + "integrity": "sha512-03m3issxUXpWMwDYTfmL8hRNewUB0yCRTeXPm+eq058rZxLHD9f5NtSSO98CWHqe4UyISIxd9Ao9iDVjHWd2qg==", "dev": true, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true - } + "requires": { + "chalk": "2.3.2", + "jest-get-type": "22.1.0", + "pretty-format": "22.4.0" } }, "jest-message-util": { - "version": "21.2.1", - "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-21.2.1.tgz", - "integrity": "sha512-EbC1X2n0t9IdeMECJn2BOg7buOGivCvVNjqKMXTzQOu7uIfLml+keUfCALDh8o4rbtndIeyGU8/BKfoTr/LVDQ==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-22.4.0.tgz", + "integrity": "sha512-eyCJB0T3hrlpFF2FqQoIB093OulP+1qvATQmD3IOgJgMGqPL6eYw8TbC5P/VCWPqKhGL51xvjIIhow5eZ2wHFw==", "dev": true, - "dependencies": { - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true - }, - "chalk": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.1.0.tgz", - "integrity": "sha512-LUHGS/dge4ujbXMJrnihYMcL4AoOweGnw9Tp3kQuqy1Kx5c1qKjqvMJZ6nVJPMWJtKCTN72ZogH3oeSO9g9rXQ==", - "dev": true - }, - "has-flag": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", - "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", - "dev": true - }, - "supports-color": { - "version": "4.4.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", - "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", - "dev": true - } + "requires": { + "@babel/code-frame": "7.0.0-beta.40", + "chalk": "2.3.2", + "micromatch": "2.3.11", + "slash": "1.0.0", + "stack-utils": "1.0.1" } }, "jest-regex-util": { - "version": "21.2.0", - "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-21.2.0.tgz", - "integrity": "sha512-BKQ1F83EQy0d9Jen/mcVX7D+lUt2tthhK/2gDWRgLDJRNOdRgSp1iVqFxP8EN1ARuypvDflRfPzYT8fQnoBQFQ==", + "version": "22.1.0", + "resolved": "https://registry.npmjs.org/jest-regex-util/-/jest-regex-util-22.1.0.tgz", + "integrity": "sha512-on0LqVS6Xeh69sw3d1RukVnur+lVOl3zkmb0Q54FHj9wHoq6dbtWqb3TSlnVUyx36hqjJhjgs/QLqs07Bzu72Q==", "dev": true }, - "json3": { - "version": "3.3.2", - "resolved": "https://registry.npmjs.org/json3/-/json3-3.3.2.tgz", - "integrity": "sha1-PAQ0dD35Pi9cQq7nsZvLSDV19OE=", + "js-tokens": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-3.0.2.tgz", + "integrity": "sha1-mGbfOVECEw449/mWvOtlRDIJwls=", "dev": true }, "jsondiffpatch": { - "version": "0.2.4", - "resolved": "https://registry.npmjs.org/jsondiffpatch/-/jsondiffpatch-0.2.4.tgz", - "integrity": "sha1-1LbFOz/H2htLkcHCrsi5MrdRHVw=", - "dev": true + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/jsondiffpatch/-/jsondiffpatch-0.3.5.tgz", + "integrity": "sha512-v7eaGLDMCHXH+fsIaZhptEUJmS8EJpunq7IM4cc4vIT/kSRAkaZ6ZF4ebiNcyUelL0znbvj6o2B5Gh9v7Og0BQ==", + "dev": true, + "requires": { + "chalk": "2.3.2", + "diff-match-patch": "1.0.0" + } }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true - }, - "lodash._baseassign": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz", - "integrity": "sha1-jDigmVAPIVrQnlnxci/QxSv+Ck4=", - "dev": true - }, - "lodash._basecopy": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/lodash._basecopy/-/lodash._basecopy-3.0.1.tgz", - "integrity": "sha1-jaDmqHbPNEwK2KVIghEd08XHyjY=", - "dev": true - }, - "lodash._basecreate": { - "version": "3.0.3", - "resolved": "https://registry.npmjs.org/lodash._basecreate/-/lodash._basecreate-3.0.3.tgz", - "integrity": "sha1-G8ZhYU2qf8MRt9A78WgGoCE8+CE=", - "dev": true - }, - "lodash._getnative": { - "version": "3.9.1", - "resolved": "https://registry.npmjs.org/lodash._getnative/-/lodash._getnative-3.9.1.tgz", - "integrity": "sha1-VwvH3t5G1hzc3mh9ZdPuy6o6r/U=", - "dev": true - }, - "lodash._isiterateecall": { - "version": "3.0.9", - "resolved": "https://registry.npmjs.org/lodash._isiterateecall/-/lodash._isiterateecall-3.0.9.tgz", - "integrity": "sha1-UgOte6Ql+uhCRg5pbbnPPmqsBXw=", - "dev": true - }, - "lodash.create": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/lodash.create/-/lodash.create-3.1.1.tgz", - "integrity": "sha1-1/KEnw29p+BGgruM1yqwIkYd6+c=", - "dev": true - }, - "lodash.isarguments": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", - "integrity": "sha1-L1c9hcaiQon/AGY7SRwdM4/zRYo=", - "dev": true - }, - "lodash.isarray": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/lodash.isarray/-/lodash.isarray-3.0.4.tgz", - "integrity": "sha1-eeTriMNqgSKvhvhEqpvNhRtfu1U=", - "dev": true - }, - "lodash.keys": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/lodash.keys/-/lodash.keys-3.1.2.tgz", - "integrity": "sha1-TbwEcrFWvlCgsoaFXRvQsMZWCYo=", - "dev": true + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } }, "micromatch": { "version": "2.3.11", "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-2.3.11.tgz", "integrity": "sha1-hmd8l9FyCzY0MdBNDRUpO9OMFWU=", - "dev": true + "dev": true, + "requires": { + "arr-diff": "2.0.0", + "array-unique": "0.2.1", + "braces": "1.8.5", + "expand-brackets": "0.1.5", + "extglob": "0.3.2", + "filename-regex": "2.0.1", + "is-extglob": "1.0.0", + "is-glob": "2.0.1", + "kind-of": "3.2.2", + "normalize-path": "2.1.1", + "object.omit": "2.0.1", + "parse-glob": "3.0.4", + "regex-cache": "0.4.4" + } }, "minimatch": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", - "dev": true + "dev": true, + "requires": { + "brace-expansion": "1.1.11" + } }, "minimist": { "version": "0.0.8", @@ -489,51 +503,91 @@ "version": "0.5.1", "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz", "integrity": "sha1-MAV0OOrGz3+MR2fzhkjWaX11yQM=", - "dev": true + "dev": true, + "requires": { + "minimist": "0.0.8" + } }, "mocha": { - "version": "3.4.1", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-3.4.1.tgz", - "integrity": "sha1-o4ArSqOBk0yss43nDPdxYh2o+a8=", + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-5.0.4.tgz", + "integrity": "sha512-nMOpAPFosU1B4Ix1jdhx5e3q7XO55ic5a8cgYvW27CequcEY+BabS0kUVL1Cw1V5PuVHZWeNRWFLmEPexo79VA==", "dev": true, + "requires": { + "browser-stdout": "1.3.1", + "commander": "2.11.0", + "debug": "3.1.0", + "diff": "3.5.0", + "escape-string-regexp": "1.0.5", + "glob": "7.1.2", + "growl": "1.10.3", + "he": "1.1.1", + "mkdirp": "0.5.1", + "supports-color": "4.4.0" + }, "dependencies": { - "supports-color": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.1.2.tgz", - "integrity": "sha1-cqJiiU2dQIuVbKBf83su2KbiotU=", + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true + }, + "supports-color": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.4.0.tgz", + "integrity": "sha512-rKC3+DyXWgK0ZLKwmRsrkyHVZAjNkfzeehuFWdGGcqGDTZFH73+RH6S/RDAAxl9GusSjZSUWYLmT9N5pzXFOXQ==", + "dev": true, + "requires": { + "has-flag": "2.0.0" + } } } }, "ms": { - "version": "0.7.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-0.7.2.tgz", - "integrity": "sha1-riXPJRKziFodldfwN4aNhDESR2U=", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", "dev": true }, "normalize-path": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz", "integrity": "sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=", - "dev": true + "dev": true, + "requires": { + "remove-trailing-separator": "1.1.0" + } }, "object.omit": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/object.omit/-/object.omit-2.0.1.tgz", "integrity": "sha1-Gpx0SCnznbuFjHbKNXmuKlTr0fo=", - "dev": true + "dev": true, + "requires": { + "for-own": "0.1.5", + "is-extendable": "0.1.1" + } }, "once": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true + "dev": true, + "requires": { + "wrappy": "1.0.2" + } }, "parse-glob": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/parse-glob/-/parse-glob-3.0.4.tgz", "integrity": "sha1-ssN2z7EfNVE7rdFz7wu246OIORw=", - "dev": true + "dev": true, + "requires": { + "glob-base": "0.3.0", + "is-dotfile": "1.0.3", + "is-extglob": "1.0.0", + "is-glob": "2.0.1" + } }, "path-is-absolute": { "version": "1.0.1", @@ -548,23 +602,13 @@ "dev": true }, "pretty-format": { - "version": "21.2.1", - "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-21.2.1.tgz", - "integrity": "sha512-ZdWPGYAnYfcVP8yKA3zFjCn8s4/17TeYH28MXuC8vTp0o21eXjbFGcOAXZEaDaOFJjc3h2qa7HQNHNshhvoh2A==", + "version": "22.4.0", + "resolved": "https://registry.npmjs.org/pretty-format/-/pretty-format-22.4.0.tgz", + "integrity": "sha512-pvCxP2iODIIk9adXlo4S3GRj0BrJiil68kByAa1PrgG97c1tClh9dLMgp3Z6cHFZrclaABt0UH8PIhwHuFLqYA==", "dev": true, - "dependencies": { - "ansi-regex": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true - }, - "ansi-styles": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", - "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", - "dev": true - } + "requires": { + "ansi-regex": "3.0.0", + "ansi-styles": "3.2.1" } }, "randomatic": { @@ -572,18 +616,28 @@ "resolved": "https://registry.npmjs.org/randomatic/-/randomatic-1.1.7.tgz", "integrity": "sha512-D5JUjPyJbaJDkuAazpVnSfVkLlpeO3wDlPROTMLGKG1zMFNFRgrciKo1ltz/AzNTkqE0HzDx655QOL51N06how==", "dev": true, + "requires": { + "is-number": "3.0.0", + "kind-of": "4.0.0" + }, "dependencies": { "is-number": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "requires": { + "kind-of": "3.2.2" + }, "dependencies": { "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "dev": true + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } } } }, @@ -591,7 +645,10 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", - "dev": true + "dev": true, + "requires": { + "is-buffer": "1.1.6" + } } } }, @@ -599,7 +656,10 @@ "version": "0.4.4", "resolved": "https://registry.npmjs.org/regex-cache/-/regex-cache-0.4.4.tgz", "integrity": "sha512-nVIZwtCjkC9YgvWkpM55B5rBhBYRZhAaJbgcFYXXsHnbZ9UZI9nnVWYZpBlCqv9ho2eZryPnWrZGsOdPwVWXWQ==", - "dev": true + "dev": true, + "requires": { + "is-equal-shallow": "0.1.3" + } }, "remove-trailing-separator": { "version": "1.1.0", @@ -625,17 +685,20 @@ "integrity": "sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU=", "dev": true }, - "strip-ansi": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-0.3.0.tgz", - "integrity": "sha1-JfSOoiynkYfzF0pNuHWTR7sSYiA=", + "stack-utils": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/stack-utils/-/stack-utils-1.0.1.tgz", + "integrity": "sha1-1PM6tU6OOHeLDKXP07OvsS22hiA=", "dev": true }, "supports-color": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-0.2.0.tgz", - "integrity": "sha1-2S3iaU6z9nMjlz1649i1W0wiGQo=", - "dev": true + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.3.0.tgz", + "integrity": "sha512-0aP01LLIskjKs3lq52EC0aGBAJhLq7B2Rd8HC/DR/PtNNpcLilNmHC12O+hu0usQpo7wtHNRqtrhBwtDb0+dNg==", + "dev": true, + "requires": { + "has-flag": "3.0.0" + } }, "wrappy": { "version": "1.0.2", diff --git a/package.json b/package.json index d7b8a421241f85..ab282d189bb9e5 100644 --- a/package.json +++ b/package.json @@ -1,22 +1,24 @@ { "name": "webidl2", "description": "A WebIDL Parser", - "version": "8.1.0", + "version": "10.2.1", "contributors": [ "Robin Berjon (https://berjon.com)", "Marcos Caceres (https://marcosc.com)", - "Kagami Sascha Rosylight " + "Kagami Sascha Rosylight ", + "Timothy Gu " ], "license": "W3C", "dependencies": {}, "devDependencies": { - "expect": "21.2.1", - "jsondiffpatch": "0.2.5", - "mocha": "4.0.1" + "expect": "22.4.0", + "jsondiffpatch": "0.3.5", + "mocha": "5.0.4" }, "scripts": { - "test": "mocha" + "test": "mocha", + "acquire": "node test/util/acquire.js" }, - "repository": "git://github.com/darobin/webidl2.js", + "repository": "git://github.com/w3c/webidl2.js", "main": "index" } diff --git a/test/invalid.js b/test/invalid.js index 548f0ea4b3d4ef..19bbf006e579ef 100644 --- a/test/invalid.js +++ b/test/invalid.js @@ -4,37 +4,17 @@ "use strict"; -const wp = require("../lib/webidl2"); -const expect = require("expect"); -const pth = require("path"); +const { collect } = require("./util/collect"); const fs = require("fs"); +const expect = require("expect"); describe("Parses all of the invalid IDLs to check that they blow up correctly", () => { - const dir = pth.join(__dirname, "invalid/idl"); - const skip = {}; - const idls = fs.readdirSync(dir) - .filter(it => (/\.w?idl$/).test(it) && !skip[it]) - .map(it => pth.join(dir, it)); - const errors = idls.map(it => pth.join(__dirname, "invalid", "json", pth.basename(it).replace(/\.w?idl/, ".json"))); - - for (let i = 0, n = idls.length; i < n; i++) { - const idl = idls[i]; - const err = JSON.parse(fs.readFileSync(errors[i], "utf8")); - - it(`should produce the right error for ${idl}`, () => { - let error; - try { - var ast = wp.parse(fs.readFileSync(idl, "utf8")); - console.log(JSON.stringify(ast, null, 4)); - } - catch (e) { - error = e; - } - finally { - expect(error).toBeTruthy(); - expect(error.message).toEqual(err.message); - expect(error.line).toEqual(err.line); - } + for (const test of collect("invalid", { expectError: true })) { + it(`should produce the right error for ${test.path}`, () => { + const err = test.readJSON(); + expect(test.error).toBeTruthy(); + expect(test.error.message).toEqual(err.message); + expect(test.error.line).toEqual(err.line); }); } }); diff --git a/test/syntax/idl/iterator.widl b/test/invalid/idl/iterator.widl similarity index 100% rename from test/syntax/idl/iterator.widl rename to test/invalid/idl/iterator.widl diff --git a/test/invalid/idl/no-semicolon-callback.widl b/test/invalid/idl/no-semicolon-callback.widl new file mode 100644 index 00000000000000..cb2055718e5f04 --- /dev/null +++ b/test/invalid/idl/no-semicolon-callback.widl @@ -0,0 +1,7 @@ +callback interface NoSemicolon { + attribute boolean noSemiColon; +} + +enum YouNeedOne { + "really" +} diff --git a/test/invalid/idl/no-semicolon.widl b/test/invalid/idl/no-semicolon.widl new file mode 100644 index 00000000000000..10bc716249b3e1 --- /dev/null +++ b/test/invalid/idl/no-semicolon.widl @@ -0,0 +1,7 @@ +partial interface NoSemicolon { + attribute boolean noSemiColon; +} + +enum YouNeedOne { + "really" +} diff --git a/test/invalid/idl/stray-slash.widl b/test/invalid/idl/stray-slash.widl new file mode 100644 index 00000000000000..b673aa94b01d65 --- /dev/null +++ b/test/invalid/idl/stray-slash.widl @@ -0,0 +1,2 @@ +// This is a comment. +/ This is not. diff --git a/test/invalid/idl/stringconstants.idl b/test/invalid/idl/stringconstants.widl similarity index 100% rename from test/invalid/idl/stringconstants.idl rename to test/invalid/idl/stringconstants.widl diff --git a/test/invalid/json/array.json b/test/invalid/json/array.json index 30b377fc71c859..898b2d836bff81 100644 --- a/test/invalid/json/array.json +++ b/test/invalid/json/array.json @@ -1,4 +1,4 @@ { - "message": "No name in attribute", + "message": "Got an error during or right after parsing `interface LotteryResults`: No name in attribute", "line": 5 -} \ No newline at end of file +} diff --git a/test/invalid/json/caller.json b/test/invalid/json/caller.json index 79b8ecac04f3a3..567fa3368129f9 100644 --- a/test/invalid/json/caller.json +++ b/test/invalid/json/caller.json @@ -1,4 +1,4 @@ { - "message": "Invalid operation", + "message": "Got an error during or right after parsing `interface NumberQuadrupler`: Invalid operation", "line": 6 } diff --git a/test/invalid/json/dict-required-default.json b/test/invalid/json/dict-required-default.json index c5afeca85c05de..82b6b2ae42a6f6 100644 --- a/test/invalid/json/dict-required-default.json +++ b/test/invalid/json/dict-required-default.json @@ -1,4 +1,4 @@ { - "message": "Required member must not have a default" + "message": "Got an error during or right after parsing `dictionary Dict`: Required member must not have a default" , "line": 4 } diff --git a/test/invalid/json/duplicate.json b/test/invalid/json/duplicate.json index cef335875c391f..e88a7156fe8c1c 100644 --- a/test/invalid/json/duplicate.json +++ b/test/invalid/json/duplicate.json @@ -1,4 +1,4 @@ { - "message": "The name \"Test\" of type \"typedef\" is already seen", + "message": "Got an error during or right after parsing `typedef Test`: The name \"Test\" of type \"typedef\" is already seen", "line": 3 -} \ No newline at end of file +} diff --git a/test/invalid/json/enum.json b/test/invalid/json/enum.json index 166115801c3411..073ff6c290cafd 100644 --- a/test/invalid/json/enum.json +++ b/test/invalid/json/enum.json @@ -1,4 +1,4 @@ { - "message": "Unexpected value in enum" + "message": "Got an error during or right after parsing `enum foo`: Unexpected value in enum" , "line": 1 } diff --git a/test/invalid/json/exception.json b/test/invalid/json/exception.json index f52cda13837c5a..ad9fac6ca2f64e 100644 --- a/test/invalid/json/exception.json +++ b/test/invalid/json/exception.json @@ -1,4 +1,4 @@ { - "message": "Unrecognised tokens", + "message": "Got an error before parsing any named definition: Unrecognised tokens", "line": 4 } diff --git a/test/invalid/json/iterator.json b/test/invalid/json/iterator.json new file mode 100644 index 00000000000000..e46d653ae3c512 --- /dev/null +++ b/test/invalid/json/iterator.json @@ -0,0 +1,4 @@ +{ + "message": "Got an error during or right after parsing `interface SessionManager`: Invalid operation", + "line": 5 +} diff --git a/test/invalid/json/maplike-1type.json b/test/invalid/json/maplike-1type.json index 859a820a4910cd..75e7a35ee256e9 100644 --- a/test/invalid/json/maplike-1type.json +++ b/test/invalid/json/maplike-1type.json @@ -1,4 +1,4 @@ { - "message": "Missing second type argument in maplike declaration", + "message": "Got an error during or right after parsing `interface MapLikeOneType`: Missing second type argument in maplike declaration", "line": 2 -} \ No newline at end of file +} diff --git a/test/invalid/json/module.json b/test/invalid/json/module.json index 3b0984d973f45e..9c071cdd07a7a3 100644 --- a/test/invalid/json/module.json +++ b/test/invalid/json/module.json @@ -1,4 +1,4 @@ { - "message": "Unrecognised tokens" + "message": "Got an error before parsing any named definition: Unrecognised tokens" , "line": 2 } diff --git a/test/invalid/json/no-semicolon-callback.json b/test/invalid/json/no-semicolon-callback.json new file mode 100644 index 00000000000000..1db9d14c8e2c51 --- /dev/null +++ b/test/invalid/json/no-semicolon-callback.json @@ -0,0 +1,4 @@ +{ + "message": "Got an error during or right after parsing `callback interface NoSemicolon`: Missing semicolon after interface", + "line": 5 +} diff --git a/test/invalid/json/no-semicolon.json b/test/invalid/json/no-semicolon.json new file mode 100644 index 00000000000000..087532a012f592 --- /dev/null +++ b/test/invalid/json/no-semicolon.json @@ -0,0 +1,4 @@ +{ + "message": "Got an error during or right after parsing `partial interface NoSemicolon`: Missing semicolon after interface", + "line": 5 +} diff --git a/test/invalid/json/nonnullableany.json b/test/invalid/json/nonnullableany.json index cf5229e8e44ab0..8a1f90046ae4d9 100644 --- a/test/invalid/json/nonnullableany.json +++ b/test/invalid/json/nonnullableany.json @@ -1,4 +1,4 @@ { - "message": "Type any cannot be made nullable" + "message": "Got an error during or right after parsing `interface NonNullable`: Type any cannot be made nullable" , "line": 2 } diff --git a/test/invalid/json/nonnullableobjects.json b/test/invalid/json/nonnullableobjects.json index 23cbb3e5d180f1..52bd8dac16fe69 100644 --- a/test/invalid/json/nonnullableobjects.json +++ b/test/invalid/json/nonnullableobjects.json @@ -1,4 +1,4 @@ { - "message": "Can't nullable more than once" + "message": "Got an error during or right after parsing `interface NonNullable`: Can't nullable more than once" , "line": 4 } diff --git a/test/invalid/json/promise-with-extended-attribute.json b/test/invalid/json/promise-with-extended-attribute.json index e9623ce7cc8c58..71212d46e3c011 100644 --- a/test/invalid/json/promise-with-extended-attribute.json +++ b/test/invalid/json/promise-with-extended-attribute.json @@ -1,4 +1,4 @@ { - "message": "Promise type cannot have extended attribute", + "message": "Got an error during or right after parsing `interface Foo`: Promise type cannot have extended attribute", "line": 2 } diff --git a/test/invalid/json/raises.json b/test/invalid/json/raises.json index 8b67afe4fc9702..3165b874f0c189 100644 --- a/test/invalid/json/raises.json +++ b/test/invalid/json/raises.json @@ -1,4 +1,4 @@ { - "message": "Unterminated attribute" + "message": "Got an error during or right after parsing `interface Person`: Unterminated attribute" , "line": 5 } diff --git a/test/invalid/json/readonly-iterable.json b/test/invalid/json/readonly-iterable.json index c6f52a24615883..1a09264a6d0d65 100644 --- a/test/invalid/json/readonly-iterable.json +++ b/test/invalid/json/readonly-iterable.json @@ -1,4 +1,4 @@ { - "message": "Invalid operation", + "message": "Got an error during or right after parsing `interface ReadonlyIterable`: Invalid operation", "line": 2 -} \ No newline at end of file +} diff --git a/test/invalid/json/record-key-with-extended-attribute.json b/test/invalid/json/record-key-with-extended-attribute.json index 3945825c318d61..4002e7fe0155d5 100644 --- a/test/invalid/json/record-key-with-extended-attribute.json +++ b/test/invalid/json/record-key-with-extended-attribute.json @@ -1,4 +1,4 @@ { - "message": "Record key cannot have extended attribute", + "message": "Got an error during or right after parsing `interface Foo`: Record key cannot have extended attribute", "line": 2 } diff --git a/test/invalid/json/record-key.json b/test/invalid/json/record-key.json index 3b929b926a30a7..179d645d6a753d 100644 --- a/test/invalid/json/record-key.json +++ b/test/invalid/json/record-key.json @@ -1,4 +1,4 @@ { - "message": "Record key must be DOMString, USVString, or ByteString", + "message": "Got an error during or right after parsing `interface Foo`: Record key must be DOMString, USVString, or ByteString", "line": 2 } diff --git a/test/invalid/json/scopedname.json b/test/invalid/json/scopedname.json index 8e2cd803287ef4..4620d2df5fa0cc 100644 --- a/test/invalid/json/scopedname.json +++ b/test/invalid/json/scopedname.json @@ -1,4 +1,4 @@ { - "message": "No name in typedef" + "message": "Got an error before parsing any named definition: No name in typedef" , "line": 2 } diff --git a/test/invalid/json/sequenceAsAttribute.json b/test/invalid/json/sequenceAsAttribute.json index b714f5d92434a2..5b4314a6de128d 100644 --- a/test/invalid/json/sequenceAsAttribute.json +++ b/test/invalid/json/sequenceAsAttribute.json @@ -1,4 +1,4 @@ { - "message": "Attributes cannot accept sequence types" + "message": "Got an error during or right after parsing `interface sequenceAsAttribute`: Attributes cannot accept sequence types" , "line": 2 } diff --git a/test/invalid/json/setlike-2types.json b/test/invalid/json/setlike-2types.json index c9e49b6756d5d9..2900e1bac30074 100644 --- a/test/invalid/json/setlike-2types.json +++ b/test/invalid/json/setlike-2types.json @@ -1,4 +1,4 @@ { - "message": "Unterminated setlike declaration", + "message": "Got an error during or right after parsing `interface SetLikeTwoTypes`: Unterminated setlike declaration", "line": 2 -} \ No newline at end of file +} diff --git a/test/invalid/json/setter-creator.json b/test/invalid/json/setter-creator.json index 07b9f1f4bc42c4..25decb374e12fe 100644 --- a/test/invalid/json/setter-creator.json +++ b/test/invalid/json/setter-creator.json @@ -1,4 +1,4 @@ { - "message": "Invalid operation", + "message": "Got an error during or right after parsing `interface OrderedMap`: Invalid operation", "line": 3 } diff --git a/test/invalid/json/special-omittable.json b/test/invalid/json/special-omittable.json index 7acb08834b0e6e..c20b28e03c17d6 100644 --- a/test/invalid/json/special-omittable.json +++ b/test/invalid/json/special-omittable.json @@ -1,4 +1,4 @@ { - "message": "Invalid operation" + "message": "Got an error during or right after parsing `interface Dictionary`: Invalid operation" , "line": 6 } diff --git a/test/invalid/json/stray-slash.json b/test/invalid/json/stray-slash.json new file mode 100644 index 00000000000000..9c071cdd07a7a3 --- /dev/null +++ b/test/invalid/json/stray-slash.json @@ -0,0 +1,4 @@ +{ + "message": "Got an error before parsing any named definition: Unrecognised tokens" +, "line": 2 +} diff --git a/test/invalid/json/stringconstants.json b/test/invalid/json/stringconstants.json index d5bf1a8832c664..1eeb31cd3ef802 100644 --- a/test/invalid/json/stringconstants.json +++ b/test/invalid/json/stringconstants.json @@ -1,4 +1,4 @@ { - "message": "No value for const" + "message": "Got an error during or right after parsing `interface Util`: No value for const" , "line": 2 } diff --git a/test/invalid/json/typedef-nested.json b/test/invalid/json/typedef-nested.json index d7fb9182f86e9d..8c6081496851ab 100644 --- a/test/invalid/json/typedef-nested.json +++ b/test/invalid/json/typedef-nested.json @@ -1,4 +1,4 @@ { - "message": "Invalid operation" + "message": "Got an error during or right after parsing `interface Widget`: Invalid operation" , "line": 14 -} \ No newline at end of file +} diff --git a/test/syntax.js b/test/syntax.js index 0838f350cd96c9..05d647eda10394 100644 --- a/test/syntax.js +++ b/test/syntax.js @@ -1,34 +1,14 @@ "use strict"; -const wp = require("../lib/webidl2"); +const { collect } = require("./util/collect"); const expect = require("expect"); -const pth = require("path"); -const fs = require("fs"); -const jdp = require("jsondiffpatch"); const debug = true; describe("Parses all of the IDLs to produce the correct ASTs", () => { - const dir = pth.join(__dirname, "syntax/idl"); - const skip = {}; // use if we have a broken test - const idls = fs.readdirSync(dir) - .filter(it => (/\.widl$/).test(it) && !skip[it]) - .map(it => pth.join(dir, it)); - const jsons = idls.map(it => pth.join(__dirname, "syntax/json", pth.basename(it).replace(".widl", ".json"))); - - for (let i = 0, n = idls.length; i < n; i++) { - const idl = idls[i]; - const json = jsons[i]; - - it(`should produce the same AST for ${idl}`, () => { + for (const test of collect("syntax")) { + it(`should produce the same AST for ${test.path}`, () => { try { - const optFile = pth.join(__dirname, "syntax/opt", pth.basename(json)); - let opt = undefined; - if (fs.existsSync(optFile)) - opt = JSON.parse(fs.readFileSync(optFile, "utf8")); - const diff = jdp.diff(JSON.parse(fs.readFileSync(json, "utf8")), - wp.parse(fs.readFileSync(idl, "utf8").replace(/\r\n/g, "\n"), opt)); - if (diff && debug) console.log(JSON.stringify(diff, null, 4)); - expect(diff).toBe(undefined); + expect(test.diff()).toBeFalsy(); } catch (e) { console.log(e.toString()); diff --git a/test/syntax/idl/extended-attributes.widl b/test/syntax/idl/extended-attributes.widl index a49463b3d76339..57d4f97de7c317 100644 --- a/test/syntax/idl/extended-attributes.widl +++ b/test/syntax/idl/extended-attributes.widl @@ -20,4 +20,10 @@ interface Circle { attribute double cx; attribute double cy; readonly attribute double circumference; -}; \ No newline at end of file +}; + +// Extracted from https://heycam.github.io/webidl/#idl-annotated-types on 2017-12-15 +[Exposed=Window] +interface I { + attribute [XAttr] (long or Node) attrib; +}; diff --git a/test/syntax/idl/typedef-union.idl b/test/syntax/idl/typedef-union.widl similarity index 100% rename from test/syntax/idl/typedef-union.idl rename to test/syntax/idl/typedef-union.widl diff --git a/test/syntax/json/allowany.json b/test/syntax/json/allowany.json index ee898d68296c1d..cd5c6e00ac33b2 100644 --- a/test/syntax/json/allowany.json +++ b/test/syntax/json/allowany.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -30,6 +31,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -43,6 +45,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -62,6 +65,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -82,6 +86,7 @@ } ], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/attributes.json b/test/syntax/json/attributes.json index 86fe9d52dec69b..c90c70d7edc4ca 100644 --- a/test/syntax/json/attributes.json +++ b/test/syntax/json/attributes.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -24,4 +25,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/callback.json b/test/syntax/json/callback.json index 5301c40d754b94..f31067dd25cb99 100644 --- a/test/syntax/json/callback.json +++ b/test/syntax/json/callback.json @@ -3,6 +3,7 @@ "type": "callback", "name": "AsyncOperationCallback", "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -15,6 +16,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -39,6 +41,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -52,6 +55,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -71,6 +75,7 @@ "type": "callback", "name": "SortCallback", "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -83,6 +88,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -96,6 +102,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/constants.json b/test/syntax/json/constants.json index 75222866443f6c..4b98751622c339 100644 --- a/test/syntax/json/constants.json +++ b/test/syntax/json/constants.json @@ -7,7 +7,10 @@ { "type": "const", "nullable": false, - "idlType": "boolean", + "idlType": { + "type": "const-type", + "idlType": "boolean" + }, "name": "DEBUG", "value": { "type": "boolean", @@ -18,7 +21,10 @@ { "type": "const", "nullable": false, - "idlType": "short", + "idlType": { + "type": "const-type", + "idlType": "short" + }, "name": "negative", "value": { "type": "number", @@ -29,7 +35,10 @@ { "type": "const", "nullable": false, - "idlType": "octet", + "idlType": { + "type": "const-type", + "idlType": "octet" + }, "name": "LF", "value": { "type": "number", @@ -40,7 +49,10 @@ { "type": "const", "nullable": false, - "idlType": "unsigned long", + "idlType": { + "type": "const-type", + "idlType": "unsigned long" + }, "name": "BIT_MASK", "value": { "type": "number", @@ -51,7 +63,10 @@ { "type": "const", "nullable": false, - "idlType": "float", + "idlType": { + "type": "const-type", + "idlType": "float" + }, "name": "AVOGADRO", "value": { "type": "number", @@ -62,7 +77,10 @@ { "type": "const", "nullable": false, - "idlType": "unrestricted float", + "idlType": { + "type": "const-type", + "idlType": "unrestricted float" + }, "name": "sobig", "value": { "type": "Infinity", @@ -73,7 +91,10 @@ { "type": "const", "nullable": false, - "idlType": "unrestricted double", + "idlType": { + "type": "const-type", + "idlType": "unrestricted double" + }, "name": "minusonedividedbyzero", "value": { "type": "Infinity", @@ -84,7 +105,10 @@ { "type": "const", "nullable": false, - "idlType": "short", + "idlType": { + "type": "const-type", + "idlType": "short" + }, "name": "notanumber", "value": { "type": "NaN" @@ -95,4 +119,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/constructor.json b/test/syntax/json/constructor.json index ee55ef03e144ab..292236f291bd9b 100644 --- a/test/syntax/json/constructor.json +++ b/test/syntax/json/constructor.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -43,6 +45,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -59,6 +62,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -85,6 +89,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/dictionary-inherits.json b/test/syntax/json/dictionary-inherits.json index ef30b1ab76d565..9b928f4f0a6f22 100644 --- a/test/syntax/json/dictionary-inherits.json +++ b/test/syntax/json/dictionary-inherits.json @@ -9,6 +9,7 @@ "name": "fillPattern", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": true, @@ -26,6 +27,7 @@ "name": "strokePattern", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": true, @@ -42,6 +44,7 @@ "name": "position", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -64,6 +67,7 @@ "name": "hydrometry", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -76,4 +80,4 @@ "inheritance": "PaintOptions", "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/dictionary.json b/test/syntax/json/dictionary.json index 28494ce437c7bb..f74fedc3d35b86 100644 --- a/test/syntax/json/dictionary.json +++ b/test/syntax/json/dictionary.json @@ -9,6 +9,7 @@ "name": "fillPattern", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": true, @@ -26,6 +27,7 @@ "name": "strokePattern", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": true, @@ -42,6 +44,7 @@ "name": "position", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -55,11 +58,13 @@ "name": "seq", "required": false, "idlType": { + "type": "dictionary-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -78,6 +83,7 @@ "name": "reqSeq", "required": true, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -100,6 +106,7 @@ "name": "h", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -113,6 +120,7 @@ "name": "d", "required": false, "idlType": { + "type": "dictionary-type", "sequence": false, "generic": null, "nullable": false, @@ -124,4 +132,4 @@ ], "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/documentation-dos.json b/test/syntax/json/documentation-dos.json index 340e039b4495d7..baa0b5a09b5ee1 100644 --- a/test/syntax/json/documentation-dos.json +++ b/test/syntax/json/documentation-dos.json @@ -7,4 +7,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/documentation.json b/test/syntax/json/documentation.json index 340e039b4495d7..baa0b5a09b5ee1 100644 --- a/test/syntax/json/documentation.json +++ b/test/syntax/json/documentation.json @@ -7,4 +7,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/enum.json b/test/syntax/json/enum.json index 88a608ba632232..29d1c865b68eab 100644 --- a/test/syntax/json/enum.json +++ b/test/syntax/json/enum.json @@ -3,9 +3,18 @@ "type": "enum", "name": "MealType", "values": [ - { "type": "string", "value": "rice" }, - { "type": "string", "value": "noodles" }, - { "type": "string", "value": "other" } + { + "type": "string", + "value": "rice" + }, + { + "type": "string", + "value": "noodles" + }, + { + "type": "string", + "value": "other" + } ], "extAttrs": [] }, @@ -21,6 +30,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -37,6 +47,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -54,6 +65,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -67,6 +79,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -80,6 +93,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -99,9 +113,18 @@ "type": "enum", "name": "AltMealType", "values": [ - { "type": "string", "value": "rice" }, - { "type": "string", "value": "noodles" }, - { "type": "string", "value": "other" } + { + "type": "string", + "value": "rice" + }, + { + "type": "string", + "value": "noodles" + }, + { + "type": "string", + "value": "other" + } ], "extAttrs": [] } diff --git a/test/syntax/json/equivalent-decl.json b/test/syntax/json/equivalent-decl.json index 7ef08bc595ffcf..de8d4dbc70ba8d 100644 --- a/test/syntax/json/equivalent-decl.json +++ b/test/syntax/json/equivalent-decl.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +63,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +77,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -86,6 +91,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -113,6 +119,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -130,6 +137,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -143,6 +151,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -162,6 +171,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -175,6 +185,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -188,6 +199,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -207,6 +219,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -220,6 +233,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -239,6 +253,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -252,6 +267,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -265,6 +281,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/extended-attributes.json b/test/syntax/json/extended-attributes.json index 6526e2a35997af..e0dc2360f3af08 100644 --- a/test/syntax/json/extended-attributes.json +++ b/test/syntax/json/extended-attributes.json @@ -30,139 +30,205 @@ ] }, { - "type": "interface", - "name": "IdInterface", - "partial": false, - "members": [], - "inheritance": null, - "extAttrs": [ - { - "name": "IntAttr", - "arguments": null, - "type": "extended-attribute", - "rhs": { - "type": "integer", - "value": "0" - } - }, - { - "name": "FloatAttr", - "arguments": null, - "type": "extended-attribute", - "rhs": { - "type": "float", - "value": "3.14" - } - }, - { - "name": "StringAttr", - "arguments": null, - "type": "extended-attribute", - "rhs": { - "type": "string", - "value": "\"abc\"" - } - } - ] + "type": "interface", + "name": "IdInterface", + "partial": false, + "members": [], + "inheritance": null, + "extAttrs": [ + { + "name": "IntAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": { + "type": "integer", + "value": "0" + } + }, + { + "name": "FloatAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": { + "type": "float", + "value": "3.14" + } + }, + { + "name": "StringAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": { + "type": "string", + "value": "\"abc\"" + } + } + ] }, { - "type": "interface", - "name": "Circle", - "partial": false, - "members": [ - { - "type": "attribute", - "static": false, - "stringifier": false, - "inherit": false, - "readonly": false, - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "double" - }, - "name": "r", - "extAttrs": [] - }, - { - "type": "attribute", - "static": false, - "stringifier": false, - "inherit": false, - "readonly": false, - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "double" - }, - "name": "cx", - "extAttrs": [] - }, - { - "type": "attribute", - "static": false, - "stringifier": false, - "inherit": false, - "readonly": false, - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "double" - }, - "name": "cy", - "extAttrs": [] - }, - { - "type": "attribute", - "static": false, - "stringifier": false, - "inherit": false, - "readonly": true, - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "double" - }, - "name": "circumference", - "extAttrs": [] - } - ], - "inheritance": null, - "extAttrs": [ - { - "name": "Constructor", - "arguments": null, - "type": "extended-attribute", - "rhs": null - }, - { - "name": "Constructor", - "arguments": [ + "type": "interface", + "name": "Circle", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "double" + }, + "name": "r", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "double" + }, + "name": "cx", + "extAttrs": [] + }, { - "optional": false, - "variadic": false, - "extAttrs": [], - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "double" - }, - "name": "radius" + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "double" + }, + "name": "cy", + "extAttrs": [] + }, + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": true, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "double" + }, + "name": "circumference", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Constructor", + "arguments": null, + "type": "extended-attribute", + "rhs": null + }, + { + "name": "Constructor", + "arguments": [ + { + "optional": false, + "variadic": false, + "extAttrs": [], + "idlType": { + "type": "argument-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "double" + }, + "name": "radius" + } + ], + "type": "extended-attribute", + "rhs": null + } + ] + }, + { + "type": "interface", + "name": "I", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": true, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "Node" + } + ], + "extAttrs": [ + { + "name": "XAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": null + } + ] + }, + "name": "attrib", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [ + { + "name": "Exposed", + "arguments": null, + "type": "extended-attribute", + "rhs": { + "type": "identifier", + "value": "Window" + } } - ], - "type": "extended-attribute", - "rhs": null - } - ] + ] } ] diff --git a/test/syntax/json/generic.json b/test/syntax/json/generic.json index 214ddd8e994872..62593859fb14ce 100644 --- a/test/syntax/json/generic.json +++ b/test/syntax/json/generic.json @@ -12,21 +12,25 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "Promise", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "ResponsePromise", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": true, @@ -47,11 +51,13 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": "Promise", "nullable": false, "union": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -79,11 +85,13 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "Promise", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": true, @@ -103,11 +111,13 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "Promise", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -136,11 +146,13 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "ResponsePromise", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/getter-setter.json b/test/syntax/json/getter-setter.json index 6268a532d55a24..1213307f20309b 100644 --- a/test/syntax/json/getter-setter.json +++ b/test/syntax/json/getter-setter.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +63,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +77,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -86,6 +91,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/identifier-qualified-names.json b/test/syntax/json/identifier-qualified-names.json index 11568f8cfd8cc3..f4e295acd3e120 100644 --- a/test/syntax/json/identifier-qualified-names.json +++ b/test/syntax/json/identifier-qualified-names.json @@ -2,6 +2,7 @@ { "type": "typedef", "idlType": { + "type": "typedef-type", "sequence": false, "generic": null, "nullable": false, @@ -24,6 +25,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -37,6 +39,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -56,6 +59,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -69,6 +73,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -96,6 +101,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -112,6 +118,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": true, @@ -138,6 +145,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -151,6 +159,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/implements.json b/test/syntax/json/implements.json index fba0542780818c..69879d94f553d5 100644 --- a/test/syntax/json/implements.json +++ b/test/syntax/json/implements.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -37,6 +38,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -50,6 +52,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -63,6 +66,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -76,6 +80,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/indexed-properties.json b/test/syntax/json/indexed-properties.json index 2676c0efab34a6..697b595546c788 100644 --- a/test/syntax/json/indexed-properties.json +++ b/test/syntax/json/indexed-properties.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +63,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +77,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -86,6 +91,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -105,6 +111,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -118,6 +125,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -137,6 +145,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -150,6 +159,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -169,6 +179,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -182,6 +193,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -195,6 +207,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -214,6 +227,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -227,6 +241,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/inherits-getter.json b/test/syntax/json/inherits-getter.json index ba6bafdf3913c9..818d8b6c16f824 100644 --- a/test/syntax/json/inherits-getter.json +++ b/test/syntax/json/inherits-getter.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -36,6 +37,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -52,6 +54,7 @@ "inherit": true, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -65,4 +68,4 @@ "inheritance": "Animal", "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/interface-inherits.json b/test/syntax/json/interface-inherits.json index e78c1cce865e4d..74a4c39bb0ffb1 100644 --- a/test/syntax/json/interface-inherits.json +++ b/test/syntax/json/interface-inherits.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -36,6 +37,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -61,6 +63,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -74,4 +77,4 @@ "inheritance": "Animal", "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/iterable.json b/test/syntax/json/iterable.json index 1e92307dad53ae..7126a4ea2b01b1 100644 --- a/test/syntax/json/iterable.json +++ b/test/syntax/json/iterable.json @@ -6,13 +6,16 @@ "members": [ { "type": "iterable", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long" - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long" + } + ], "extAttrs": [] } ], @@ -28,6 +31,7 @@ "type": "iterable", "idlType": [ { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -35,6 +39,7 @@ "idlType": "short" }, { + "type": null, "sequence": false, "generic": null, "nullable": true, @@ -55,21 +60,24 @@ "members": [ { "type": "iterable", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long", - "extAttrs": [ - { - "name": "XAttr", - "arguments": null, - "type": "extended-attribute", - "rhs": null - } - ] - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long", + "extAttrs": [ + { + "name": "XAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": null + } + ] + } + ], "extAttrs": [] } ], @@ -77,4 +85,3 @@ "extAttrs": [] } ] - diff --git a/test/syntax/json/legacyiterable.json b/test/syntax/json/legacyiterable.json index 059ccc11312fc6..5a1e526b50ae60 100644 --- a/test/syntax/json/legacyiterable.json +++ b/test/syntax/json/legacyiterable.json @@ -6,13 +6,16 @@ "members": [ { "type": "legacyiterable", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long" - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long" + } + ], "extAttrs": [] } ], @@ -20,4 +23,3 @@ "extAttrs": [] } ] - diff --git a/test/syntax/json/maplike.json b/test/syntax/json/maplike.json index 97e76d5841a24c..b86e10487c1b61 100644 --- a/test/syntax/json/maplike.json +++ b/test/syntax/json/maplike.json @@ -8,6 +8,7 @@ "type": "maplike", "idlType": [ { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -15,6 +16,7 @@ "idlType": "long" }, { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -38,6 +40,7 @@ "type": "maplike", "idlType": [ { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -45,6 +48,7 @@ "idlType": "long" }, { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -68,6 +72,7 @@ "type": "maplike", "idlType": [ { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -83,6 +88,7 @@ ] }, { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -106,4 +112,3 @@ "extAttrs": [] } ] - diff --git a/test/syntax/json/mixin.json b/test/syntax/json/mixin.json index a2afae318dcc13..f0458e2b0841ca 100644 --- a/test/syntax/json/mixin.json +++ b/test/syntax/json/mixin.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -47,6 +48,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/namedconstructor.json b/test/syntax/json/namedconstructor.json index cee163069d1850..f895461d15e0a5 100644 --- a/test/syntax/json/namedconstructor.json +++ b/test/syntax/json/namedconstructor.json @@ -23,6 +23,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -40,4 +41,4 @@ } ] } -] \ No newline at end of file +] diff --git a/test/syntax/json/namespace.json b/test/syntax/json/namespace.json index 8ee7796553ed9e..0611b710bf10d9 100644 --- a/test/syntax/json/namespace.json +++ b/test/syntax/json/namespace.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -54,6 +57,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +77,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -86,6 +91,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -99,6 +105,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/nointerfaceobject.json b/test/syntax/json/nointerfaceobject.json index 85987e82de3db4..03bb99442d5fe3 100644 --- a/test/syntax/json/nointerfaceobject.json +++ b/test/syntax/json/nointerfaceobject.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -25,6 +26,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/nullable.json b/test/syntax/json/nullable.json index 2c83c3dad58c67..ae4d2aa537594c 100644 --- a/test/syntax/json/nullable.json +++ b/test/syntax/json/nullable.json @@ -7,7 +7,10 @@ { "type": "const", "nullable": true, - "idlType": "boolean", + "idlType": { + "type": "const-type", + "idlType": "boolean" + }, "name": "ARE_WE_THERE_YET", "value": { "type": "boolean", @@ -31,6 +34,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": true, @@ -44,4 +48,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/nullableobjects.json b/test/syntax/json/nullableobjects.json index 2c875607262007..29d1314f168651 100644 --- a/test/syntax/json/nullableobjects.json +++ b/test/syntax/json/nullableobjects.json @@ -28,6 +28,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +42,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": true, @@ -60,6 +62,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +76,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": true, diff --git a/test/syntax/json/operation-optional-arg.json b/test/syntax/json/operation-optional-arg.json index 7588d63475f8f6..44c3a16dc2ee1a 100644 --- a/test/syntax/json/operation-optional-arg.json +++ b/test/syntax/json/operation-optional-arg.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -25,6 +26,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -38,6 +40,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -51,6 +54,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -64,6 +68,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/overloading.json b/test/syntax/json/overloading.json index 8d7e8e286cbfdc..87169e9202ba40 100644 --- a/test/syntax/json/overloading.json +++ b/test/syntax/json/overloading.json @@ -28,6 +28,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +42,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +62,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +76,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -101,6 +105,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -114,6 +119,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -133,6 +139,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -153,6 +160,7 @@ } ], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -166,6 +174,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -179,6 +188,7 @@ "variadic": true, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -198,6 +208,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -216,6 +227,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -229,6 +241,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -242,6 +255,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -255,6 +269,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -268,6 +283,7 @@ "variadic": true, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/overridebuiltins.json b/test/syntax/json/overridebuiltins.json index 4ded17c3103772..d63f8f744113ee 100644 --- a/test/syntax/json/overridebuiltins.json +++ b/test/syntax/json/overridebuiltins.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/partial-interface.json b/test/syntax/json/partial-interface.json index e95af2baa1548b..c16c64d334dfc4 100644 --- a/test/syntax/json/partial-interface.json +++ b/test/syntax/json/partial-interface.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -36,6 +37,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -48,4 +50,4 @@ ], "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/primitives.json b/test/syntax/json/primitives.json index 7568542f95762f..cf965399a4ff3e 100644 --- a/test/syntax/json/primitives.json +++ b/test/syntax/json/primitives.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -43,6 +45,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -59,6 +62,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -75,6 +79,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -91,6 +96,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -107,6 +113,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -123,6 +130,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -139,6 +147,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -155,6 +164,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -171,6 +181,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -187,6 +198,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -203,6 +215,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -219,6 +232,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -235,6 +249,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -251,6 +266,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -267,6 +283,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -280,4 +297,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/prototyperoot.json b/test/syntax/json/prototyperoot.json index c75f00ed3e84f2..eda7f14dae4c5d 100644 --- a/test/syntax/json/prototyperoot.json +++ b/test/syntax/json/prototyperoot.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/putforwards.json b/test/syntax/json/putforwards.json index 1b0a7b6b9743f0..4b809d2d34dcb5 100644 --- a/test/syntax/json/putforwards.json +++ b/test/syntax/json/putforwards.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -37,6 +38,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -50,4 +52,4 @@ "inheritance": null, "extAttrs": [] } -] \ No newline at end of file +] diff --git a/test/syntax/json/record.json b/test/syntax/json/record.json index 339ae08a39f38b..dd00b5df045e5c 100644 --- a/test/syntax/json/record.json +++ b/test/syntax/json/record.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -25,17 +26,20 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "argument-type", "sequence": false, "generic": "record", "nullable": false, "union": false, "idlType": [ { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -43,6 +47,7 @@ "idlType": "ByteString" }, { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -65,12 +70,14 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "record", "nullable": false, "union": false, "idlType": [ { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -78,12 +85,14 @@ "idlType": "DOMString" }, { + "type": "return-type", "sequence": false, "generic": null, "nullable": true, "union": true, "idlType": [ { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -91,6 +100,7 @@ "idlType": "float" }, { + "type": null, "sequence": false, "generic": null, "nullable": false, @@ -113,6 +123,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -134,12 +145,14 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": "record", "nullable": false, "union": false, "idlType": [ { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -147,6 +160,7 @@ "idlType": "USVString" }, { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -176,12 +190,14 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": "record", "nullable": false, "union": false, "idlType": [ { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -189,6 +205,7 @@ "idlType": "DOMString" }, { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/reg-operations.json b/test/syntax/json/reg-operations.json index c1c13c74f1baac..d696e907e0c663 100644 --- a/test/syntax/json/reg-operations.json +++ b/test/syntax/json/reg-operations.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -53,6 +55,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -71,6 +74,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -84,6 +88,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -103,6 +108,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -116,6 +122,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -129,6 +136,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/replaceable.json b/test/syntax/json/replaceable.json index f53009b4baa42b..a10b0bfd03b022 100644 --- a/test/syntax/json/replaceable.json +++ b/test/syntax/json/replaceable.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -35,6 +36,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/sequence.json b/test/syntax/json/sequence.json index 79821181a19a52..c2d1765bfa506d 100644 --- a/test/syntax/json/sequence.json +++ b/test/syntax/json/sequence.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -25,11 +26,13 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -50,11 +53,13 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -75,7 +80,6 @@ "name": "Foo", "partial": false, "members": [ - { "type": "operation", "getter": false, @@ -84,6 +88,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -98,7 +103,6 @@ "inheritance": null, "extAttrs": [] }, - { "type": "interface", "name": "I", @@ -112,6 +116,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -125,11 +130,13 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/setlike.json b/test/syntax/json/setlike.json index 3c1591b2372256..12299a7ee0444a 100644 --- a/test/syntax/json/setlike.json +++ b/test/syntax/json/setlike.json @@ -6,13 +6,16 @@ "members": [ { "type": "setlike", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long" - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long" + } + ], "readonly": false, "extAttrs": [] } @@ -27,13 +30,16 @@ "members": [ { "type": "setlike", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long" - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long" + } + ], "readonly": true, "extAttrs": [] } @@ -48,21 +54,24 @@ "members": [ { "type": "setlike", - "idlType": { - "sequence": false, - "generic": null, - "nullable": false, - "union": false, - "idlType": "long", - "extAttrs": [ - { - "name": "XAttr", - "arguments": null, - "type": "extended-attribute", - "rhs": null - } - ] - }, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long", + "extAttrs": [ + { + "name": "XAttr", + "arguments": null, + "type": "extended-attribute", + "rhs": null + } + ] + } + ], "readonly": false, "extAttrs": [] } @@ -71,4 +80,3 @@ "extAttrs": [] } ] - diff --git a/test/syntax/json/static.json b/test/syntax/json/static.json index 034ffda2d5450c..0951b2acf5ff99 100644 --- a/test/syntax/json/static.json +++ b/test/syntax/json/static.json @@ -19,6 +19,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -35,6 +36,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -51,6 +53,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -67,6 +70,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -84,6 +88,7 @@ "static": true, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -97,6 +102,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -110,6 +116,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -123,6 +130,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/stringifier-attribute.json b/test/syntax/json/stringifier-attribute.json index acb26c2dda8879..36e2b6d50ac064 100644 --- a/test/syntax/json/stringifier-attribute.json +++ b/test/syntax/json/stringifier-attribute.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/stringifier-custom.json b/test/syntax/json/stringifier-custom.json index 3c84305d863847..3dc3ac1758c8a2 100644 --- a/test/syntax/json/stringifier-custom.json +++ b/test/syntax/json/stringifier-custom.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": true, @@ -43,6 +45,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +63,7 @@ "static": false, "stringifier": true, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/stringifier.json b/test/syntax/json/stringifier.json index 6b2d133d96f185..1a702765b0a656 100644 --- a/test/syntax/json/stringifier.json +++ b/test/syntax/json/stringifier.json @@ -12,6 +12,7 @@ "static": false, "stringifier": true, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/treatasnull.json b/test/syntax/json/treatasnull.json index 03dec604fb44f6..611d9741043947 100644 --- a/test/syntax/json/treatasnull.json +++ b/test/syntax/json/treatasnull.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -44,6 +46,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -67,6 +70,7 @@ } ], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/treatasundefined.json b/test/syntax/json/treatasundefined.json index 8699b73c8f2db2..258acdabd8593d 100644 --- a/test/syntax/json/treatasundefined.json +++ b/test/syntax/json/treatasundefined.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -44,6 +46,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -67,6 +70,7 @@ } ], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/typedef-union.json b/test/syntax/json/typedef-union.json index 9c87672c8aebb1..06735a80791006 100644 --- a/test/syntax/json/typedef-union.json +++ b/test/syntax/json/typedef-union.json @@ -1,49 +1,48 @@ [ - { - "type" : "typedef", - "idlType" : { - "nullable" : false, - "generic" : null, - "union" : true, - "idlType" : [ - { - "union" : false, - "generic" : null, - "nullable" : false, - "array" : false, - "sequence" : false, - "idlType" : "ImageData" - }, - { - "generic" : null, - "union" : false, - "nullable" : false, - "array" : false, - "idlType" : "HTMLImageElement", - "sequence" : false - }, - { - "array" : false, - "sequence" : false, - "idlType" : "HTMLCanvasElement", - "generic" : null, - "union" : false, - "nullable" : false - }, - { - "union" : false, - "generic" : null, - "nullable" : false, - "array" : false, - "sequence" : false, - "idlType" : "HTMLVideoElement" - } - ], - "sequence" : false, - "array" : false - }, - "name" : "TexImageSource", - "extAttrs" : [], - "typeExtAttrs" : [] - } + { + "type": "typedef", + "idlType": { + "type": "typedef-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": true, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "ImageData" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "HTMLImageElement" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "HTMLCanvasElement" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "HTMLVideoElement" + } + ] + }, + "name": "TexImageSource", + "extAttrs": [] + } ] diff --git a/test/syntax/json/typedef.json b/test/syntax/json/typedef.json index 612cfe727d91aa..5e9715da8fb2a7 100644 --- a/test/syntax/json/typedef.json +++ b/test/syntax/json/typedef.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -27,6 +28,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -43,11 +45,13 @@ { "type": "typedef", "idlType": { + "type": "typedef-type", "sequence": true, "generic": "sequence", "nullable": false, "union": false, "idlType": { + "type": "typedef-type", "sequence": false, "generic": null, "nullable": false, @@ -70,6 +74,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -86,6 +91,7 @@ "inherit": false, "readonly": false, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -111,6 +117,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -128,6 +135,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -141,6 +149,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -160,6 +169,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -173,6 +183,7 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -191,6 +202,7 @@ { "type": "typedef", "idlType": { + "type": "typedef-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/syntax/json/typesuffixes.json b/test/syntax/json/typesuffixes.json index 0b30830a158db8..be0b1f226827d0 100644 --- a/test/syntax/json/typesuffixes.json +++ b/test/syntax/json/typesuffixes.json @@ -12,6 +12,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -25,11 +26,13 @@ "variadic": false, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": true, "generic": "sequence", "nullable": true, "union": false, "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": true, diff --git a/test/syntax/json/uniontype.json b/test/syntax/json/uniontype.json index c4725d417b5378..87735c7fb6320d 100644 --- a/test/syntax/json/uniontype.json +++ b/test/syntax/json/uniontype.json @@ -1,118 +1,129 @@ [ - { - "partial": false, - "members": [ - { - "idlType": { - "idlType": [ - { - "union": false, - "sequence": false, - "generic": null, - "idlType": "float", - "nullable": false - }, - { - "idlType": [ + { + "type": "interface", + "name": "Union", + "partial": false, + "members": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": true, + "idlType": [ { - "nullable": false, - "idlType": "Date", - "sequence": false, - "generic": null, - "union": false + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "float" }, { - "nullable": false, - "idlType": "Event", - "generic": null, - "sequence": false, - "union": false - } - ], - "nullable": false, - "sequence": false, - "generic": null, - "union": true - }, - { - "generic": null, - "sequence": false, - "idlType": [ - { - "union": false, - "sequence": false, - "generic": null, - "nullable": false, - "idlType": "Node" + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": true, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "Date" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "Event" + } + ] }, { - "nullable": false, - "idlType": "DOMString", - "sequence": false, - "generic": null, - "union": false + "type": null, + "sequence": false, + "generic": null, + "nullable": true, + "union": true, + "idlType": [ + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "Node" + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "DOMString" + } + ] } - ], - "nullable": true, - "union": true - } - ], - "nullable": false, - "generic": null, - "sequence": false, - "union": true + ] + }, + "name": "test", + "extAttrs": [] }, - "name": "test", - "inherit": false, - "type": "attribute", - "extAttrs": [], - "readonly": false, - "stringifier": false, - "static": false - }, - { - "readonly": false, - "extAttrs": [], - "stringifier": false, - "static": false, - "name": "test2", - "idlType": { - "nullable": false, - "idlType": [ - { - "extAttrs": [ + { + "type": "attribute", + "static": false, + "stringifier": false, + "inherit": false, + "readonly": false, + "idlType": { + "type": "attribute-type", + "sequence": false, + "generic": null, + "nullable": false, + "union": true, + "idlType": [ { - "name": "EnforceRange", - "arguments": null, - "type": "extended-attribute", - "rhs": null + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "long", + "extAttrs": [ + { + "name": "EnforceRange", + "arguments": null, + "type": "extended-attribute", + "rhs": null + } + ] + }, + { + "type": null, + "sequence": false, + "generic": null, + "nullable": false, + "union": false, + "idlType": "Date" } - ], - "nullable": false, - "idlType": "long", - "generic": null, - "sequence": false, - "union": false - }, - { - "union": false, - "sequence": false, - "generic": null, - "idlType": "Date", - "nullable": false - } - ], - "generic": null, - "sequence": false, - "union": true - }, - "inherit": false, - "type": "attribute" - } - ], - "inheritance": null, - "name": "Union", - "extAttrs": [], - "type": "interface" - } + ] + }, + "name": "test2", + "extAttrs": [] + } + ], + "inheritance": null, + "extAttrs": [] + } ] diff --git a/test/syntax/json/variadic-operations.json b/test/syntax/json/variadic-operations.json index a9560da9ddd875..53b02dfb4ccb57 100644 --- a/test/syntax/json/variadic-operations.json +++ b/test/syntax/json/variadic-operations.json @@ -11,6 +11,7 @@ "inherit": false, "readonly": true, "idlType": { + "type": "attribute-type", "sequence": false, "generic": null, "nullable": false, @@ -28,6 +29,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -41,6 +43,7 @@ "variadic": true, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, @@ -60,6 +63,7 @@ "static": false, "stringifier": false, "idlType": { + "type": "return-type", "sequence": false, "generic": null, "nullable": false, @@ -73,6 +77,7 @@ "variadic": true, "extAttrs": [], "idlType": { + "type": "argument-type", "sequence": false, "generic": null, "nullable": false, diff --git a/test/util/acquire.js b/test/util/acquire.js new file mode 100644 index 00000000000000..6f37dd6083c3c7 --- /dev/null +++ b/test/util/acquire.js @@ -0,0 +1,8 @@ +"use strict"; + +const { collect } = require("./collect"); +const fs = require("fs"); + +for (const test of collect("syntax")) { + fs.writeFileSync(test.jsonPath, `${JSON.stringify(test.ast, null, 4)}\n`) +} diff --git a/test/util/collect.js b/test/util/collect.js new file mode 100644 index 00000000000000..7e3d9d3bf31267 --- /dev/null +++ b/test/util/collect.js @@ -0,0 +1,59 @@ +"use strict"; + +const wp = require("../../lib/webidl2"); +const pth = require("path"); +const fs = require("fs"); +const jdp = require("jsondiffpatch"); + +/** + * Collects test items from the specified directory + * @param {string} base + */ +function* collect(base, { expectError } = {}) { + base = pth.join(__dirname, "..", base); + const dir = pth.join(base, "idl"); + const idls = fs.readdirSync(dir) + .filter(it => (/\.widl$/).test(it)) + .map(it => pth.join(dir, it)); + + for (const path of idls) { + const optFile = pth.join(base, "opt", pth.basename(path)).replace(".widl", ".json"); + let opt; + if (fs.existsSync(optFile)) + opt = JSON.parse(fs.readFileSync(optFile, "utf8")); + + try { + const ast = wp.parse(fs.readFileSync(path, "utf8").replace(/\r\n/g, "\n"), opt); + yield new TestItem({ ast, path, opt }); + } + catch (error) { + if (expectError) { + yield new TestItem({ path, error }); + } + else { + throw error; + } + } + } +}; + + +class TestItem { + constructor({ ast, path, error, opt }) { + this.ast = ast; + this.path = path; + this.error = error; + this.opt = opt; + this.jsonPath = pth.join(pth.dirname(path), "../json", pth.basename(path).replace(".widl", ".json")); + } + + readJSON() { + return JSON.parse(fs.readFileSync(this.jsonPath, "utf8")); + } + + diff(target = this.readJSON()) { + return jdp.diff(target, this.ast); + } +} + +module.exports.collect = collect; diff --git a/test/writer.js b/test/writer.js new file mode 100644 index 00000000000000..e84076b4f28ce3 --- /dev/null +++ b/test/writer.js @@ -0,0 +1,23 @@ +"use strict"; + +const { collect } = require("./util/collect"); +const wp = require("../lib/webidl2"); +const writer = require("../lib/writer"); +const expect = require("expect"); +const debug = true; + +describe("Rewrite and parses all of the IDLs to produce the same ASTs", () => { + for (const test of collect("syntax")) { + it(`should produce the same AST for ${test.path}`, () => { + try { + const diff = test.diff(wp.parse(writer.write(test.ast), test.opt)); + if (diff && debug) console.log(JSON.stringify(diff, null, 4)); + expect(diff).toBe(undefined); + } + catch (e) { + console.log(e.toString()); + throw e; + } + }); + } +});