From cce39b0794279440bbd3d5e39a328f634d564384 Mon Sep 17 00:00:00 2001 From: Bronley Date: Wed, 23 Jun 2021 22:44:44 -0400 Subject: [PATCH] Add script to sync xml syntax from vscode repo --- package.json | 16 ++++---- scripts/sync-scenegraph-tmlanguage.js | 17 +++++++++ syntaxes/scenegraph.tmLanguage.json | 53 +++++++++++++++++++-------- 3 files changed, 64 insertions(+), 22 deletions(-) create mode 100644 scripts/sync-scenegraph-tmlanguage.js diff --git a/package.json b/package.json index 1cd56f24..f1756f9e 100644 --- a/package.json +++ b/package.json @@ -41,13 +41,14 @@ "clean": "rimraf dist", "install-local": "node scripts/install-local.js", "install-pull-local": "node scripts/install-local.js --pull", - "uninstall-local": "node scripts/uninstall-local.js" + "uninstall-local": "node scripts/uninstall-local.js", + "sync-syntaxes": "node scripts/sync-scenegraph-tmlanguage.js" }, "dependencies": { "array-sort": "^1.0.0", "backoff": "^2.5.0", - "brighterscript": "^0.39.3", - "brighterscript-formatter": "^1.6.0", + "brighterscript": "file:../brighterscript", + "brighterscript-formatter": "file:../brighterscript-formatter", "debounce": "^1.2.0", "dotenv": "^6.2.0", "eol": "^0.9.1", @@ -70,13 +71,13 @@ "q": "^1.5.1", "replace-in-file": "^4.1.0", "replace-last": "^1.2.6", - "roku-debug": "^0.8.3", - "roku-deploy": "^3.4.1", + "roku-debug": "file:../roku-debug", + "roku-deploy": "file:../roku-deploy", "semver": "^7.1.3", "serialize-error": "^5.0.0", "source-map": "^0.7.3", - "vscode-debugadapter": "1.33.0", - "vscode-debugprotocol": "1.33.0", + "vscode-debugadapter": "^1.47.0", + "vscode-debugprotocol": "^1.47.0", "vscode-languageclient": "^7.0.0", "vscode-languageserver": "^4.1.3", "vscode-uri": "^1.0.6" @@ -101,6 +102,7 @@ "mocha": "^8.3.2", "mocha-param": "^2.0.0", "mock-fs": "^4.10.3", + "node-fetch": "^2.6.1", "nyc": "^15.0.0", "ovsx": "0.1.0-next.e000fdb", "rimraf": "^3.0.0", diff --git a/scripts/sync-scenegraph-tmlanguage.js b/scripts/sync-scenegraph-tmlanguage.js new file mode 100644 index 00000000..6c43b93d --- /dev/null +++ b/scripts/sync-scenegraph-tmlanguage.js @@ -0,0 +1,17 @@ +const fetch = require('node-fetch'); +var fsExtra = require('fs-extra'); +(async () => { + const json = await (await fetch('https://raw.githubusercontent.com/microsoft/vscode/main/extensions/xml/syntaxes/xml.tmLanguage.json')).json() + json.scopeName = 'scenegraph.xml'; + json.name = 'scenegraph'; + json.fileTypes = ['xml']; + delete json.information_for_contributors; + delete json.version; + //find the CDATA pattern + var pattern = json.patterns.find(x => x.name === 'string.unquoted.cdata.xml'); + pattern.name = 'source.brighterscript.embedded.scenegraph'; + pattern.patterns = [{ + include: "source.brs" + }]; + fsExtra.outputFileSync(`${__dirname}/../syntaxes/scenegraph.tmLanguage.json`, JSON.stringify(json, null, 4)); +})().catch(e => console.error(e)); diff --git a/syntaxes/scenegraph.tmLanguage.json b/syntaxes/scenegraph.tmLanguage.json index 53b57d97..67f5c122 100644 --- a/syntaxes/scenegraph.tmLanguage.json +++ b/syntaxes/scenegraph.tmLanguage.json @@ -1,9 +1,6 @@ { - "scopeName": "scenegraph.xml", "name": "scenegraph", - "fileTypes": [ - "xml" - ], + "scopeName": "scenegraph.xml", "patterns": [ { "begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)", @@ -191,7 +188,7 @@ "name": "punctuation.definition.string.end.xml" } }, - "name": "source.brighterscript.embedded.xml", + "name": "source.brighterscript.embedded.scenegraph", "patterns": [ { "include": "source.brs" @@ -341,7 +338,7 @@ "name": "entity.other.attribute-name.localname.xml" } }, - "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)=" + "match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*=" }, { "include": "#doublequotedString" @@ -352,15 +349,41 @@ ] }, "comments": { - "begin": "<[!%]--", - "captures": { - "0": { - "name": "punctuation.definition.comment.xml" + "patterns": [ + { + "begin": "<%--", + "captures": { + "0": { + "name": "punctuation.definition.comment.xml" + }, + "end": "--%>", + "name": "comment.block.xml" + } + }, + { + "begin": "", + "name": "comment.block.xml", + "patterns": [ + { + "begin": "--(?!>)", + "captures": { + "0": { + "name": "invalid.illegal.bad-comments-or-CDATA.xml" + } + } + } + ] } - }, - "end": "--%?>", - "name": "comment.block.xml" + ] } }, - "version": "https://github.com/atom/language-xml/commit/f461d428fb87040cb8a52d87d0b95151b9d3c0cc" -} + "fileTypes": [ + "xml" + ] +} \ No newline at end of file