Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't match keywords if they are preceded by a dot and add the 'sequence' keyword #186

Merged
merged 7 commits into from
Jan 10, 2025
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
15 changes: 11 additions & 4 deletions PowerShell.sublime-syntax
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ contexts:
- include: main
- match: \b[\w.-]+\.(?i:exe|com|cmd|bat)\b
scope: variable.function.powershell
# Consume a string with a trailing dot
# to prevent members with particular names from being recognized as keywords.
- match: \b[\w-]+(?=\.)
matteocoder marked this conversation as resolved.
Show resolved Hide resolved
scope: variable.other.object.powershell
push: members
# Exceptions
- match: \b(?i:throw){{kebab_break}}
scope: keyword.control.exception.raise.powershell
Expand All @@ -100,6 +105,8 @@ contexts:
# Begin/End
- match: \b(?i:begin){{kebab_break}}
scope: keyword.context.block.begin.powershell
- match: \b(?i:process){{kebab_break}}
scope: keyword.context.block.process.powershell
- match: \b(?i:end){{kebab_break}}
scope: keyword.context.block.end.powershell
- match: \b(?i:clean){{kebab_break}}
Expand Down Expand Up @@ -129,7 +136,7 @@ contexts:
- match: \b(?i:(?:dynamic)?param){{kebab_break}}
scope: keyword.declaration.parameter.powershell # This scope is not standard
# Uncategorized keywords
- match: \b(?i:data|default|define|from|in|inlinescript|parallel|process){{kebab_break}}
- match: \b(?i:data|default|define|from|in|inlinescript|parallel|sequence){{kebab_break}}
scope: keyword.control.powershell
- match: \B--%\B
scope: keyword.control.powershell
Expand Down Expand Up @@ -292,10 +299,10 @@ contexts:
(?xi:
\b(
Mandatory | ValueFromPipeline(?:ByPropertyName)?
| ValueFromRemainingArguments | Position
| ValueFromRemainingArguments | Position(?:alBinding)?
| (?:Default)?ParameterSetName | SupportsShouldProcess | SupportsPaging
| PositionalBinding | HelpUri | ConfirmImpact | HelpMessage
)
| HelpUri | ConfirmImpact | HelpMessage
)\b
\s*(=)?
)
captures:
Expand Down
2 changes: 1 addition & 1 deletion Tests/syntax_test_Function.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ function Verb-Noun {
{
}
Process {
# <- keyword.control
# <- keyword.context.block.process
if ($pscmdlet.ShouldProcess("Target", "Operation")) {
# <- keyword.control
# ^ punctuation.section.group.begin
Expand Down
6 changes: 6 additions & 0 deletions Tests/syntax_test_PowerShell.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,7 @@
# ^^ constant.numeric.float
1.d
# ^^^ constant.numeric.float
1.lGB

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[constant.numeric.float - unclear whether float or int] does not match scope [source.powershell]

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[keyword.other.unit] does not match scope [source.powershell]

Check failure on line 478 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[keyword.other.unit] does not match scope [source.powershell]
# ^^^ constant.numeric.float - unclear whether float or int
# ^^ keyword.other.unit
1.dGB
Expand Down Expand Up @@ -522,7 +522,7 @@
# ^^ constant.numeric.integer
# ^^^ constant.numeric.float
# ^ keyword.operator
-10.002L

Check failure on line 525 in Tests/syntax_test_PowerShell.ps1

View workflow job for this annotation

GitHub Actions / Syntax Tests (4102)

[constant.numeric.float - unclear whether float or int] does not match scope [source.powershell]
# ^ keyword.operator.unary
# ^^^^^^^ constant.numeric.float - unclear whether float or int
$x..5.40D
Expand Down Expand Up @@ -1360,6 +1360,12 @@
# ^^^^^^^ - keyword.control
New-Object -TypeName System.Data
# ^^^^ - keyword.control
New-Object -TypeName Sy-stem.if
# ^^ - keyword.control
New-Object -TypeName S_ystem.Clean
# ^^^^^ - keyword.control
New-Object -TypeName Sy_stem-.Throw
# ^^^^^ - keyword.control
echo `"test`"
# ^^^^^^^^^ - string.quoted
# ^^ constant.character.escape
Expand Down
Loading