Skip to content

Commit aabf5ed

Browse files
committed
Refactor Razor C# inheritance
1 parent 74b49bc commit aabf5ed

5 files changed

Lines changed: 44 additions & 33 deletions

File tree

Razor/C# (Razor).sublime-syntax

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%YAML 1.2
22
---
3-
scope: source.cs.embedded.html
3+
scope: source.cs.embedded.html.cs.razor
44
hidden: true
55
# version: 2
66

@@ -33,3 +33,26 @@ contexts:
3333
scope: invalid.illegal.stray.cs
3434
- match: (?=})
3535
pop: 1
36+
37+
keywords:
38+
- meta_prepend: true
39+
- match: \bModel\b
40+
scope: variable.language.this.razor
41+
- match: \bHtml\b
42+
scope: variable.language.this.razor
43+
44+
inside_triple_quoted_raw_string_syntax:
45+
- meta_include_prototype: false
46+
- include: immediately_pop
47+
48+
inside_verbatim_string_syntax:
49+
- meta_include_prototype: false
50+
- include: immediately_pop
51+
52+
inside_verbatim_format_string_syntax:
53+
- meta_include_prototype: false
54+
- include: immediately_pop
55+
56+
immediately_pop:
57+
- match: ''
58+
pop: 1

Razor/Razor.sublime-syntax

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ contexts:
9999
- match: \}
100100
scope: punctuation.section.block.end.cs-razor
101101
pop: true
102-
- include: scope:source.cs#code_block_in
102+
- include: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax#code_block_in
103103
- match: \s*(?!\{)(?=\S)
104104
scope: invalid.illegal.expected-block.cs-razor
105105
pop: true
@@ -111,15 +111,15 @@ contexts:
111111
push:
112112
- clear_scopes: 1
113113
- meta_content_scope: source.cs.embedded.html
114-
- include: scope:source.cs#line_of_code
114+
- include: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax#line_of_code
115115
- match: ''
116116
pop: true
117117
with_prototype:
118118
- include: razor-block-prototype
119119
- match: '[\w-+]+@\w+' # ignore email addresses
120120
- match: '@(?=(?:\w+\.)*\w+(?:[<\s]|$))'
121121
scope: punctuation.section.embedded.line.cs-razor
122-
embed: scope:source.cs#line_of_code_in
122+
embed: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax#line_of_code_in
123123
embed_scope: source.cs.embedded.html
124124
escape: $|(?=[<\s])
125125
- match: '@(?=(?:\w+\.)*\w+\()'
@@ -128,7 +128,7 @@ contexts:
128128
- meta_content_scope: source.cs.embedded.html
129129
- match: (?=[<\s])
130130
pop: true
131-
- include: scope:source.cs#line_of_code_in
131+
- include: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax#line_of_code_in
132132
- match: '@\('
133133
scope: punctuation.section.embedded.begin.cs-razor
134134
push:
@@ -137,7 +137,7 @@ contexts:
137137
- match: \)
138138
scope: punctuation.section.embedded.end.cs-razor
139139
pop: true
140-
- include: scope:source.cs#line_of_code_in
140+
- include: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax#line_of_code_in
141141
#- match: '@(?=\w+(?:\.\w+)*)(?!\s*[+=|(])' # TODO: support a.b[2] etc.
142142
# comment: property/variable access
143143
# scope: punctuation.section.embedded.line.cs-razor

Razor/embeddings/C# (for C# Razor HTML attribute).sublime-syntax

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,23 +4,11 @@ scope: source.cs.embedded.html-attribute-string.razor
44
version: 1
55
hidden: true
66

7-
extends: Packages/C#/C#.sublime-syntax
7+
extends: Packages/HTML (C#)/Razor/C# (Razor).sublime-syntax
88

99
contexts:
1010

1111
line_of_code_in:
1212
- meta_prepend: true
1313
- match: (?=")
1414
pop: 1
15-
16-
inside_triple_quoted_raw_string_syntax:
17-
- meta_include_prototype: false
18-
- include: immediately_pop
19-
20-
inside_verbatim_string_syntax:
21-
- meta_include_prototype: false
22-
- include: immediately_pop
23-
24-
inside_verbatim_format_string_syntax:
25-
- meta_include_prototype: false
26-
- include: immediately_pop

Razor/tests/syntax_test_cshtml.cshtml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,35 +165,35 @@ else
165165
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
166166
<!-- ^^^^^^^^ meta.class-name.html meta.string.html string.quoted.double.html -->
167167
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
168+
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.html -->
168169
<!-- ^^^^^^^^^ entity.other.attribute-name.html -->
169170
<!-- ^ punctuation.separator.key-value.html -->
170171
<!-- ^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
171172
<!-- ^ punctuation.definition.string.begin.html -->
172173
<!-- ^ punctuation.section.interpolation.begin.razor -->
173-
<!-- ^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
174-
<!-- ^^^^^ variable.other.cs -->
174+
<!-- ^^^^^ variable.language.this.razor -->
175175
<!-- ^ punctuation.accessor.dot.cs -->
176176
<!-- ^^^^^^^^ variable.other.cs -->
177177
<!-- ^ punctuation.definition.string.end.html -->
178+
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.html -->
178179
<!-- ^^^^^^^^^^^^^ entity.other.attribute-name.html -->
179180
<!-- ^ punctuation.separator.key-value.html -->
180181
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
181182
<!-- ^ punctuation.definition.string.begin.html -->
182183
<!-- ^ punctuation.section.interpolation.begin.razor -->
183-
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
184-
<!-- ^^^^^ variable.other.cs -->
184+
<!-- ^^^^^ variable.language.this.razor -->
185185
<!-- ^ punctuation.accessor.dot.cs -->
186186
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
187187
<!-- ^ punctuation.accessor.dot.cs -->
188188
<!-- ^^^^^^^^ variable.other.cs -->
189189
<!-- ^ punctuation.definition.string.end.html -->
190+
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.html -->
190191
<!-- ^^^^^^^^^^^^^^^ entity.other.attribute-name.html -->
191192
<!-- ^ punctuation.separator.key-value.html -->
192193
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
193194
<!-- ^ punctuation.definition.string.begin.html -->
194195
<!-- ^ punctuation.section.interpolation.begin.razor -->
195-
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
196-
<!-- ^^^^^ variable.other.cs -->
196+
<!-- ^^^^^ variable.language.this.razor -->
197197
<!-- ^ punctuation.accessor.dot.cs -->
198198
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
199199
<!-- ^ punctuation.accessor.dot.cs -->
@@ -211,13 +211,13 @@ else
211211
<!-- ^ punctuation.section.group.begin.cs -->
212212
<!-- ^ punctuation.section.group.end.cs -->
213213
<!-- ^ punctuation.definition.string.end.html -->
214+
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute-with-value.html -->
214215
<!-- ^^^^^^^^^^^^^^^^^^^^ entity.other.attribute-name.html -->
215216
<!-- ^ punctuation.separator.key-value.html -->
216217
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.html string.quoted.double.html -->
217218
<!-- ^ punctuation.definition.string.begin.html -->
218219
<!-- ^ punctuation.section.interpolation.begin.razor -->
219-
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
220-
<!-- ^^^^^ variable.other.cs -->
220+
<!-- ^^^^^ variable.language.this.razor -->
221221
<!-- ^ punctuation.accessor.dot.cs -->
222222
<!-- ^^^^^^^^^^^^^ variable.other.cs -->
223223
<!-- ^ punctuation.accessor.dot.cs -->
@@ -248,21 +248,21 @@ else
248248
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
249249
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html -->
250250
<!-- ^ punctuation.section.interpolation.begin.razor -->
251-
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
252-
<!-- ^^^^^ variable.other.cs -->
251+
<!-- ^^^^^ variable.language.this.razor -->
253252
<!-- ^ punctuation.accessor.dot.cs -->
254253
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.cs -->
255254
<!-- ^^^^^^^^^^^^^^ variable.function.cs -->
256255
<!-- ^^^^^^^^^^^^^^^^^^^^^^^ meta.group.cs -->
257256
<!-- ^ punctuation.section.group.begin.cs -->
258-
<!-- ^^^^^ variable.other.cs -->
257+
<!-- ^^^^^ variable.language.this.razor -->
259258
<!-- ^ punctuation.accessor.dot.cs -->
260259
<!-- ^^^^^^^^^^^ variable.other.cs -->
261260
<!-- ^ keyword.operator.cs -->
262261
<!-- ^ meta.number.integer.decimal.cs constant.numeric.value.cs -->
263262
<!-- ^ punctuation.section.group.end.cs -->
264263
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
265264
<!-- ^ punctuation.definition.tag.end.html -->
265+
<!-- ^^^^ meta.tag.inline.any.html -->
266266
<!-- ^^ punctuation.definition.tag.begin.html -->
267267
<!-- ^ entity.name.tag.inline.any.html -->
268268
<!-- ^ punctuation.definition.tag.end.html -->
@@ -278,8 +278,7 @@ else
278278
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.begin.html -->
279279
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.path.url.html meta.string.html string.quoted.double.html -->
280280
<!-- ^ punctuation.section.interpolation.begin.razor -->
281-
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.cs.embedded.html-attribute-string.razor -->
282-
<!-- ^^^^^ variable.other.cs -->
281+
<!-- ^^^^^ variable.language.this.razor -->
283282
<!-- ^ punctuation.accessor.dot.cs -->
284283
<!-- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function-call.cs -->
285284
<!-- ^^^^^^^^^^^^ variable.function.cs -->
@@ -291,6 +290,7 @@ else
291290
<!-- ^ punctuation.section.group.end.cs -->
292291
<!-- ^ meta.string.html string.quoted.double.html punctuation.definition.string.end.html -->
293292
<!-- ^ punctuation.definition.tag.end.html -->
293+
<!-- ^^^^ meta.tag.inline.any.html -->
294294
<!-- ^^ punctuation.definition.tag.begin.html -->
295295
<!-- ^ entity.name.tag.inline.any.html -->
296296
<!-- ^ punctuation.definition.tag.end.html -->

WebForms/C# (WebForms).sublime-syntax

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
%YAML 1.2
22
---
3-
scope: source.cs.embedded.html
3+
scope: source.cs.embedded.html.cs.webforms
44
hidden: true
55
# version: 2
66

0 commit comments

Comments
 (0)