diff --git a/PowerShell.sublime-syntax b/PowerShell.sublime-syntax index a4f1234..6f54568 100644 --- a/PowerShell.sublime-syntax +++ b/PowerShell.sublime-syntax @@ -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 @@ -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.braces.begin.powershell + 3: storage.type.powershell + 4: punctuation.section.braces.end.powershell + 5: entity.name.function.powershell + push: + - match: (?=\() + pop: true + - include: comment-line diff --git a/Tests/syntax_test_PowerShell.ps1 b/Tests/syntax_test_PowerShell.ps1 index 7dcd109..4b45eb2 100644 --- a/Tests/syntax_test_PowerShell.ps1 +++ b/Tests/syntax_test_PowerShell.ps1 @@ -916,6 +916,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 @@ -1129,6 +1132,8 @@ class Vehicle { [void]Drive([int]$NumberOfMiles) { # ^^^^ storage.type +# ^^^^^ meta.function entity.name.function +# @@@@@ definition # ^^^ storage.type # ^ punctuation.definition.variable # ^ variable.other.readwrite @@ -1140,9 +1145,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