Skip to content

Commit fdf8a61

Browse files
committed
[razor] update grammar (fixes microsoft#30084)
1 parent ad61de6 commit fdf8a61

2 files changed

Lines changed: 90 additions & 22 deletions

File tree

extensions/razor/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"vscode": "0.10.x"
77
},
88
"scripts": {
9-
"update-grammar": "node ../../build/npm/update-grammar.js demyte/language-cshtml grammars/cshtml.cson ./syntaxes/cshtml.json"
9+
"update-grammar": "node ../../build/npm/update-grammar.js demyte/language-cshtml grammars/cshtml.json ./syntaxes/cshtml.json"
1010
},
1111
"contributes": {
1212
"languages": [{

extensions/razor/syntaxes/cshtml.json

Lines changed: 89 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
{
22
"information_for_contributors": [
3-
"This file has been converted from https://github.com/demyte/language-cshtml/blob/master/grammars/cshtml.cson",
3+
"This file has been converted from https://github.com/demyte/language-cshtml/blob/master/grammars/cshtml.json",
44
"If you want to provide a fix or improvement, please create a pull request against the original repository.",
55
"Once accepted there, we are happy to receive an update request."
66
],
7+
"version": "https://github.com/demyte/language-cshtml/commit/cbf0e35971324e861247145e92f4cbbe0bc42d0e",
78
"name": "ASP.NET Razor",
89
"scopeName": "text.html.cshtml",
910
"fileTypes": [
@@ -35,21 +36,14 @@
3536
}
3637
},
3738
"patterns": [
38-
{
39-
"name": "string.quoted.single.cshtml",
40-
"match": "'"
41-
},
4239
{
4340
"include": "#embedded-code"
4441
},
4542
{
46-
"include": "#comments"
43+
"include": "#general-includes"
4744
},
4845
{
4946
"include": "source.cs"
50-
},
51-
{
52-
"include": "text.html.basic"
5347
}
5448
],
5549
"end": "\\}",
@@ -59,18 +53,14 @@
5953
}
6054
}
6155
},
62-
{
63-
"name": "string.quoted.single.cshtml",
64-
"match": "'"
65-
},
6656
{
6757
"include": "#embedded-code"
6858
},
6959
{
70-
"include": "#comments"
60+
"include": "#general-includes"
7161
},
7262
{
73-
"include": "text.html.basic"
63+
"include": "source.cs"
7464
}
7565
],
7666
"end": "\\}",
@@ -107,17 +97,32 @@
10797
"include": "#embedded-code"
10898
},
10999
{
110-
"include": "#comments"
100+
"include": "#general-includes"
101+
}
102+
],
103+
"end": "(\\n|\\s)",
104+
"comments": "Single statement Razor tags"
105+
},
106+
{
107+
"begin": "(@\\()",
108+
"captures": {
109+
"0": {
110+
"name": "punctuation.section.embedded.begin.cshtml"
111+
}
112+
},
113+
"patterns": [
114+
{
115+
"include": "#embedded-code"
111116
},
112117
{
113-
"include": "source.cs"
118+
"include": "#general-includes"
114119
},
115120
{
116-
"include": "text.html.basic"
121+
"include": "source.cs"
117122
}
118123
],
119-
"end": "(\\n|\\s)",
120-
"comments": "Covers single line Razor tags"
124+
"end": "(\\))",
125+
"comments": "Covers same line Razor statments with embedded C#"
121126
},
122127
{
123128
"include": "#comments"
@@ -139,7 +144,7 @@
139144
},
140145
"patterns": [
141146
{
142-
"include": "#comments"
147+
"include": "#general-includes"
143148
}
144149
]
145150
},
@@ -152,6 +157,69 @@
152157
},
153158
"end": "\\*@",
154159
"name": "comment.block.cshtml"
160+
},
161+
"line-comments": {
162+
"name": "comment.line.double-slash.cshtml",
163+
"begin": "(\\s*)//",
164+
"end": "$(\\s*)"
165+
},
166+
"block-comments": {
167+
"name": "comment.block.cshtml",
168+
"begin": "/\\*",
169+
"end": "((?=})|(\\*/))"
170+
},
171+
"single-quotes": {
172+
"name": "string.quoted.single.cshtml",
173+
"begin": "'",
174+
"end": "'"
175+
},
176+
"double-quotes": {
177+
"name": "string.quoted.double.cshtml",
178+
"begin": "\"",
179+
"end": "\"",
180+
"patterns": [
181+
{
182+
"include": "text.html.basic"
183+
}
184+
]
185+
},
186+
"round-brackets": {
187+
"name": "string.bracers.round.cshtml",
188+
"begin": "\\(",
189+
"end": "\\)"
190+
},
191+
"squiggly-brackets": {
192+
"name": "string.bracers.squiggly.cshtml",
193+
"begin": "{",
194+
"end": "}"
195+
},
196+
"general-includes": {
197+
"patterns": [
198+
{
199+
"include": "#comments"
200+
},
201+
{
202+
"include": "#line-comments"
203+
},
204+
{
205+
"include": "#block-comments"
206+
},
207+
{
208+
"include": "#round-brackets"
209+
},
210+
{
211+
"include": "#squiggly-brackets"
212+
},
213+
{
214+
"include": "#single-quotes"
215+
},
216+
{
217+
"include": "#double-quotes"
218+
},
219+
{
220+
"include": "text.html.basic"
221+
}
222+
]
155223
}
156224
}
157225
}

0 commit comments

Comments
 (0)