Skip to content

Commit

Permalink
Add script to sync xml syntax from vscode repo
Browse files Browse the repository at this point in the history
  • Loading branch information
TwitchBronBron committed Oct 28, 2021
1 parent 48f128b commit cce39b0
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 22 deletions.
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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"
Expand All @@ -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",
Expand Down
17 changes: 17 additions & 0 deletions scripts/sync-scenegraph-tmlanguage.js
Original file line number Diff line number Diff line change
@@ -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));
53 changes: 38 additions & 15 deletions syntaxes/scenegraph.tmLanguage.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
{
"scopeName": "scenegraph.xml",
"name": "scenegraph",
"fileTypes": [
"xml"
],
"scopeName": "scenegraph.xml",
"patterns": [
{
"begin": "(<\\?)\\s*([-_a-zA-Z0-9]+)",
Expand Down Expand Up @@ -191,7 +188,7 @@
"name": "punctuation.definition.string.end.xml"
}
},
"name": "source.brighterscript.embedded.xml",
"name": "source.brighterscript.embedded.scenegraph",
"patterns": [
{
"include": "source.brs"
Expand Down Expand Up @@ -341,7 +338,7 @@
"name": "entity.other.attribute-name.localname.xml"
}
},
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)="
"match": "(?:^|\\s+)(?:([-\\w.]+)((:)))?([-\\w.:]+)\\s*="
},
{
"include": "#doublequotedString"
Expand All @@ -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": "<!--",
"captures": {
"0": {
"name": "punctuation.definition.comment.xml"
}
},
"end": "-->",
"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"
]
}

0 comments on commit cce39b0

Please sign in to comment.