Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ contexts:
- include: script-block
- include: escape-characters
- include: numeric-constant
- include: class-method
- match: (@)(\()
captures:
1: keyword.other.array.begin.powershell
Expand Down Expand Up @@ -342,7 +343,7 @@ contexts:
\-\w+? # Any "noun"
(?:\.(?i:exe|cmd|bat|ps1))?\b # More path stuff
)
scope: support.function.powershell
scope: meta.function-call.powershell support.function.powershell
# Builtin cmdlets with reserved verbs
- match: \b(?i:(?:foreach|where|sort|tee)-object)\b
scope: support.function.powershell
Expand Down Expand Up @@ -793,3 +794,17 @@ contexts:
3: support.variable.drive.powershell
4: variable.other.readwrite.powershell
5: punctuation.section.braces.end

class-method:
- match: ^(?:\s*)(?i)(hidden|static)?\s*(\[)((?!\d+|\.)[\p{L}\p{N}.]+)(\])\s*((?:\p{L}|\d|_|-|\.)+)\s*(?=\()
scope: meta.function.powershell
captures:
1: storage.modifier.powershell
2: punctuation.section.brackets.begin.powershell
3: storage.type.powershell
4: punctuation.section.brackets.end.powershell
5: entity.name.function.powershell
push:
- match: (?=\()
pop: true
- include: comment-line
19 changes: 19 additions & 0 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,9 @@ function New-File ($Name) { }
# @@@@@@@@ definition
# ^ punctuation.section.braces.begin
# ^ punctuation.section.braces.end
New-File
#^^^^^^^^ meta.function-call support.function
#@@@@@@@@ reference
function NewFile($Name) { }
# <- storage.type
# ^^^^^^^ entity.name.function
Expand Down Expand Up @@ -1248,6 +1251,8 @@ class Vehicle {

[void]Drive([int]$NumberOfMiles) {
# ^^^^ storage.type
# ^^^^^ meta.function entity.name.function
# @@@@@ definition
# ^^^ storage.type
# ^ punctuation.definition.variable
# ^ variable.other.readwrite
Expand All @@ -1259,9 +1264,23 @@ class Vehicle {

}
# <- punctuation.section.braces.end
static [System.Array] GetAvailableColors() {
# ^^^^^^^^^^^^^^^^^^ meta.function entity.name.function
# @@@@@@@@@@@@@@@@@@ definition
# ^^^^^^ meta.function storage.modifier
# ^^^^^^^^^^^ meta.function storage.type
return 'yellow', 'red'
}
}
# <- punctuation.section.braces.end

$fiat.Drive(42)
# ^^^^^ meta.function-call
# @@@@@ reference
[Vehicle]::GetAvailableColors()
# ^^^^^^^^^^^^^^^^^^ meta.function-call variable.function
# @@@@@@@@@@@@@@@@@@ reference

# Control words
foreach ($item in $collection) {
# <- keyword.control
Expand Down
Loading