Skip to content

Commit 161427e

Browse files
author
Keen Yee Liau
authored
build: check in syntax files (#604)
This commit makes a few changes: 1. Check in syntax JSON files to syntaxes/lib 2. Fix lint errors in syntax TS source 3. Add CI check to make sure JSON files are in sync with TS source 4. Add a README
1 parent 9db9d60 commit 161427e

File tree

13 files changed

+385
-14
lines changed

13 files changed

+385
-14
lines changed

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
"compile:test": "tsc -b server/src/tests",
9797
"compile:integration": "tsc -b integration",
9898
"compile:syntaxes-test": "tsc -b syntaxes/test",
99-
"compile:syntaxes": "tsc -b syntaxes",
100-
"build:syntaxes": "yarn compile:syntaxes && node syntaxes/out/build.js",
99+
"build:syntaxes": "tsc -b syntaxes && node syntaxes/out/build.js",
101100
"format": "scripts/format.sh",
102101
"watch": "tsc -b -w",
103102
"postinstall": "vscode-install && cd client && yarn && cd ../server && yarn && cd ..",

scripts/build.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,9 @@ cp client/package.json client/yarn.lock dist/client
1919
# Copy files to server directory
2020
cp server/package.json server/yarn.lock server/README.md dist/server
2121
# Build and copy files to syntaxes directory
22-
node syntaxes/out/build.js
22+
yarn run build:syntaxes
2323
mkdir dist/syntaxes
24-
cp syntaxes/out/*.json dist/syntaxes
24+
cp syntaxes/inline-styles.json syntaxes/inline-template.json syntaxes/template.json dist/syntaxes
2525

2626
pushd dist
2727
yarn install --production --ignore-scripts

scripts/lint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ set -ex -o pipefail
55
yarn tslint --project client/tsconfig.json
66
yarn tslint --project server/tsconfig.json
77
yarn tslint --project server/src/tests/tsconfig.json
8+
yarn tslint --project syntaxes/tsconfig.json

scripts/test.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,7 @@ yarn run test:lsp
2020

2121
# Syntaxes tests
2222
yarn run test:syntaxes
23+
if [[ -n "$(git status --porcelain)" ]]; then
24+
echo 'Syntax files are out-of-sync with source. Please run "yarn run build:syntaxes".'
25+
exit 1
26+
fi

syntaxes/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
# Read This!
2+
3+
**The JSON files in this directory are not meant to be edited by hand.**
4+
5+
If you need to make modification, the respective files should be changed within the repository's [`syntaxes/src`](https://github.com/angular/vscode-ng-language-service/tree/master/syntaxes/src) directory.
6+
7+
Running `yarn build:syntaxes` will then appropriately update the files in this directory.
8+
19
# Syntaxes
210

311
This directory specifies

syntaxes/inline-styles.json

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"scopeName": "inline-styles.ng",
3+
"injectionSelector": "L:source.ts#meta.decorator.ts -comment",
4+
"patterns": [
5+
{
6+
"include": "#inlineStyles"
7+
}
8+
],
9+
"repository": {
10+
"inlineStyles": {
11+
"begin": "(styles)\\s*(:)",
12+
"beginCaptures": {
13+
"1": {
14+
"name": "meta.object-literal.key.ts"
15+
},
16+
"2": {
17+
"name": "meta.object-literal.key.ts punctuation.separator.key-value.ts"
18+
}
19+
},
20+
"end": "(?=,|})",
21+
"patterns": [
22+
{
23+
"include": "#tsParenExpression"
24+
},
25+
{
26+
"include": "#tsBracketExpression"
27+
}
28+
]
29+
},
30+
"tsParenExpression": {
31+
"begin": "\\G\\s*(\\()",
32+
"beginCaptures": {
33+
"1": {
34+
"name": "meta.brace.round.ts"
35+
}
36+
},
37+
"end": "\\)",
38+
"endCaptures": {
39+
"0": {
40+
"name": "meta.brace.round.ts"
41+
}
42+
},
43+
"patterns": [
44+
{
45+
"include": "$self"
46+
},
47+
{
48+
"include": "#tsBracketExpression"
49+
}
50+
]
51+
},
52+
"tsBracketExpression": {
53+
"begin": "\\G\\s*(\\[)",
54+
"beginCaptures": {
55+
"1": {
56+
"name": "meta.array.literal.ts meta.brace.square.ts"
57+
}
58+
},
59+
"end": "\\]",
60+
"endCaptures": {
61+
"0": {
62+
"name": "meta.array.literal.ts meta.brace.square.ts"
63+
}
64+
},
65+
"patterns": [
66+
{
67+
"include": "#style"
68+
}
69+
]
70+
},
71+
"style": {
72+
"begin": "\\s*([`|'|\"])",
73+
"beginCaptures": {
74+
"1": {
75+
"name": "string"
76+
}
77+
},
78+
"end": "\\1",
79+
"endCaptures": {
80+
"0": {
81+
"name": "string"
82+
}
83+
},
84+
"contentName": "source.css",
85+
"patterns": [
86+
{
87+
"include": "source.css"
88+
}
89+
]
90+
}
91+
}
92+
}

syntaxes/inline-template.json

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"scopeName": "inline-template.ng",
3+
"injectionSelector": "L:meta.decorator.ts -comment",
4+
"patterns": [
5+
{
6+
"include": "#inlineTemplate"
7+
}
8+
],
9+
"repository": {
10+
"inlineTemplate": {
11+
"begin": "(template)\\s*(:)",
12+
"beginCaptures": {
13+
"1": {
14+
"name": "meta.object-literal.key.ts"
15+
},
16+
"2": {
17+
"name": "meta.object-literal.key.ts punctuation.separator.key-value.ts"
18+
}
19+
},
20+
"end": "(?=,|})",
21+
"patterns": [
22+
{
23+
"include": "#tsParenExpression"
24+
},
25+
{
26+
"include": "#ngTemplate"
27+
}
28+
]
29+
},
30+
"tsParenExpression": {
31+
"begin": "\\G\\s*(\\()",
32+
"beginCaptures": {
33+
"1": {
34+
"name": "meta.brace.round.ts"
35+
}
36+
},
37+
"end": "\\)",
38+
"endCaptures": {
39+
"0": {
40+
"name": "meta.brace.round.ts"
41+
}
42+
},
43+
"patterns": [
44+
{
45+
"include": "#tsParenExpression"
46+
},
47+
{
48+
"include": "#ngTemplate"
49+
}
50+
]
51+
},
52+
"ngTemplate": {
53+
"begin": "\\G\\s*([`|'|\"])",
54+
"beginCaptures": {
55+
"1": {
56+
"name": "string"
57+
}
58+
},
59+
"end": "\\1",
60+
"endCaptures": {
61+
"0": {
62+
"name": "string"
63+
}
64+
},
65+
"contentName": "text.html",
66+
"patterns": [
67+
{
68+
"include": "text.html.derivative"
69+
},
70+
{
71+
"include": "template.ng"
72+
}
73+
]
74+
}
75+
}
76+
}

syntaxes/src/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ function build(grammar: GrammarDefinition, filename: string): void {
3737
const processedGrammar: JsonObject = processGrammar(grammar);
3838
const grammarContent: string = JSON.stringify(processedGrammar, null, ' ') + '\n';
3939

40-
fs.writeFile(`syntaxes/out/${filename}.json`, grammarContent, (error) => {
40+
fs.writeFile(`syntaxes/${filename}.json`, grammarContent, (error) => {
4141
if (error) throw error;
4242
});
4343
}

syntaxes/src/inline-styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ export const InlineStyles: GrammarDefinition = {
4848
patterns: [{include: 'source.css'}]
4949
}
5050
}
51-
}
51+
};

syntaxes/src/inline-template.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ export const InlineTemplate: GrammarDefinition = {
4040
patterns: [{include: 'text.html.derivative'}, {include: 'template.ng'}]
4141
}
4242
}
43-
}
43+
};

0 commit comments

Comments
 (0)