diff options
author | dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> | 2021-12-12 19:41:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-12 19:41:04 +0100 |
commit | a02713dc15818dd2d82d5a38b45d2cc33a4de95c (patch) | |
tree | e02bdc93dcbacc3f73a50a63b23447b6a281d56c | |
parent | ee1f5a9e89a716ba1856c5f59393ea32e253c8d9 (diff) |
* 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](https://github.com/PowerShell/EditorSyntax/compare/4a0a076661d26473cac71b9a17e6a759e9b1c643...742f0b5d4b60f5930c0b47fcc1f646860521296e)
---
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>
-rw-r--r-- | CHANGELOG.md | 1 | ||||
m--------- | assets/syntaxes/02_Extra/PowerShell | 0 | ||||
-rw-r--r-- | assets/syntaxes/02_Extra/PowerShell.sublime-syntax | 106 | ||||
-rw-r--r-- | tests/syntax-tests/highlighted/PowerShell/test.ps1 | 4 |
4 files changed, 61 insertions, 50 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 8c2df7ea..a4a2f286 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/assets/syntaxes/02_Extra/PowerShell b/assets/syntaxes/02_Extra/PowerShell -Subproject 4a0a076661d26473cac71b9a17e6a759e9b1c64 +Subproject 742f0b5d4b60f5930c0b47fcc1f646860521296 diff --git a/assets/syntaxes/02_Extra/PowerShell.sublime-syntax b/assets/syntaxes/02_Extra/PowerShell.sublime-syntax index be84b1d4..3a452a64 100644 --- a/assets/syntaxes/02_Extra/PowerShell.sublime-syntax +++ b/assets/syntaxes/02_Extra/PowerShell.sublime-syntax @@ -24,7 +24,7 @@ contexts: - include: commands - include: commentLine - include: variable - - include: interpolatedStringContent + - include: subexpression - include: function - include: attribute - include: UsingDirective @@ -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: @@ -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: \) @@ -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 @@ -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 @@ -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: @@ -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: @@ -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: diff --git a/tests/syntax-tests/highlighted/PowerShell/test.ps1 b/tests/syntax-tests/highlighted/PowerShell/test.ps1 index 915b6072..aae615d5 100644 --- a/tests/syntax-tests/highlighted/PowerShell/test.ps1 +++ b/tests/syntax-tests/highlighted/PowerShell/test.ps1 @@ -20,6 +20,6 @@ [38;2;248;248;242m [0m[38;2;230;219;116m'[0m[38;2;230;219;116mPath does not contain Rust[0m[38;2;230;219;116m'[0m [38;2;248;248;242m}[0m -[38;2;248;248;242m([0m[38;2;190;132;255m5[0m[38;2;249;38;114m..[0m[38;2;190;132;255m30[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m|[0m[38;2;248;248;242m [0m[38;2;249;38;114m?[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;190;132;255m2[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m-eq[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m|[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;230;219;116m"[0m[38;2;230;219;116mIn {0} minutes, the time will be {1}.[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m-f[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m([0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-FutureTime[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;248;248;242m [0m[38;2;248;248;242m)[0m[38;2;248;248;242m}[0m -[38;2;255;255;255m$[0m[38;2;255;255;255mlater[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-FutureTime[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMinutes [0m[38;2;255;255;255m$[0m[38;2;248;248;242m([0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-Random[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMinimum [0m[38;2;190;132;255m60[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMaximum [0m[38;2;190;132;255m120[0m[38;2;248;248;242m [0m[38;2;248;248;242m)[0m +[38;2;248;248;242m([0m[38;2;190;132;255m5[0m[38;2;249;38;114m..[0m[38;2;190;132;255m30[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m|[0m[38;2;248;248;242m [0m[38;2;249;38;114m?[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m [0m[38;2;248;248;242m([0m[38;2;190;132;255m2[0m[38;2;248;248;242m [0m[38;2;249;38;114m*[0m[38;2;248;248;242m [0m[38;2;190;132;255m2[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;190;132;255m1[0m[38;2;248;248;242m)[0m[38;2;248;248;242m [0m[38;2;249;38;114m-eq[0m[38;2;248;248;242m [0m[38;2;190;132;255m0[0m[38;2;248;248;242m [0m[38;2;248;248;242m}[0m[38;2;248;248;242m [0m[38;2;249;38;114m|[0m[38;2;248;248;242m [0m[38;2;249;38;114m%[0m[38;2;248;248;242m [0m[38;2;248;248;242m{[0m[38;2;230;219;116m"[0m[38;2;230;219;116mIn {0} minutes, the time will be {1}.[0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m-f[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;249;38;114m,[0m[38;2;248;248;242m [0m[38;2;249;38;114m$[0m[38;2;248;248;242m([0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-FutureTime[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;248;248;242m_[0m[38;2;248;248;242m [0m[38;2;248;248;242m)[0m[38;2;248;248;242m}[0m +[38;2;255;255;255m$[0m[38;2;255;255;255mlater[0m[38;2;248;248;242m [0m[38;2;249;38;114m=[0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-FutureTime[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMinutes [0m[38;2;249;38;114m$[0m[38;2;248;248;242m([0m[38;2;248;248;242m [0m[38;2;102;217;239mGet-Random[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMinimum [0m[38;2;190;132;255m60[0m[38;2;248;248;242m [0m[38;2;249;38;114m-[0m[38;2;248;248;242mMaximum [0m[38;2;190;132;255m120[0m[38;2;248;248;242m [0m[38;2;248;248;242m)[0m [38;2;230;219;116m"[0m[38;2;230;219;116mThe time will be [0m[38;2;230;219;116m"[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;255;255;255m$[0m[38;2;255;255;255mlater[0m[38;2;248;248;242m [0m[38;2;249;38;114m+[0m[38;2;248;248;242m [0m[38;2;230;219;116m"[0m[38;2;230;219;116m later.[0m[38;2;230;219;116m"[0m |