Skip to content

Commit

Permalink
Bump assets/syntaxes/02_Extra/PowerShell from 4a0a076 to 742f0b5 (#…
Browse files Browse the repository at this point in the history
…1935)

* Bump assets/syntaxes/02_Extra/PowerShell from `4a0a076` to `742f0b5`

Bumps [assets/syntaxes/02_Extra/PowerShell](https://github.com/PowerShell/EditorSyntax) from `4a0a076` to `742f0b5`.
- [Release notes](https://github.com/PowerShell/EditorSyntax/releases)
- [Commits](PowerShell/EditorSyntax@4a0a076...742f0b5)

---
updated-dependencies:
- dependency-name: assets/syntaxes/02_Extra/PowerShell
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>

* Do machine-conversion from .tmLanguage to .sublime-syntax

The new .sublime-syntax file is a pure "Tools" -> "Developer" -> "New Syntax
from ..." conversion from a licenced version of Sublime Text, Version 3.1.1,
Build 3176 with the .tmLanguage as the source file. No manual changes has been
made.

* Update regression test and add CHANGELOG.md entry

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Martin Nordholts <enselic@gmail.com>
  • Loading branch information
dependabot[bot] and Enselic authored Dec 12, 2021
1 parent ee1f5a9 commit a02713d
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 51 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
- The `requirements.txt` syntax has been removed due to incompatible license requirements.
- Dart, new highlighter, see #1959 (@Ersikan)
- SCSS and Sass syntaxes updated, see #1766 (@Enselic)
- PowerShell syntax updated, see #1935 (@Enselic)

## New themes

Expand Down
106 changes: 58 additions & 48 deletions assets/syntaxes/02_Extra/PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ contexts:
- include: commands
- include: commentLine
- include: variable
- include: interpolatedStringContent
- include: subexpression
- include: function
- include: attribute
- include: UsingDirective
Expand All @@ -33,32 +33,38 @@ contexts:
- include: doubleQuotedString
- include: scriptblock
- include: doubleQuotedStringEscapes
- match: (?<!')'
- match: '[''\x{2018}-\x{201B}]'
captures:
0: punctuation.definition.string.begin.powershell
push:
- meta_scope: string.quoted.single.powershell
- match: "'(?!')"
- match: '[''\x{2018}-\x{201B}]{2}'
scope: constant.character.escape.powershell
- match: '[''\x{2018}-\x{201B}]'
captures:
0: punctuation.definition.string.end.powershell
pop: true
- match: "''"
scope: constant.character.escape.powershell
- match: \@"(?=$)
- match: '(@["\x{201C}-\x{201E}])\s*$'
captures:
1: punctuation.definition.string.begin.powershell
push:
- meta_scope: string.quoted.double.heredoc.powershell
- match: ^"@
- match: '^["\x{201C}-\x{201E}]@'
captures:
0: punctuation.definition.string.end.powershell
pop: true
- include: variableNoProperty
- include: doubleQuotedStringEscapes
- include: interpolation
- match: \@'(?=$)
- match: '(@[''\x{2018}-\x{201B}])\s*$'
captures:
1: punctuation.definition.string.begin.powershell
push:
- meta_scope: string.quoted.single.heredoc.powershell
- match: ^'@
- match: '^[''\x{2018}-\x{201B}]@'
captures:
0: punctuation.definition.string.end.powershell
pop: true
- match: "''"
scope: constant.character.escape.powershell
- include: numericConstant
- match: (@)(\()
captures:
Expand All @@ -71,11 +77,12 @@ contexts:
0: punctuation.section.group.end.powershell
pop: true
- include: main
- match: (\$)(\()
- match: ((\$))(\()
comment: "TODO: move to repo; make recursive."
captures:
1: punctuation.definition.variable.powershell
2: punctuation.section.group.begin.powershell
1: keyword.other.substatement.powershell
2: punctuation.definition.subexpression.powershell
3: punctuation.section.group.begin.powershell
push:
- meta_scope: meta.group.complex.subexpression.powershell
- match: \)
Expand All @@ -85,7 +92,7 @@ contexts:
- include: main
- match: '(\b(([A-Za-z0-9\-_\.]+)\.(?i:exe|com|cmd|bat))\b)'
scope: support.function.powershell
- match: (?<!\w|-|\.)((?i:begin|break|catch|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
- match: (?<!\w|-|\.)((?i:begin|break|catch|clean|continue|data|default|define|do|dynamicparam|else|elseif|end|exit|finally|for|from|if|in|inlinescript|parallel|param|process|return|sequence|switch|throw|trap|try|until|var|while)|%|\?)(?!\w)
scope: keyword.control.powershell
- match: '(?<!\w|-|[^\)]\.)((?i:(foreach|where)(?!-object))|%|\?)(?!\w)'
scope: keyword.control.powershell
Expand Down Expand Up @@ -135,7 +142,7 @@ contexts:
- meta_scope: meta.requires.powershell
- match: $
pop: true
- match: \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version)
- match: \-(?i:Modules|PSSnapin|RunAsAdministrator|ShellId|Version|Assembly|PSEdition)
scope: keyword.other.powershell
- match: '(?<!-)\b\p{L}+|\d+(?:\.\d+)*'
scope: variable.parameter.powershell
Expand Down Expand Up @@ -187,51 +194,53 @@ contexts:
comment: Builtin cmdlets with reserved verbs
scope: support.function.powershell
commentEmbeddedDocs:
- match: ^(?i:(?:\s?|#)+(\.)(COMPONENT|DESCRIPTION|EXAMPLE|EXTERNALHELP|FORWARDHELPCATEGORY|FORWARDHELPTARGETNAME|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|REMOTEHELPRUNSPACE|ROLE|SYNOPSIS))
- match: (?:^|\G)(?i:\s*(\.)(COMPONENT|DESCRIPTION|EXAMPLE|FUNCTIONALITY|INPUTS|LINK|NOTES|OUTPUTS|ROLE|SYNOPSIS))\s*$
comment: these embedded doc keywords do not support arguments, must be the only thing on the line
scope: comment.documentation.embedded.powershell
captures:
1: constant.string.documentation.powershell
2: keyword.operator.documentation.powershell
- match: '(?i:\s?(\.)(PARAMETER|FORWARDHELPTARGETNAME|FORWARDHELPCATEGORY|REMOTEHELPRUNSPACE|EXTERNALHELP)\s+([a-z0-9-_]+))'
- match: (?:^|\G)(?i:\s*(\.)(EXTERNALHELP|FORWARDHELP(?:CATEGORY|TARGETNAME)|PARAMETER|REMOTEHELPRUNSPACE))\s+(.+?)\s*$
comment: these embedded doc keywords require arguments though the type required may be inconsistent, they may not all be able to use the same argument match
scope: comment.documentation.embedded.powershell
captures:
1: constant.string.documentation.powershell
2: keyword.operator.documentation.powershell
3: keyword.operator.documentation.powershell
commentLine:
- match: '(?<![`\\-])#'
- match: '(?<![`\\-])(#)#*'
captures:
0: punctuation.definition.comment.powershell
1: punctuation.definition.comment.powershell
push:
- meta_scope: comment.line.powershell
- match: $\n?
captures:
0: punctuation.definition.comment.powershell
1: punctuation.definition.comment.powershell
pop: true
- include: commentEmbeddedDocs
- include: RequiresDirective
doubleQuotedString:
- match: (?<!(?<!`)")"
- match: '["\x{201C}-\x{201E}]'
captures:
0: punctuation.definition.string.begin.powershell
push:
- meta_scope: string.quoted.double.powershell
- match: '"(?!")'
captures:
0: punctuation.definition.string.end.powershell
pop: true
- match: '(?i)\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,64}\b'
- include: variableNoProperty
- include: doubleQuotedStringEscapes
- match: '["\x{201C}-\x{201E}]{2}'
scope: constant.character.escape.powershell
- include: interpolation
- match: '`\s*$'
scope: keyword.other.powershell
- match: '["\x{201C}-\x{201E}]'
captures:
0: punctuation.definition.string.end.powershell
pop: true
doubleQuotedStringEscapes:
- match: '`[`0abefnrtv"''$]'
- match: '`[`0abefnrtv''"\x{2018}-\x{201E}$]'
scope: constant.character.escape.powershell
- include: unicodeEscape
- match: '""'
scope: constant.character.escape.powershell
function:
- match: '^(?:\s*+)(?i)(function|filter|configuration|workflow)\s+(?:(global|local|script|private):)?((?:\p{L}|\d|_|-|\.)+)'
captures:
Expand Down Expand Up @@ -263,33 +272,23 @@ contexts:
4: keyword.operator.assignment.powershell
- include: scriptblock
- include: main
interpolatedStringContent:
- match: \(
captures:
0: punctuation.section.group.begin.powershell
push:
- meta_content_scope: interpolated.simple.source.powershell
- match: \)
captures:
0: punctuation.section.group.end.powershell
pop: true
- include: main
- include: interpolation
- include: interpolatedStringContent
interpolation:
- match: (\$)(\()
- match: (((\$)))((\())
captures:
1: punctuation.definition.variable.powershell
2: punctuation.section.group.begin.powershell
1: keyword.other.substatement.powershell
2: punctuation.definition.substatement.powershell
3: punctuation.section.embedded.substatement.begin.powershell
4: punctuation.section.group.begin.powershell
5: punctuation.section.embedded.substatement.begin.powershell
push:
- meta_scope: meta.embedded.substatement.powershell
- meta_content_scope: interpolated.complex.source.powershell
- match: \)
- match: (\))
captures:
0: punctuation.section.group.end.powershell
1: punctuation.section.embedded.substatement.end.powershell
pop: true
- include: main
- include: interpolation
- include: interpolatedStringContent
numericConstant:
- match: '(?<!\w)([-+]?0(?:x|X)[0-9a-fA-F_]+(?:U|u|L|l|UL|Ul|uL|ul|LU|Lu|lU|lu)?)((?i:[kmgtp]b)?)\b'
captures:
Expand Down Expand Up @@ -330,6 +329,17 @@ contexts:
0: punctuation.section.braces.end.powershell
pop: true
- include: main
subexpression:
- match: \(
captures:
0: punctuation.section.group.begin.powershell
push:
- meta_scope: meta.group.simple.subexpression.powershell
- match: \)
captures:
0: punctuation.section.group.end.powershell
pop: true
- include: main
type:
- match: '\['
captures:
Expand Down
4 changes: 2 additions & 2 deletions tests/syntax-tests/highlighted/PowerShell/test.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
 'Path does not contain Rust'
}

(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
(5..30) | ? { $_ % (2 * 2 + 1) -eq 0 } | % {"In {0} minutes, the time will be {1}." -f $_, $( Get-FutureTime $_ )}
$later = Get-FutureTime -Minutes $( Get-Random -Minimum 60 -Maximum 120 )
"The time will be " + $later + " later."

0 comments on commit a02713d

Please sign in to comment.