Skip to content

Commit 140963c

Browse files
committed
upgrade oniguruma/textmate dependency
1 parent 09500e0 commit 140963c

File tree

3 files changed

+55
-67
lines changed

3 files changed

+55
-67
lines changed

package-lock.json

Lines changed: 28 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,8 +1368,9 @@
13681368
"grammar": "js-yaml syntaxes/dml.yml > syntaxes/dml.json; js-yaml syntaxes/diet.yml > syntaxes/diet.json; js-yaml syntaxes/d.yml > syntaxes/d.json; js-yaml syntaxes/sdl.yml > syntaxes/sdl.json; mocha out/test/ci"
13691369
},
13701370
"dependencies": {
1371-
"@vscode/webview-ui-toolkit": "^0.9.0",
13721371
"@vscode/codicons": "^0.0.27",
1372+
"@vscode/webview-ui-toolkit": "^0.9.0",
1373+
"@xmldom/xmldom": "^0.8.3",
13731374
"adm-zip": "^0.5.9",
13741375
"async": "^3.2.2",
13751376
"axios": "^0.24.0",
@@ -1384,8 +1385,7 @@
13841385
"string-argv": "^0.3.1",
13851386
"vscode-languageclient": "^8.0.0-next.2",
13861387
"vscode-test-adapter-api": "^1.9.0",
1387-
"which": "^2.0.2",
1388-
"@xmldom/xmldom": "^0.8.3"
1388+
"which": "^2.0.2"
13891389
},
13901390
"devDependencies": {
13911391
"@types/expand-tilde": "^2.0.0",
@@ -1401,8 +1401,9 @@
14011401
"mocha": "^9.1.3",
14021402
"source-map-support": "^0.5.19",
14031403
"typescript": "^4.4.2",
1404+
"vscode-oniguruma": "^1.7.0",
14041405
"vscode-test": "^1.6.1",
1405-
"vscode-textmate": "^4.4.0"
1406+
"vscode-textmate": "^8.0.0"
14061407
},
14071408
"__metadata": {
14081409
"id": "bf217d41-312b-4d39-9536-82fd0d9c6f94",

src/test/ci/syntaxes.test.ts

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,37 @@
11
import * as assert from 'assert';
22
import * as vscode from 'vscode';
33
import * as fs from 'fs';
4-
import * as paths from 'path';
4+
import * as path from 'path';
55
import * as vsctm from 'vscode-textmate';
6+
import * as oniguruma from 'vscode-oniguruma';
67
import { suite, test } from 'mocha';
8+
import { IRawGrammar } from 'vscode-textmate/release/rawGrammar';
79

810
/**
911
* Resolves a package relative path (relative to root folder / package.json folder) to the actual path
10-
* @param path the package relative path to resolve to an actual path
12+
* @param pathStr the package relative path to resolve to an actual path
1113
*/
12-
function res(path: string): string {
13-
return paths.join(__dirname, "../../../", path);
14+
function res(pathStr: string): string {
15+
return path.join(__dirname, "../../../", pathStr);
1416
}
1517

16-
function readFile(path: string): Promise<Buffer> {
18+
const wasmBin = fs.readFileSync(res('node_modules/vscode-oniguruma/release/onig.wasm')).buffer;
19+
const vscodeOnigurumaLib = oniguruma.loadWASM(wasmBin).then(() => {
20+
return {
21+
createOnigScanner: function(patterns: any) { return new oniguruma.OnigScanner(patterns); },
22+
createOnigString: function(s: any) { return new oniguruma.OnigString(s); }
23+
};
24+
});
25+
26+
function readFile(pathStr: string): Promise<Buffer> {
1727
return new Promise((resolve, reject) => {
18-
fs.readFile(res(path), (error, data) => error ? reject(error) : resolve(data));
28+
fs.readFile(res(pathStr), (error, data) => error ? reject(error) : resolve(data));
1929
});
2030
}
2131

2232
const registry = new vsctm.Registry({
23-
loadGrammar: async (scopeName): Promise<vsctm.IRawGrammar | undefined | null> => {
33+
onigLib: vscodeOnigurumaLib,
34+
loadGrammar: async (scopeName): Promise<IRawGrammar | undefined | null> => {
2435
if (scopeName === 'source.diet') {
2536
const data = await readFile('syntaxes/diet.json');
2637
return vsctm.parseRawGrammar(data.toString(), 'syntaxes/diet.json');
@@ -60,7 +71,7 @@ function testSyntaxes(grammar: vsctm.IGrammar, folder: string, ext: string) {
6071

6172
let ruleStack = vsctm.INITIAL;
6273

63-
const text = await readFile(paths.join(folder, file));
74+
const text = await readFile(path.join(folder, file));
6475
const lines = text.toString().split(/\r?\n/g);
6576
const tokens = lines.map(line => grammar.tokenizeLine(line, ruleStack).tokens.map(a => {
6677
return {
@@ -71,9 +82,9 @@ function testSyntaxes(grammar: vsctm.IGrammar, folder: string, ext: string) {
7182
}));
7283

7384
const actual = tokens.map(line => JSON.stringify(line)).join("\n");
74-
fs.writeFileSync(res(paths.join(folder, file) + ".actual"), actual);
85+
fs.writeFileSync(res(path.join(folder, file) + ".actual"), actual);
7586

76-
const expectedText = await readFile(paths.join(folder, file) + ".expected");
87+
const expectedText = await readFile(path.join(folder, file) + ".expected");
7788
const expectedLines = expectedText.toString().split(/\r?\n/g);
7889
const expectedTokens = expectedLines.map(line => JSON.parse(line));
7990

@@ -113,4 +124,4 @@ suite("syntax tests", () => {
113124
return testSyntaxes(grammar, "src/test/ci/syntax/dml", ".dml");
114125
});
115126
});
116-
});
127+
});

0 commit comments

Comments
 (0)