Skip to content

Commit f9292e6

Browse files
committed
Added highlighting of class and class keywords
1 parent 5b960df commit f9292e6

File tree

1 file changed

+87
-5
lines changed

1 file changed

+87
-5
lines changed

PowerShellSyntax.tmLanguage

Lines changed: 87 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
<key>include</key>
106106
<string>#function</string>
107107
</dict>
108+
<dict>
109+
<key>include</key>
110+
<string>#enum</string>
111+
</dict>
108112
<dict>
109113
<key>include</key>
110114
<string>#class</string>
@@ -191,7 +195,9 @@
191195
</dict>
192196
<key>class</key>
193197
<dict>
194-
<key>captures</key>
198+
<key>begin</key>
199+
<string>(?&lt;!\w|-)(?i:(class))\s+(\w+)(?:\s*(:)\s*(\w+))?\s*\{</string>
200+
<key>beginCaptures</key>
195201
<dict>
196202
<key>1</key>
197203
<dict>
@@ -201,13 +207,69 @@
201207
<key>2</key>
202208
<dict>
203209
<key>name</key>
204-
<string>entity.name.function</string>
210+
<string>entity.name.function.powershell</string>
211+
</dict>
212+
<key>3</key>
213+
<dict>
214+
<key>name</key>
215+
<string>keyword.operator.powershell</string>
216+
</dict>
217+
<key>4</key>
218+
<dict>
219+
<key>name</key>
220+
<string>entity.other.inherited-class.powershell</string>
205221
</dict>
206222
</dict>
207223
<key>comment</key>
208-
<string>capture should be entity.name.type, but it doesn't provide a good color in the default schema.</string>
224+
<string>Class</string>
225+
<key>end</key>
226+
<string>\}</string>
227+
<key>name</key>
228+
<string>meta.class.powershell</string>
229+
<key>patterns</key>
230+
<array>
231+
<dict>
232+
<key>include</key>
233+
<string>#classReservedWords</string>
234+
</dict>
235+
<dict>
236+
<key>include</key>
237+
<string>#classBaseKeyword</string>
238+
</dict>
239+
<dict>
240+
<key>include</key>
241+
<string>$self</string>
242+
</dict>
243+
</array>
244+
</dict>
245+
<key>classBaseKeyword</key>
246+
<dict>
247+
<key>captures</key>
248+
<dict>
249+
<key>1</key>
250+
<dict>
251+
<key>name</key>
252+
<string>keyword.operator.powershell</string>
253+
</dict>
254+
<key>2</key>
255+
<dict>
256+
<key>name</key>
257+
<string>keyword.control.class.powershell</string>
258+
</dict>
259+
</dict>
260+
<key>comment</key>
261+
<string>The base keyword used in classes.</string>
209262
<key>match</key>
210-
<string>(?&lt;!\w|-)(?i:(class|enum))\s+(\w+)\s+</string>
263+
<string>(:)\s*(?i:(base))\s*(?=\()</string>
264+
</dict>
265+
<key>classReservedWords</key>
266+
<dict>
267+
<key>comment</key>
268+
<string>Reserved words for classes.</string>
269+
<key>match</key>
270+
<string>\b(?i:(hidden|static))\b</string>
271+
<key>name</key>
272+
<string>keyword.other.powershell</string>
211273
</dict>
212274
<key>commandParameter</key>
213275
<dict>
@@ -713,6 +775,26 @@
713775
<key>match</key>
714776
<string>(?i:(default))\s*(?=\{)</string>
715777
</dict>
778+
<key>enum</key>
779+
<dict>
780+
<key>captures</key>
781+
<dict>
782+
<key>1</key>
783+
<dict>
784+
<key>name</key>
785+
<string>storage.type.powershell</string>
786+
</dict>
787+
<key>2</key>
788+
<dict>
789+
<key>name</key>
790+
<string>entity.name.function</string>
791+
</dict>
792+
</dict>
793+
<key>comment</key>
794+
<string>capture should be entity.name.type, but it doesn't provide a good color in the default schema.</string>
795+
<key>match</key>
796+
<string>(?&lt;!\w|-)(?i:(enum))\s+(\w+)\s+</string>
797+
</dict>
716798
<key>executableFiles</key>
717799
<dict>
718800
<key>comment</key>
@@ -990,7 +1072,7 @@
9901072
<key>reservedWords</key>
9911073
<dict>
9921074
<key>match</key>
993-
<string>(\b(?&lt;!-|\$)(?i:configuration|node|process|enum|filter|sequence|class|switch|data|define|function|dynamicparam|inlinescript|var|parallel|param|workflow)\b(?!-|\.))</string>
1075+
<string>(\b(?&lt;!-|\$)(?i:configuration|node|process|enum|filter|sequence|class|data|define|function|dynamicparam|inlinescript|var|parallel|param|workflow)\b(?!-|\.))</string>
9941076
<key>name</key>
9951077
<string>keyword.other.powershell</string>
9961078
</dict>

0 commit comments

Comments
 (0)