Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 10 additions & 0 deletions Tests/syntax_test_Class.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@ class TypeName
# ^ punctuation.section.brackets.begin
# ^^^^ storage.type
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.function
# @@@@@@@@@@@@@ definition
# ^ punctuation.section.group.begin
# ^ punctuation.section.brackets.begin
# ^^^^^^^^^ storage.type
Expand All @@ -105,6 +107,8 @@ class TypeName
# <- punctuation.section.brackets.begin
# ^ storage.type
# ^ punctuation.section.brackets.end
# ^^^^^^^^^^^^^ entity.name.function
# @@@@@@@@@@@@@ definition
# ^ punctuation.section.group.begin
# ^ punctuation.section.brackets.begin
# ^^^ storage.type
Expand All @@ -126,3 +130,9 @@ class TypeName
# ^^ variable.other.member
}
}

[TypeName]::MemberMethod1()
# @@@@@@@@@@@@@ reference

$object.MemberMethod2()
# @@@@@@@@@@@@@ reference
3 changes: 3 additions & 0 deletions Tests/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ using module Microsoft.Management
# ^ keyword.other
# ^ variable.parameter

function Test-Path {}
# @@@@@@@@@ definition
<#
# <- punctuation.definition.comment.block.begin
.Synopsis
Expand Down Expand Up @@ -321,6 +323,7 @@ function Verb-Noun {
# ^ meta.attribute punctuation.section.group.end
# ^ meta.attribute punctuation.section.brackets.end
[ValidateScript({Test-Path $_})] #Make sure cmdlets don't break highlighting
# @@@@@@@@@ reference
# <- meta.attribute punctuation.section.brackets.begin
# ^ meta.attribute support.function.attribute
# ^ meta.attribute punctuation.section.group.begin
Expand Down
Loading
Loading