Repository: w3c/webidl2.js (js)

Issue:
Remove implements statement support
I think "implements" has been dropped from the IDL spec... probably when "mixin" happened... 

Affected specs: https://github.com/heycam/webidl/issues/472




Pull request:
DO NOT MERGE YET: Drop support for implements statement
Fixes #98, but merge after specs remove the syntax.

Patch:
diff --git a/README.md b/README.md
index 4efac4b..49e48b1 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 92d07e5..37ab279 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 77c3c08..a1a63ac 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_,


Test patch:
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 0000000..6fc096e
--- /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 62fd9fc..0000000
--- 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"
-    }
-]