Skip to content

Commit 2a23654

Browse files
committed
Extract variable name lists
1 parent 5017fc8 commit 2a23654

1 file changed

Lines changed: 48 additions & 98 deletions

File tree

PowerShell.sublime-syntax

Lines changed: 48 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -462,66 +462,23 @@ contexts:
462462
###[ VARIABLES ]###############################################################
463463

464464
variables:
465-
- match: |-
466-
(?xi:
467-
(\$)
468-
(?:
469-
ExecutionContext | Host | Home | IsCoreCLR | IsLinux | IsWindows
470-
| IsMacOS | PID | Profile | PsCommandPath | PsHome | PsScriptRoot
471-
| PsUiCulture | PsVersionTable | ShellID
472-
)
473-
)
465+
- match: (\$){{var_constants}}
474466
scope: support.constant.variable.powershell
475467
captures:
476468
1: punctuation.definition.variable.powershell
477469
push: members
478-
- match: |-
479-
(?xi:
480-
(\$)
481-
(?:
482-
[$^?_]
483-
| (?:
484-
Args | ConsoleFileName | Error | Event | EventArgs
485-
| EventSubscriber | ForEach | Input | LastExitCode | Matches
486-
| MyInvocation | NestedPromptLevel | PsBoundParameters | PsCmdlet
487-
| PsCulture | PsDebugContext | PsItem | Pwd | Sender | SourceArgs
488-
| SourceEventArgs | StackTrace | Switch | This
489-
)\b
490-
)
491-
)
470+
- match: (\$){{var_language}}
492471
scope: variable.language.powershell
493472
captures:
494473
1: punctuation.definition.variable.powershell
495474
push: members
496-
- match: |-
497-
(?xi:
498-
(\$)
499-
(?:
500-
(?:
501-
Confirm | Debug | ErrorAction | Information | Progress | Verbose # *Preference
502-
| Warning | WhatIf
503-
)
504-
Preference
505-
| Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count
506-
| Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event
507-
| PsDebugContext | PsDefaultParameterValues | PsEmailServer
508-
| PsModuleAutoloadingPreference | PsSenderInfo
509-
| PsSessionApplicationName | PsSessionConfigurationName
510-
| PsSessionOption | ErrorView | FormatEnumerationLimit | OFS
511-
| OutputEncoding
512-
)
513-
)
514-
scope: variable.language.powershell
515-
captures:
516-
1: punctuation.definition.variable.powershell
517-
push: members
518-
- match: ((\$|@)(?i:(global|local|private|script|using|workflow):\w+))
475+
- match: ((\$|@)(?i:({{var_scope_mod}}):\w+))
519476
captures:
520477
1: variable.other.readwrite.powershell
521478
2: punctuation.definition.variable.powershell
522479
3: storage.modifier.scope.powershell
523480
push: members
524-
- match: ((\$)(\{)((?i:global|local|private|script|using|workflow)):([^}]*[^}`])(\}))
481+
- match: ((\$)(\{)({{var_scope_mod}}):([^}]*[^}`])(\}))
525482
captures:
526483
1: variable.other.readwrite.powershell
527484
2: punctuation.definition.variable.powershell
@@ -546,62 +503,20 @@ contexts:
546503
push: members
547504

548505
variables-without-property:
549-
- match: |-
550-
(?xi:
551-
(\$)
552-
(?:
553-
ExecutionContext | Host | Home | IsCoreCLR | IsLinux | IsWindows
554-
| IsMacOS | PID | Profile | PsCommandPath | PsHome | PsScriptRoot
555-
| PsUiCulture | PsVersionTable | ShellID
556-
)
557-
)
506+
- match: (\$){{var_constants}}
558507
scope: support.constant.variable.powershell
559508
captures:
560509
1: punctuation.definition.variable.powershell
561-
- match: |-
562-
(?xi:
563-
(\$)
564-
(?:
565-
[$^?_]
566-
| (?:
567-
Args | ConsoleFileName | Error | Event | EventArgs
568-
| EventSubscriber | ForEach | Input | LastExitCode | Matches
569-
| MyInvocation | NestedPromptLevel | PsBoundParameters | PsCmdlet
570-
| PsCulture | PsDebugContext | PsItem | Pwd | Sender | SourceArgs
571-
| SourceEventArgs | StackTrace | Switch | This
572-
)\b
573-
)
574-
)
575-
scope: variable.language.powershell
576-
captures:
577-
1: punctuation.definition.variable.powershell
578-
- match: |-
579-
(?xi:
580-
(\$)
581-
(?:
582-
(?:
583-
Confirm | Debug | ErrorAction | Information | Progress | Verbose # *Preference
584-
| Warning | WhatIf
585-
)
586-
Preference
587-
| Maximum(?:Alias|Drive|Error|Function|History|Variable)Count # Maximum*Count
588-
| Log(?:Command|Engine|Provider)(?:Health|Lifecycle)Event # Log*Event
589-
| PsDebugContext | PsDefaultParameterValues | PsEmailServer
590-
| PsModuleAutoloadingPreference | PsSenderInfo
591-
| PsSessionApplicationName | PsSessionConfigurationName
592-
| PsSessionOption | ErrorView | FormatEnumerationLimit | OFS
593-
| OutputEncoding
594-
)
595-
)
510+
- match: (\$){{var_language}}
596511
scope: variable.language.powershell
597512
captures:
598513
1: punctuation.definition.variable.powershell
599-
- match: (?i:(\$|@)(global|local|private|script|using|workflow):(\w+))
514+
- match: (?i:(\$|@)({{var_scope_mod}}):(\w+))
600515
captures:
601516
1: punctuation.definition.variable.powershell
602517
2: storage.modifier.scope.powershell
603518
3: variable.other.readwrite.powershell
604-
- match: (?i:(\$)(\{)(global|local|private|script|using|workflow):([^}]*[^}`])(\}))
519+
- match: (?i:(\$)(\{)({{var_scope_mod}}):([^}]*[^}`])(\}))
605520
captures:
606521
1: punctuation.definition.variable.powershell
607522
2: punctuation.section.braces.begin
@@ -925,15 +840,50 @@ contexts:
925840
###############################################################################
926841

927842
variables:
928-
dec_exponent: (?:[eE][-+]?\d*)
929-
dec_suffix: '[dD]'
930-
float_suffix: '[dDlL]'
931-
int_suffix: (?i:u[lsy]?|[lnsy])
932-
unit_suffix: (?i:[kmgtp]b\b)
933843
kebab_break: (?![\w-])
934844
builtin_types: |-
935845
\b(?x:
936846
void | null | object | bool | char | string
937847
| int (?:32|64)? | long | byte | float | double | decimal
938848
| array | hashtable
939849
)\b
850+
851+
# Numbers
852+
dec_exponent: (?:[eE][-+]?\d*)
853+
dec_suffix: '[dD]'
854+
float_suffix: '[dDlL]'
855+
int_suffix: (?i:u[lsy]?|[lnsy])
856+
unit_suffix: (?i:[kmgtp]b\b)
857+
858+
# Variables
859+
var_constants: |-
860+
\b(?xi:
861+
(?:
862+
ExecutionContext | Host | Home | IsCoreCLR | IsLinux | IsWindows
863+
| IsMacOS | PID | Profile | PsCommandPath | PsHome | PsScriptRoot
864+
| PsUiCulture | PsVersionTable | ShellID
865+
)
866+
)\b
867+
var_language: |-
868+
(?xi:
869+
[$^?_]
870+
| \b(?:
871+
Args | ConsoleFileName | Error | Event | EventArgs
872+
| EventSubscriber | ForEach | Input | LastExitCode | Matches
873+
| MyInvocation | NestedPromptLevel | PsBoundParameters | PsCmdlet
874+
| PsCulture | PsDebugContext | PsItem | Pwd | Sender | SourceArgs
875+
| SourceEventArgs | StackTrace | Switch | This
876+
| (?:
877+
Confirm | Debug | ErrorAction | Information | Progress # *Preference
878+
| Verbose | Warning | WhatIf
879+
) Preference
880+
| Maximum (?: Alias | Drive | Error | Function | History | Variable ) Count # Maximum*Count
881+
| Log (?: Command | Engine | Provider ) (?: Health | Lifecycle ) Event # Log*Event
882+
| PsDebugContext | PsDefaultParameterValues | PsEmailServer
883+
| PsModuleAutoloadingPreference | PsSenderInfo
884+
| PsSessionApplicationName | PsSessionConfigurationName
885+
| PsSessionOption | ErrorView | FormatEnumerationLimit | OFS
886+
| OutputEncoding
887+
)\b
888+
)
889+
var_scope_mod: (?i:global|local|private|script|using|workflow)

0 commit comments

Comments
 (0)