Skip to content

Commit 8a7b81c

Browse files
committed
build test grammar infra
Signed-off-by: Qingpeng Li <qingpeng9802@gmail.com>
1 parent 447b650 commit 8a7b81c

21 files changed

+2007
-1409
lines changed

.eslintrc.json

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"root": true,
88
"parser": "@typescript-eslint/parser",
99
"parserOptions": {
10-
"project": "./tsconfig.json",
10+
"project": ["tsconfig.json", "syntaxes/scripts/tsconfig.json"],
1111
"ecmaVersion": 2022,
1212
"sourceType": "module"
1313
},
@@ -48,6 +48,7 @@
4848
"eol-last": "warn",
4949
"one-var": [ "warn", "never" ],
5050
"new-parens": "warn",
51+
"template-curly-spacing": ["warn"],
5152
"prefer-const": "warn",
5253
"prefer-arrow-callback": "warn",
5354
"prefer-rest-params": "warn",
@@ -297,43 +298,50 @@
297298
"zones": [
298299
// layer 0
299300
{
300-
"target": "./src/web/common",
301-
"from": "./src/web",
302-
"message": "[layer 0] ./src/web/common"
301+
"target": "src/web/common",
302+
"from": "src/web",
303+
"message": "[layer 0] src/web/common"
303304
},
304305
{
305-
"target": "./src/web/doc",
306-
"from": "./src/web",
307-
"except": [ "./cl_data", "./common" ],
308-
"message": "[layer 0] ./src/web/doc"
306+
"target": "src/web/doc",
307+
"from": "src/web",
308+
"except": [ "cl_data", "common" ],
309+
"message": "[layer 0] src/web/doc"
309310
},
310311
{
311-
"target": "./src/web/collect_info",
312-
"from": "./src/web",
313-
"except": [ "./collect_info", "./common" ],
314-
"message": "[layer 0] ./src/web/collect_info"
312+
"target": "src/web/collect_info",
313+
"from": "src/web",
314+
"except": [ "collect_info", "common" ],
315+
"message": "[layer 0] src/web/collect_info"
315316
},
316317
// layer 1
317318
{
318-
"target": "./src/web/builders",
319-
"from": [ "./src/web/entry", "./src/web/extension.ts", "./src/web/provider_interface" ],
320-
"message": "[layer 1] ./src/web/builders"
319+
"target": "src/web/builders",
320+
"from": [ "src/web/entry", "src/web/extension.ts", "src/web/provider_interface" ],
321+
"message": "[layer 1] src/web/builders"
321322
},
322323
// layer 2
323324
{
324-
"target": "./src/web/provider_interface",
325-
"from": [ "./src/web/entry", "./src/web/extension.ts" ],
326-
"message": "[layer 2] ./src/web/provider_interface"
325+
"target": "src/web/provider_interface",
326+
"from": [ "src/web/entry", "src/web/extension.ts" ],
327+
"message": "[layer 2] src/web/provider_interface"
327328
},
328329
// layer 3
329330
{
330-
"target": "./src/web/entry",
331-
"from": "./src/web/extension.ts",
332-
"message": "[layer 3] ./src/web/entry"
331+
"target": "src/web/entry",
332+
"from": "src/web/extension.ts",
333+
"message": "[layer 3] src/web/entry"
333334
}
334335
]
335336
}
336-
]
337+
],
338+
339+
"node/no-unsupported-features/node-builtins": ["error", {
340+
"version": ">=20.8.0"
341+
}],
342+
"node/no-unpublished-import": ["error", {
343+
"allowModules": ["vscode-oniguruma", "vscode-textmate", "js-yaml"]
344+
}]
337345
},
338346

339347
"settings": {
@@ -350,6 +358,7 @@
350358
}
351359
},
352360
"ignorePatterns": [
353-
"**/*.d.ts"
361+
"**/*.d.ts",
362+
"syntaxes/scripts/gen_record.mjs"
354363
]
355364
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
name: Textmate-syntax related
3+
about: Bug or improvement of Textmate-syntax
4+
title: ''
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
<!-- Troubleshooting -->
11+
Please help confirm if it is a purely Textmate grammar issue:
12+
1. set `"commonLisp.StaticAnalysis.enabled": false` in this extension's built-in settings (under `Common Lisp` tab) or set `"editor.semanticHighlighting.enabled": false` in VS Code's settings.
13+
2. reload VS Code.
14+
3. check if you still see the bug and describe your findings.
15+
16+
- VS Code Version: *You can find it by* [*how-do-i-find-the-version*](https://code.visualstudio.com/docs/supporting/FAQ#_how-do-i-find-the-version)
17+
- Desktop Electron Version or Browser version: *You can find it by* [*how-do-i-find-the-version*](https://code.visualstudio.com/docs/supporting/FAQ#_how-do-i-find-the-version)
18+
- OS Version: *which OS and its version*
19+
20+
**Describe the bug**
21+
A clear and concise description of what the bug is.
22+
23+
**Code**
24+
```lsp
25+
;; Please include a code snippet that demonstrates the issue
26+
27+
```
28+
29+
**Current Behavior Screenshot**
30+
31+
32+
**Expected Behavior Screenshot**
33+

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ jobs:
5050
- name: build with esbuild
5151
run: npm run esbuildp
5252

53-
#test:
54-
# uses: ./.github/workflows/test.yml
53+
test:
54+
uses: ./.github/workflows/test.yml

.github/workflows/test.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,5 +34,8 @@ jobs:
3434
- name: Build Grammar from yaml to json
3535
run: npm run bg
3636

37-
- name: Run headless test
38-
run: xvfb-run -a npm test
37+
- name: Test Grammar
38+
run: npm run testg
39+
40+
#- name: Headless Test for the Web Extension
41+
# run: xvfb-run -a npm test

.github/workflows/vsce_publish.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ on:
1111

1212
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
1313
jobs:
14-
#test:
15-
# uses: ./.github/workflows/test.yml
14+
test:
15+
uses: ./.github/workflows/test.yml
1616

1717
publish:
1818
name: publish

.github/workflows/vsce_publish_pre.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ on:
88
required: true
99

1010
jobs:
11-
#test:
12-
# uses: ./.github/workflows/test.yml
11+
test:
12+
uses: ./.github/workflows/test.yml
1313

1414
publish_pre:
1515
name: publish pre-release

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ node_modules
55
*.vsix
66
*.log
77
.parcel-cache
8+
syntaxes/test/generated/*

.vscode/launch.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"!**/node_modules/**"
2323
],
2424
"outFiles": ["${workspaceFolder}/dist/web/**/*.js"],
25-
"skipFiles": ["<node_internals>/**"],
2625
//"preLaunchTask": "npm: esbuildc"
2726
},
2827
{
@@ -44,7 +43,6 @@
4443
"!**/node_modules/**"
4544
],
4645
"outFiles": ["${workspaceFolder}/dist/web/**/*.js"],
47-
"skipFiles": ["<node_internals>/**"],
4846
//"preLaunchTask": "npm: esbuildc"
4947
},
5048
{

CONTRIBUTING.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ Run `find ./src -name '*.ts' | xargs wc -l` to check the physical lines of code
109109
## Declarative Language Features
110110

111111
### Syntax Highlight
112-
We have two syntax files in `./syntaxes`, and we use `./scripts/build_grammar.mjs` to convert them into `json` format:
112+
#### Introduction
113+
We have two syntax files in `./syntaxes`, and we use `./syntaxes/scripts/build_grammar.mjs` to convert them into `json` format:
113114
- `commonlisp.yaml` is the main syntax of Common Lisp.
114115
- `cl_codeblock.yaml` is the [injection grammar](https://code.visualstudio.com/api/language-extensions/syntax-highlight-guide#injection-grammars) for Markdown.
115116

@@ -121,13 +122,21 @@ If you need to modify the syntax, here are some helpful materials:
121122
[regex101](https://regex101.com/),
122123
[Common Lisp HyperSpec](http://www.lispworks.com/documentation/HyperSpec/Front/).
123124

125+
#### Workflow
124126
Mastering the TextMate grammars is very difficult. If you are a beginner, you can try to start with a small work sample and then work on it incrementally.
125127
The recommended workflow is:
126128
1. `git add`
127129
2. construct a regex and verify the regex in [regex101](https://regex101.com/)
128130
3. add the regex to the syntax
129131
4. convert the syntax into `json` and test the syntax in real world
130132

133+
#### Maintain grammar health
134+
1. After you modified the grammar, run `npm run bg` to rebuild the grammar.
135+
2. Then, run `npm run testg` to test the grammar with the fixtures in `syntaxes/test/baselines`.
136+
> You may optionally run `npx tsc -p syntaxes/scripts/tsconfig.json` to generate `gen_record.mjs`.
137+
3. Check if it is the test result you expected. Run `npm run diff` to find the differences between the baselines and generated.
138+
4. If the changes are what you expect, run `npm run accept` to accept the new baselines.
139+
131140
### Snippet
132141
In `./snippets`.
133142
See [Snippet Guide](https://code.visualstudio.com/api/language-extensions/snippet-guide) and [creating-your-own-snippets](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).

0 commit comments

Comments
 (0)