Switch to plist format for textmate grammar
This commit is contained in:
Родитель
a710be4a43
Коммит
48f2db5440
|
@ -5,7 +5,7 @@
|
|||
**/*
|
||||
|
||||
# Then explicitly include what we want to ship in VSIX
|
||||
!dist/**/*.json
|
||||
!dist/**/*.tmLanguage
|
||||
!dist/**/*.js
|
||||
!dist/**/*.js.map
|
||||
!extension-shim.js
|
||||
|
|
|
@ -320,9 +320,8 @@ const grammar: Grammar = {
|
|||
};
|
||||
|
||||
async function main() {
|
||||
const filePath = "./dist/adl.tmlanguage.json";
|
||||
const json = await tm.emitJSON(grammar);
|
||||
await fs.writeFile(filePath, json);
|
||||
const plist = await tm.emitPList(grammar);
|
||||
await fs.writeFile("./dist/adl.tmLanguage", plist);
|
||||
}
|
||||
|
||||
main().catch((err) => {
|
||||
|
|
|
@ -38,11 +38,11 @@
|
|||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"@azure-tools/tmlanguage-generator": "0.1.2",
|
||||
"@rollup/plugin-commonjs": "^17.1.0",
|
||||
"@rollup/plugin-node-resolve": "^11.2.0",
|
||||
"@types/node": "14.0.27",
|
||||
"@types/vscode": "^1.53.0",
|
||||
"@azure-tools/tmlanguage-generator": "0.1.2",
|
||||
"rollup": "^2.41.4",
|
||||
"typescript": "~4.1.5",
|
||||
"vsce": "^1.85.1",
|
||||
|
@ -79,7 +79,7 @@
|
|||
{
|
||||
"language": "adl",
|
||||
"scopeName": "source.adl",
|
||||
"path": "./dist/adl.tmlanguage.json"
|
||||
"path": "./dist/adl.tmLanguage"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import { loadWASM, OnigRegExp } from "onigasm";
|
||||
import { readFile } from "fs/promises";
|
||||
import { dirname, resolve } from "path";
|
||||
import plist from "plist";
|
||||
|
||||
export const schema =
|
||||
"https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json";
|
||||
|
@ -79,15 +80,26 @@ async function initialize() {
|
|||
export async function emitJSON(grammar: Grammar): Promise<string> {
|
||||
await initialize();
|
||||
const indent = 2;
|
||||
const processed = processGrammar(grammar);
|
||||
const processed = await processGrammar(grammar);
|
||||
return JSON.stringify(processed, undefined, indent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the grammar from our more convenient representation to the
|
||||
* tmlanguage.json schema. Perform some validation in the process.
|
||||
* Emit the given grammar to PList XML
|
||||
*/
|
||||
function processGrammar(grammar: Grammar): any {
|
||||
export async function emitPList(grammar: Grammar): Promise<string> {
|
||||
await initialize();
|
||||
const processed = await processGrammar(grammar);
|
||||
return plist.build(processed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert the grammar from our more convenient representation to the
|
||||
* tmlanguage schema. Perform some validation in the process.
|
||||
*/
|
||||
async function processGrammar(grammar: Grammar): Promise<any> {
|
||||
await initialize();
|
||||
|
||||
// key is rule.key, value is [unprocessed rule, processed rule]. unprocessed
|
||||
// rule is used for its identity to check for duplicates and deal with cycles.
|
||||
const repository = new Map<string, [Rule, any]>();
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
"name": "@azure-tools/tmlanguage-generator",
|
||||
"version": "0.1.2",
|
||||
"author": "Microsoft Corporation",
|
||||
"description": "Helper library to generate TextMate syntax highlighting tmlanguage files.",
|
||||
"description": "Helper library to generate TextMate syntax highlighting tmLanguage files.",
|
||||
"homepage": "https://github.com/Azure/adl/tree/master/packages/tmlanguage-generator",
|
||||
"readme": "https://github.com/Azure/adl/blob/master/packages/tmlanguage-generator/README.md",
|
||||
"keywords": [
|
||||
|
@ -32,9 +32,11 @@
|
|||
"dist/**"
|
||||
],
|
||||
"dependencies": {
|
||||
"onigasm": "~2.2.5"
|
||||
"onigasm": "^2.2.5",
|
||||
"plist": "^3.0.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "14.0.27"
|
||||
"@types/node": "14.0.27",
|
||||
"@types/plist": "^3.0.2"
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче