@@ -13,50 +13,165 @@ contexts:
1313 main :
1414 - include : html
1515
16+ directive-generic-attribute :
17+ - match : ' \b(\w+)\s*(?:(=)\s*((")[^"]*("))?)?\s*'
18+ captures :
19+ 1 : entity.other.attribute-name.cshtml
20+ 2 : punctuation.separator.key-value.cshtml
21+ 3 : string.quoted.double.cshtml
22+ 4 : punctuation.definition.string.begin.cshtml
23+ 5 : punctuation.definition.string.end.cshtml
24+
25+ directive-end :
26+ - match : ' %>'
27+ scope : punctuation.section.embedded.end.cshtml
28+ pop : true
29+
1630 directive :
17- - match : ' <%@' # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
31+ # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
32+ - match : ' <%@'
1833 scope: punctuation.section.embedded.begin.cshtml
19- push:
20- - match: '\b(\w+)\s*(=)\s*((")[^"]*("))\s*'
34+ set:
35+ - meta_scope: meta.block.processing-directive.cshtml
36+ - include: directive-type
37+ - include: directive-import
38+ - include: directive-implements
39+ - include: directive-reference
40+ - include: directive-outputcache
41+ - include: directive-other
42+ # Blank directives are considered to be "Page" or "Control" by .Net
43+ - include: directive-generic-attribute
44+ - include: directive-end
45+
46+ directive-type:
47+ # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
48+ - match: '\b(?i:Application|Page|Control|Master)\b'
49+ scope: constant.language.processing-directive.cshtml entity.name.class.cs
50+ set:
51+ - meta_scope: meta.block.processing-directive.contents.type.cshtml
52+ - include: directive-generic-attribute
53+ - include: directive-end
54+
55+ directive-import:
56+ # https://msdn.microsoft.com/en-us/library/eb44kack(v=vs.100).aspx
57+ - match: '\b(?i:Import)\b'
58+ scope: constant.language.processing-directive.cshtml
59+ set:
60+ - meta_scope: meta.block.processing-directive.contents.import.cshtml
61+ - match: '\b(?i:(Namespace))\s*(=)\s*((")([^"]*)("))'
2162 captures:
2263 1: entity.other.attribute-name.cshtml
2364 2: punctuation.separator.key-value.cshtml
2465 3: string.quoted.double.cshtml
2566 4: punctuation.definition.string.begin.cshtml
26- 5: punctuation.definition.string.end.cshtml
27- - match: '\s*(Application|Page|Control|Import|Implements|Register|Assembly|OutputCache|Reference|Master|PreviousPageType|MasterType|WebHandler)\b(?:(=)"([^"]+)")?'
67+ 5: meta.path.cs
68+ 6: punctuation.definition.string.end.cshtml
69+ - include: directive-end
70+
71+ directive-implements:
72+ # https://msdn.microsoft.com/en-us/library/cbsf6k72(v=vs.100).aspx
73+ - match: '\b(?i:(Implements))\b'
74+ scope: constant.language.processing-directive.cshtml
75+ set:
76+ - meta_scope: meta.block.processing-directive.contents.implements.cshtml
77+ - match: '\b(?i:(Interface))\s*(=)\s*((")([^"]*)("))'
2878 captures:
29- 1: constant.language.processing-directive .cshtml
79+ 1: entity.other.attribute-name .cshtml
3080 2: punctuation.separator.key-value.cshtml
3181 3: string.quoted.double.cshtml
32- - match: ' % >'
33- scope : punctuation.section.embedded.end.cshtml
34- pop : true
82+ 4: punctuation.definition.string.begin.cshtml
83+ 5: entity.other.inherited-class.cs
84+ 6: punctuation.definition.string.end.cshtml
85+ - include: directive-end
86+
87+ directive-reference:
88+ # https://msdn.microsoft.com/en-us/library/w70c655a(v=vs.100).aspx
89+ - match: '\b(?i:(Reference))\b'
90+ scope: constant.language.processing-directive.reference.cshtml
91+ set:
92+ - meta_scope: meta.block.processing-directive.contents.reference.cshtml
93+ - match: '\b(?i:(Page|Control|VirtualPath))\s*(=)\s*((")([^"]*)("))'
94+ captures:
95+ 1: entity.other.attribute-name.cshtml
96+ 2: punctuation.separator.key-value.cshtml
97+ 3: string.quoted.double.cshtml
98+ 4: punctuation.definition.string.begin.cshtml
99+ 5: meta.path.cs
100+ 6: punctuation.definition.string.end.cshtml
101+ - include: directive-end
102+
103+ directive-outputcache:
104+ # https://msdn.microsoft.com/en-us/library/hdxfb6cy(v=vs.100).aspx
105+ - match: '\b(?i:(OutputCache))\b'
106+ scope: constant.language.processing-directive.caching.cshtml
107+ set:
108+ - meta_scope: meta.block.processing-directive.contents.outputcache.cshtml
109+ - match: '\b(?i:(Duration))\s*(=)\s*((")(?:(\d+)|[^"]*)("))'
110+ captures:
111+ 1: entity.other.attribute-name.cshtml
112+ 2: punctuation.separator.key-value.cshtml
113+ 3: string.quoted.double.cshtml
114+ 4: punctuation.definition.string.begin.cshtml
115+ 5: constant.numeric.integer.cshtml
116+ 6: punctuation.definition.string.end.cshtml
117+ - match: '\b(?i:(NoStore|Shared))\s*(=)\s*((")(?i:(true|false)|[^"]*)("))'
118+ captures:
119+ 1: entity.other.attribute-name.cshtml
120+ 2: punctuation.separator.key-value.cshtml
121+ 3: string.quoted.double.cshtml
122+ 4: punctuation.definition.string.begin.cshtml
123+ 5: constant.language.boolean.cshtml
124+ 6: punctuation.definition.string.end.cshtml
125+ - match: '\b(?i:(Location))\s*(=)\s*((")(?i:(Any|Client|Downstream|Server|None|ServerAndClient)|[^"]*)("))'
126+ captures:
127+ 1: entity.other.attribute-name.cshtml
128+ 2: punctuation.separator.key-value.cshtml
129+ 3: string.quoted.double.cshtml
130+ 4: punctuation.definition.string.begin.cshtml
131+ 5: meta.enum.cache-location.cshtml
132+ 6: punctuation.definition.string.end.cshtml
133+ - match: '\b(?i:(CacheProfile|SqlDependency|ProviderName|VaryBy(?:Control|Custom|Header|Param|ContentEncoding)))\s*(=)\s*((")([^"]*)("))'
134+ captures:
135+ 1: entity.other.attribute-name.cshtml
136+ 2: punctuation.separator.key-value.cshtml
137+ 3: string.quoted.double.cshtml
138+ 4: punctuation.definition.string.begin.cshtml
139+ 5: meta.path.cs
140+ 6: punctuation.definition.string.end.cshtml
141+ - include: directive-end
142+
143+ directive-other:
144+ # https://msdn.microsoft.com/en-us/library/xz702w3e(v=vs.100).aspx
145+ - match: '\b(Register|Assembly|PreviousPageType|MasterType)\b'
146+ scope: constant.language.processing-directive.cshtml
147+ set:
148+ - include: directive-generic-attribute
149+ - include: directive-end
35150
36151 html:
37152 - match: ''
38153 set: scope:text.html.basic
39154 with_prototype:
40155 - include: comments
41- - include : script_tag_cs
156+ - include: script-tag-cs
42157 - include: directive
43- - include : block_cs
158+ - include: block-cs
44159
45- block_cs :
160+ block-cs :
46161 - match: '<%[=#:$]?'
47162 scope: punctuation.section.embedded.begin.cshtml
48- embed: inside_block_cs
163+ embed: inside-block-cs
49164 embed_scope: source.cs.embedded.html
50165 escape: ' % >'
51166 escape_captures :
52167 0 : punctuation.section.embedded.end.cshtml
53168
54- inside_block_cs :
169+ inside-block-cs :
55170 - match : ' }'
56171 scope : punctuation.section.block.end.cs
57172 - include : scope:source.cs
58173
59- script_tag_cs :
174+ script-tag-cs :
60175 - match : (?i)(<)(script)[^>]+(runat)(=)(?:((')server('))|((")server(")))
61176 captures :
62177 1 : punctuation.definition.tag.begin.html
0 commit comments