diff --git a/PowerShell.sublime-syntax b/PowerShell.sublime-syntax index b9680ab..9a0eb2a 100644 --- a/PowerShell.sublime-syntax +++ b/PowerShell.sublime-syntax @@ -25,7 +25,7 @@ contexts: main: - meta_include_prototype: false - match: '' - push: [statements, imports, shebang] + push: [statements, script-param-block, imports, shebang] shebang: - meta_include_prototype: false @@ -46,6 +46,11 @@ contexts: - include: using-directives - include: else-pop + script-param-block: + - include: attributes + - include: param-block + - include: else-pop + statements: - include: classes - include: functions @@ -591,21 +596,21 @@ contexts: attributes: - match: (\[)\s*(ValidatePattern) captures: - 1: punctuation.section.brackets.begin.powershell - 2: support.function.attribute.powershell + 1: punctuation.definition.annotation.begin.powershell + 2: variable.annotation.powershell push: inside-attribute with_prototype: - include: regex-strings - match: (\[)\s*({{attributes}}) captures: - 1: punctuation.section.brackets.begin.powershell - 2: support.function.attribute.powershell + 1: punctuation.definition.annotation.begin.powershell + 2: variable.annotation.powershell push: inside-attribute inside-attribute: - - meta_scope: meta.attribute.powershell + - meta_scope: meta.annotation.powershell - match: \] - scope: punctuation.section.brackets.end.powershell + scope: punctuation.definition.annotation.end.powershell pop: 1 - match: \( scope: punctuation.section.group.begin.powershell diff --git a/tests/syntax_test_Class.ps1 b/tests/syntax_test_Class.ps1 index 2b926db..2419604 100644 --- a/tests/syntax_test_Class.ps1 +++ b/tests/syntax_test_Class.ps1 @@ -31,10 +31,10 @@ class TypeName # <- punctuation.definition.comment # ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line [ValidateSet("val1", "Val2")] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.class.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell # ^ punctuation.definition.string.begin.powershell @@ -44,7 +44,7 @@ class TypeName # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [string] $P1 #^^^^^^^^^^^^^^^ meta.class.powershell # ^ punctuation.section.brackets.begin.powershell diff --git a/tests/syntax_test_Function.ps1 b/tests/syntax_test_Function.ps1 index ebe8c46..798a0ec 100644 --- a/tests/syntax_test_Function.ps1 +++ b/tests/syntax_test_Function.ps1 @@ -80,10 +80,10 @@ function Verb-Noun { # @@@@@@@@@ definition # ^ punctuation.section.block.begin.powershell [CmdletBinding(DefaultParameterSetName = 'Parameter Set 1', -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell @@ -92,21 +92,21 @@ function Verb-Noun { # ^ punctuation.definition.string.end.powershell # ^ punctuation.separator.sequence.powershell SupportsShouldProcess = $true, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.annotation.powershell # ^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^ constant.language.boolean.true.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell PositionalBinding = $false, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.annotation.powershell # ^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^^ constant.language.boolean.false.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell HelpUri = 'http://www.microsoft.com/', -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.annotation.powershell # ^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell @@ -114,33 +114,34 @@ function Verb-Noun { # ^ punctuation.definition.string.end.powershell # ^ punctuation.separator.sequence.powershell ConfirmImpact = 'Medium')] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell # ^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^^^^ meta.string.powershell string.quoted.single.powershell # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [Alias()] -#^^^^^^^^^^^^ meta.function.powershell -# ^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^ meta.function.powershell +# ^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [OutputType([String])] -#^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell -# ^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell +# ^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^ punctuation.section.brackets.begin.powershell # ^^^^^^ support.type.powershell # ^ punctuation.section.brackets.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell Param #^^^^^^^^ meta.function.powershell # ^^^^^ keyword.declaration.parameter.powershell @@ -151,10 +152,10 @@ function Verb-Noun { # <- comment.line punctuation.definition.comment # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line [Parameter(Mandatory=$true, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell @@ -162,153 +163,177 @@ function Verb-Noun { # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell ValueFromPipeline=$true, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.annotation.powershell # ^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^ constant.language.boolean.true.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell ValueFromPipelineByPropertyName = $true, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.annotation.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^ constant.language.boolean.true.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell ValueFromRemainingArguments=$false, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.annotation.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^^ constant.language.boolean.false.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.separator.sequence.powershell Position=0, -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.annotation.powershell # ^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell # ^ punctuation.separator.sequence.powershell ParameterSetName = 'Parameter Set 1')] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell meta.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell # ^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell # ^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateNotNullOrEmpty()] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateNotNull()] -#^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateNotNullOrEmpty()] - #^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- punctuation.section.brackets.begin - # ^^^^^^^^^^^^^^^^^^^^^ support.function.attribute - # ^ punctuation.section.group.begin - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateCount(0,5)] - #^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- punctuation.section.brackets.begin - # ^^^^^^^^^^^^ support.function.attribute - # ^ punctuation.section.group.begin - # ^ constant.numeric.value - # ^ punctuation.separator - # ^ constant.numeric.value - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell +# ^ punctuation.separator.sequence.powershell +# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateSet("sun", "moon", "earth")] - #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- punctuation.section.brackets.begin - # ^ support.function.attribute - # ^ punctuation.section.group.begin - # ^^^^ string.quoted.double - # ^ punctuation.separator - # ^^^^^^ string.quoted.double - # ^ punctuation.separator - # ^^^^^^^ string.quoted.double - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell +# ^ punctuation.definition.string.begin.powershell +# ^ punctuation.definition.string.end.powershell +# ^ punctuation.separator.sequence.powershell +# ^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell +# ^ punctuation.definition.string.begin.powershell +# ^ punctuation.definition.string.end.powershell +# ^ punctuation.separator.sequence.powershell +# ^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell +# ^ punctuation.definition.string.begin.powershell +# ^ punctuation.definition.string.end.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [Alias("p1")] - #^^^^^^^^^^^^ meta.attribute - # <- punctuation.section.brackets.begin - # ^ support.function.attribute - # ^ punctuation.section.group.begin - # ^^^^ string.quoted.double - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^^^^ meta.string.interpolated.powershell string.quoted.double.powershell +# ^ punctuation.definition.string.begin.powershell +# ^ punctuation.definition.string.end.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell $Param1, - # <- punctuation.definition.variable - # ^ variable.other.readwrite - # ^ punctuation.separator +#^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^ variable.other.readwrite.powershell +# ^ punctuation.definition.variable.powershell +# ^ punctuation.separator.sequence.powershell # Param2 help description - # <- comment.line punctuation.definition.comment - # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^ punctuation.definition.comment [Parameter(ParameterSetName='Parameter Set 1')] - #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute - # ^^^^^^^^ support.function.attribute - # ^^^^^^^^^^^^^^^^ variable.parameter.attribute - # ^ keyword.operator.assignment - # ^^^^^^^^^^^^^^^^ string.quoted.single - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end - # ^ - meta.attribute +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell +# ^ keyword.operator.assignment.powershell +# ^^^^^^^^^^^^^^^^^ meta.string.powershell string.quoted.single.powershell +# ^ punctuation.definition.string.begin.powershell +# ^ punctuation.definition.string.end.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [AllowNull()] - #^^^^^^^^^^^^ meta.attribute - # <- meta.attribute punctuation.section.brackets.begin - # ^ meta.attribute support.function.attribute - # ^ meta.attribute punctuation.section.group.begin - # ^ meta.attribute punctuation.section.group.end - # ^ meta.attribute punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [AllowEmptyCollection()] - #^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- meta.attribute punctuation.section.brackets.begin - # ^ meta.attribute support.function.attribute - # ^ meta.attribute punctuation.section.group.begin - # ^ meta.attribute punctuation.section.group.end - # ^ meta.attribute punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [AllowEmptyString()] - #^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- meta.attribute punctuation.section.brackets.begin - # ^ meta.attribute support.function.attribute - # ^ meta.attribute punctuation.section.group.begin - # ^ meta.attribute punctuation.section.group.end - # ^ meta.attribute punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateScript({$true})] - #^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- meta.attribute punctuation.section.brackets.begin - # ^^^^^^^^^^^^^ support.function.attribute - # ^ punctuation.section.group.begin - # ^ meta.attribute - # ^ punctuation.definition.variable - # ^^^^ constant.language - # ^ meta.attribute - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^^^^^^^ meta.block.powershell +# ^ punctuation.section.braces.begin.powershell +# ^^^^^ constant.language.boolean.true.powershell +# ^ punctuation.definition.variable.powershell +# ^ punctuation.section.braces.end.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateRange(0,5)] - #^^^^^^^^^^^^^^^^^^^ meta.attribute - # <- meta.attribute punctuation.section.brackets.begin - # ^^^^^^^^^^^^ support.function.attribute - # ^ punctuation.section.group.begin - # ^ constant.numeric.value - # ^ punctuation.separator - # ^ constant.numeric.value - # ^ punctuation.section.group.end - # ^ punctuation.section.brackets.end +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell +# ^ punctuation.separator.sequence.powershell +# ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell [int32] #^^^^^^^^^^^^^^ meta.function.powershell # ^ punctuation.section.brackets.begin.powershell @@ -321,13 +346,13 @@ function Verb-Noun { # ^ punctuation.separator.sequence.powershell # Param3 help description - # <- comment.line punctuation.definition.comment - # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^ punctuation.definition.comment [Parameter(ParameterSetName='Another Parameter Set')] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell @@ -335,29 +360,29 @@ function Verb-Noun { # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidatePattern("[a-z]*")] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^ meta.string.interpolated.powershell string.quoted.double.powershell # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateLength(0,15)] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^ meta.number.integer.decimal.powershell constant.numeric.value.powershell # ^ punctuation.separator.sequence.powershell # ^^ meta.number.integer.decimal.powershell constant.numeric.value.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [String] #^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell # ^ punctuation.section.brackets.begin.powershell @@ -370,13 +395,13 @@ function Verb-Noun { # ^ punctuation.separator.sequence.powershell # Param4 help description - # <- comment.line punctuation.definition.comment - # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line +# ^ punctuation.definition.comment [Parameter(ParameterSetName='Parameter Set 1')] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell @@ -384,24 +409,24 @@ function Verb-Noun { # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidateScript({Test-Path $_})] # Make sure cmdlets don't break highlighting -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^ meta.block.powershell # ^ punctuation.section.braces.begin.powershell -# ^^^^^^^^^ meta.function-call.powershell support.function.powershell # @@@@@@@@@ reference +# ^^^^^^^^^ meta.function-call.powershell support.function.powershell # ^^^ meta.function-call.arguments.powershell # ^^ variable.language.powershell # ^ punctuation.definition.variable.powershell # ^ punctuation.section.braces.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.powershell +# ^ punctuation.definition.annotation.end.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.powershell # ^ punctuation.definition.comment.powershell [string] #^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell @@ -418,10 +443,10 @@ function Verb-Noun { # <- comment.line punctuation.definition.comment # ^^^^^^^^^^^^^^^^^^^^^^^ comment.line [Parameter(ParameterSetName='Parameter Set 1')] -#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^ support.function.attribute.powershell +#^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell # ^ keyword.operator.assignment.powershell @@ -429,19 +454,19 @@ function Verb-Noun { # ^ punctuation.definition.string.begin.powershell # ^ punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell [ValidatePattern('(?=^.{1,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$)')] # this regex shouldn't break highlighting #^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.function.powershell meta.block.parameters.powershell -# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.attribute.powershell -# ^ punctuation.section.brackets.begin.powershell -# ^^^^^^^^^^^^^^^ support.function.attribute.powershell +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^^^ variable.annotation.powershell # ^ punctuation.section.group.begin.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.string.powershell # ^ string.quoted.single.powershell punctuation.definition.string.begin.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ source.regexp.embedded # ^ string.quoted.single.powershell punctuation.definition.string.end.powershell # ^ punctuation.section.group.end.powershell -# ^ punctuation.section.brackets.end.powershell +# ^ punctuation.definition.annotation.end.powershell # ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ comment.line.powershell # ^ punctuation.definition.comment.powershell [string] diff --git a/tests/syntax_test_script_params.ps1 b/tests/syntax_test_script_params.ps1 new file mode 100644 index 0000000..ea77419 --- /dev/null +++ b/tests/syntax_test_script_params.ps1 @@ -0,0 +1,29 @@ +# SYNTAX TEST "Packages/PowerShell/PowerShell.sublime-syntax" + + [CmdletBinding(PositionalBinding=$false)] +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ meta.annotation.powershell +# ^ punctuation.definition.annotation.begin.powershell +# ^^^^^^^^^^^^^ variable.annotation.powershell +# ^ punctuation.section.group.begin.powershell +# ^^^^^^^^^^^^^^^^^ variable.parameter.attribute.powershell +# ^ keyword.operator.assignment.powershell +# ^^^^^^ constant.language.boolean.false.powershell +# ^ punctuation.definition.variable.powershell +# ^ punctuation.section.group.end.powershell +# ^ punctuation.definition.annotation.end.powershell + param( +# ^^^^^ keyword.declaration.parameter.powershell +# ^^ meta.block.parameters.powershell +# ^ punctuation.section.block.begin.powershell + [Parameter(Mandatory=$true)] + [string]$base, + + [Parameter(Mandatory=$true)] + [string]$head + ) + + Set-StrictMode -version 2.0 + $ErrorActionPreference="Stop" + + [CmdletBinding(PositionalBinding=$false)] +# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - meta.attribute - meta.annotation