From 98125c4938a25351cb071122da8526f02c0c8631 Mon Sep 17 00:00:00 2001 From: Kagami Sascha Rosylight Date: Thu, 2 Nov 2017 17:12:40 +0900 Subject: [PATCH] BREAKING CHANGE: Drop support for implements statement --- README.md | 27 --- lib/webidl2.js | 26 --- lib/writer.js | 5 - test/{syntax => invalid}/idl/implements.widl | 0 test/invalid/json/implements.json | 4 + test/syntax/json/implements.json | 212 ------------------- 6 files changed, 4 insertions(+), 270 deletions(-) rename test/{syntax => invalid}/idl/implements.widl (100%) create mode 100644 test/invalid/json/implements.json delete mode 100644 test/syntax/json/implements.json diff --git a/README.md b/README.md index 4efac4b6..49e48b14 100644 --- a/README.md +++ b/README.md @@ -520,33 +520,6 @@ The fields are as follows: * `trivia`: A trivia object. * `extAttrs`: An [extended attributes](#extended-attributes) container. -### Implements - -An implements definition looks like this: - -```JS -{ - "type": "implements", - "target": "Node", - "implements": "EventTarget", - "trivia": { - "target": "\n\n ", - "implements": " ", - "mixin": " ", - "termination": "" - }, - "extAttrs": null -} -``` - -The fields are as follows: - -* `type`: Always "implements". -* `target`: The interface that implements another. -* `implements`: The interface that is being implemented by the target. -* `trivia`: A trivia object. The field `target` is for the base interface identifier, `implements` for the `implements` keyword, and `mixin` for the mixin identifier. -* `extAttrs`: An [extended attributes](#extended-attributes) container. - ### Includes An includes definition looks like this: diff --git a/lib/webidl2.js b/lib/webidl2.js index 92d07e5b..37ab2795 100644 --- a/lib/webidl2.js +++ b/lib/webidl2.js @@ -1100,31 +1100,6 @@ return ret; } - function implements_() { - const start_position = consume_position; - const target = consume(ID); - if (!target) return; - const trivia = { target: target.trivia }; - const implementsToken = consume("implements"); - if (implementsToken) { - trivia.implements = implementsToken.trivia; - const ret = { - type: "implements", - target: target.value - }; - const imp = consume(ID) || error("Incomplete implements statement"); - trivia.mixin = imp.trivia; - ret.implements = imp.value; - ret.trivia = trivia; - const termination = consume(";") || error("No terminating ; for implements statement"); - trivia.termination = termination.trivia; - return ret; - } else { - // rollback - unconsume(start_position); - } - } - function includes() { const start_position = consume_position; const target = consume(ID); @@ -1157,7 +1132,6 @@ dictionary() || enum_() || typedef() || - implements_() || includes() || namespace(); } diff --git a/lib/writer.js b/lib/writer.js index 77c3c083..a1a63acf 100644 --- a/lib/writer.js +++ b/lib/writer.js @@ -150,10 +150,6 @@ const ret = extended_attributes(it.extAttrs); return `${ret}${it.trivia.base}typedef${type(it.idlType)}${it.trivia.name}${it.name}${it.trivia.termination};`; } - function implements_(it) { - const ret = extended_attributes(it.extAttrs); - return `${ret}${it.trivia.target}${it.target}${it.trivia.implements}implements${it.trivia.mixin}${it.implements}${it.trivia.termination};`; - } function includes(it) { const ret = extended_attributes(it.extAttrs); return `${ret}${it.trivia.target}${it.target}${it.trivia.includes}includes${it.trivia.mixin}${it.includes}${it.trivia.termination};`; @@ -195,7 +191,6 @@ field, const: const_, typedef, - implements: implements_, includes, callback, enum: enum_, diff --git a/test/syntax/idl/implements.widl b/test/invalid/idl/implements.widl similarity index 100% rename from test/syntax/idl/implements.widl rename to test/invalid/idl/implements.widl diff --git a/test/invalid/json/implements.json b/test/invalid/json/implements.json new file mode 100644 index 00000000..6fc096ea --- /dev/null +++ b/test/invalid/json/implements.json @@ -0,0 +1,4 @@ +{ + "message": "Got an error during or right after parsing `interface EventTarget`: Unrecognised tokens", + "line": 14 +} diff --git a/test/syntax/json/implements.json b/test/syntax/json/implements.json deleted file mode 100644 index 62fd9fca..00000000 --- a/test/syntax/json/implements.json +++ /dev/null @@ -1,212 +0,0 @@ -[ - { - "type": "interface", - "name": "Node", - "partial": null, - "members": [ - { - "type": "attribute", - "static": null, - "stringifier": null, - "inherit": null, - "readonly": { - "trivia": "\n " - }, - "trivia": { - "base": " ", - "name": " ", - "termination": "" - }, - "idlType": { - "type": "attribute-type", - "generic": null, - "nullable": null, - "union": false, - "idlType": "unsigned short", - "baseName": "short", - "prefix": { - "value": "unsigned", - "trivia": " " - }, - "postfix": null, - "separator": null, - "extAttrs": null, - "trivia": { - "base": " " - } - }, - "name": "nodeType", - "escapedName": "nodeType", - "extAttrs": null - } - ], - "trivia": { - "base": "// Extracted from http://dev.w3.org/2006/webapi/WebIDL/ on 2011-05-06\n ", - "name": " ", - "open": " ", - "close": "\n // ...\n ", - "termination": "" - }, - "inheritance": null, - "extAttrs": null - }, - { - "type": "interface", - "name": "EventTarget", - "partial": null, - "members": [ - { - "type": "operation", - "getter": null, - "setter": null, - "deleter": null, - "static": null, - "stringifier": null, - "body": { - "idlType": { - "type": "return-type", - "generic": null, - "nullable": null, - "union": false, - "idlType": "void", - "baseName": "void", - "prefix": null, - "postfix": null, - "separator": null, - "extAttrs": null, - "trivia": { - "base": "\n " - } - }, - "trivia": { - "open": "", - "close": "" - }, - "name": { - "value": "addEventListener", - "escaped": "addEventListener", - "trivia": " " - }, - "arguments": [ - { - "optional": null, - "variadic": null, - "default": null, - "trivia": { - "name": " " - }, - "extAttrs": null, - "idlType": { - "type": "argument-type", - "generic": null, - "nullable": null, - "union": false, - "idlType": "DOMString", - "baseName": "DOMString", - "prefix": null, - "postfix": null, - "separator": null, - "extAttrs": null, - "trivia": { - "base": "" - } - }, - "name": "type", - "escapedName": "type", - "separator": { - "value": ",", - "trivia": "" - } - }, - { - "optional": null, - "variadic": null, - "default": null, - "trivia": { - "name": " " - }, - "extAttrs": null, - "idlType": { - "type": "argument-type", - "generic": null, - "nullable": null, - "union": false, - "idlType": "EventListener", - "baseName": "EventListener", - "prefix": null, - "postfix": null, - "separator": null, - "extAttrs": null, - "trivia": { - "base": "\n " - } - }, - "name": "listener", - "escapedName": "listener", - "separator": { - "value": ",", - "trivia": "" - } - }, - { - "optional": null, - "variadic": null, - "default": null, - "trivia": { - "name": " " - }, - "extAttrs": null, - "idlType": { - "type": "argument-type", - "generic": null, - "nullable": null, - "union": false, - "idlType": "boolean", - "baseName": "boolean", - "prefix": null, - "postfix": null, - "separator": null, - "extAttrs": null, - "trivia": { - "base": "\n " - } - }, - "name": "useCapture", - "escapedName": "useCapture", - "separator": null - } - ] - }, - "trivia": { - "termination": "" - }, - "extAttrs": null - } - ], - "trivia": { - "base": "\n\n ", - "name": " ", - "open": " ", - "close": "\n // ...\n ", - "termination": "" - }, - "inheritance": null, - "extAttrs": null - }, - { - "type": "implements", - "target": "Node", - "implements": "EventTarget", - "trivia": { - "target": "\n\n ", - "implements": " ", - "mixin": " ", - "termination": "" - }, - "extAttrs": null - }, - { - "type": "eof", - "trivia": "\n" - } -]