Skip to content

Commit 0ed6442

Browse files
committed
Improve type scopes
1 parent 3a05c40 commit 0ed6442

File tree

2 files changed

+105
-55
lines changed

2 files changed

+105
-55
lines changed

PowerShell.sublime-syntax

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -314,20 +314,35 @@ contexts:
314314
# Back to normal stuff
315315
- include: statements
316316

317+
###[ TYPES ]###################################################################
318+
317319
types:
318320
# TODO: push a maybe-static-members context
319321
- match: \[
320322
scope: punctuation.section.brackets.begin.powershell
321-
push:
322-
- match: \](?=::)
323-
scope: punctuation.section.brackets.end.powershell
324-
set: static-members
325-
- match: \]
326-
scope: punctuation.section.brackets.end.powershell
327-
pop: 1
328-
- match: (?!\d+|\.)[\p{L}\p{N}.]+
329-
scope: storage.type.powershell
330-
- include: types
323+
push: inside-type
324+
325+
inside-type:
326+
- meta_include_prototype: false
327+
- match: \](?=::)
328+
scope: punctuation.section.brackets.end.powershell
329+
set: static-members
330+
- match: \]
331+
scope: punctuation.section.brackets.end.powershell
332+
pop: 1
333+
- match: \p{L}[\p{L}\p{N}]+(\.)
334+
scope: meta.generic-name.powershell
335+
captures:
336+
1: punctuation.accessor.dot.powershell
337+
- match: \b(?:void|null|object|bool|char|string|int(?:32|64)?|long|byte|float|double|decimal)\b
338+
scope: storage.type.powershell
339+
- match: (?!\d+|\.)[\p{L}\p{N}.]+
340+
scope: support.type.powershell
341+
- include: types
342+
- match: \,
343+
scope: punctuation.separator.sequence.powershell
344+
- match: \+
345+
scope: punctuation.accessor.plus.powershell
331346

332347
###[ OPERATORS ]###############################################################
333348

Tests/syntax_test_PowerShell.ps1

Lines changed: 80 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -654,51 +654,86 @@ $a3[1..2]
654654
# ^^ constant.numeric.value
655655
# ^^ constant.numeric.suffix
656656

657-
# Types
658-
[string]
659-
# <- punctuation.section.brackets.begin
660-
# ^ storage.type
661-
# ^ punctuation.section.brackets.end
662-
[string[]]
663-
# <- punctuation.section.brackets.begin
664-
# ^ storage.type
665-
# ^ punctuation.section.brackets.begin
666-
# ^^ punctuation.section.brackets.end
667-
[int32]
668-
# <- punctuation.section.brackets.begin
669-
# ^^^^ storage.type
670-
# ^ punctuation.section.brackets.end
671-
[System.Collections.Generic.Dictionary[[System.String, mscorlib],[System.Management.Automation.ParameterMetadata,System.Management.Automation]]]
672-
# <- punctuation.section.brackets.begin
673-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ storage.type
674-
# ^^ punctuation.section.brackets.begin
675-
# ^^^^^^^^^^^^^ storage.type
676-
# ^^^^^^^^ storage.type
677-
# ^ punctuation.section.brackets.end
678-
# ^ punctuation.section.brackets.begin
679-
# ^^^^^^^^^^^^^^^^ storage.type
680-
# ^^^ punctuation.section.brackets.end
681-
[System.Array+SZArrayEnumerator]
682-
# <- punctuation.section.brackets.begin
683-
# ^^^^^^^^^^^ storage.type
684-
# ^^^^^^^^^^^^^^^^^ storage.type
685-
# ^ punctuation.section.brackets.end
686-
[int]::MinValue
687-
# <- punctuation.section.brackets.begin
688-
# ^ storage.type
689-
# ^ punctuation.section.brackets.end
690-
# ^^ punctuation.accessor.double-colon
691-
# ^^^^^^^^ variable.other.member
692-
[System.DateTime]::Parse('2016/09/21')
693-
# <- punctuation.section.brackets.begin
694-
# ^^^^^^^^^^^^^^ storage.type
695-
# ^ punctuation.section.brackets.end
696-
# ^^ punctuation.accessor.double-colon
697-
# ^^^^^ meta.function-call variable.function
698-
# @@@@@ reference
699-
# ^^^^^^^^^^^^^^ meta.function-call.arguments
700-
# ^ punctuation.section.arguments.begin
701-
# ^ punctuation.section.arguments.end
657+
658+
###[ Types ]###################################################################
659+
660+
[string]
661+
# ^ punctuation.section.brackets.begin.powershell
662+
# ^^^^^^ storage.type.powershell
663+
# ^ punctuation.section.brackets.end.powershell
664+
665+
[string[]]
666+
# ^ punctuation.section.brackets.begin.powershell
667+
# ^^^^^^ storage.type.powershell
668+
# ^ punctuation.section.brackets.begin.powershell
669+
# ^^ punctuation.section.brackets.end.powershell
670+
671+
[int32]
672+
# ^ punctuation.section.brackets.begin.powershell
673+
# ^^^^^ storage.type.powershell
674+
# ^ punctuation.section.brackets.end.powershell
675+
676+
[System.Collections.Generic.Dictionary[[System.String, mscorlib],[System.Management.Automation.ParameterMetadata,System.Management.Automation]]]
677+
# ^ punctuation.section.brackets.begin.powershell
678+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic-name.powershell
679+
# ^ punctuation.accessor.dot.powershell
680+
# ^ punctuation.accessor.dot.powershell
681+
# ^ punctuation.accessor.dot.powershell
682+
# ^^^^^^^^^^ support.type.powershell
683+
# ^^ punctuation.section.brackets.begin.powershell
684+
# ^^^^^^^ meta.generic-name.powershell
685+
# ^ punctuation.accessor.dot.powershell
686+
# ^^^^^^ support.type.powershell
687+
# ^ punctuation.separator.sequence.powershell
688+
# ^^^^^^^^ support.type.powershell
689+
# ^ punctuation.section.brackets.end.powershell
690+
# ^ punctuation.separator.sequence.powershell
691+
# ^ punctuation.section.brackets.begin.powershell
692+
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.generic-name.powershell
693+
# ^ punctuation.accessor.dot.powershell
694+
# ^ punctuation.accessor.dot.powershell
695+
# ^ punctuation.accessor.dot.powershell
696+
# ^^^^^^^^^^^^^^^^^ support.type.powershell
697+
# ^ punctuation.separator.sequence.powershell
698+
# ^^^^^^^^^^^^^^^^^^ meta.generic-name.powershell
699+
# ^ punctuation.accessor.dot.powershell
700+
# ^ punctuation.accessor.dot.powershell
701+
# ^^^^^^^^^^ support.type.powershell
702+
# ^^^ punctuation.section.brackets.end.powershell
703+
704+
[System.Array+SZArrayEnumerator]
705+
# ^ punctuation.section.brackets.begin.powershell
706+
# ^^^^^^^ meta.generic-name.powershell
707+
# ^ punctuation.accessor.dot.powershell
708+
# ^^^^^ support.type.powershell
709+
# ^ punctuation.accessor.plus.powershell
710+
# ^^^^^^^^^^^^^^^^^ support.type.powershell
711+
# ^ punctuation.section.brackets.end.powershell
712+
713+
[int]::MinValue
714+
# ^ punctuation.section.brackets.begin.powershell
715+
# ^^^ storage.type.powershell
716+
# ^ punctuation.section.brackets.end.powershell
717+
# ^^ punctuation.accessor.double-colon.powershell
718+
# ^^^^^^^^ variable.other.member.powershell
719+
720+
[System.DateTime]::Parse('2016/09/21')
721+
# ^ punctuation.section.brackets.begin.powershell
722+
# ^^^^^^^ meta.generic-name.powershell
723+
# ^ punctuation.accessor.dot.powershell
724+
# ^^^^^^^^ support.type.powershell
725+
# ^ punctuation.section.brackets.end.powershell
726+
# ^^ punctuation.accessor.double-colon.powershell
727+
# ^^^^^ meta.function-call.powershell variable.function.powershell
728+
# ^^^^^^^^^^^^^^ meta.function-call.arguments.powershell
729+
# ^ punctuation.section.arguments.begin.powershell
730+
# ^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell
731+
# ^ punctuation.definition.string.begin.powershell
732+
# ^ punctuation.definition.string.end.powershell
733+
# ^ punctuation.section.arguments.end.powershell
734+
735+
736+
###[ Commands ]################################################################
702737

703738
# Commands (functions)
704739
Invoke-Something -foobar

0 commit comments

Comments
 (0)