From d14162eef26648180332a24899558cb11b6f3986 Mon Sep 17 00:00:00 2001 From: msftrncs Date: Fri, 16 Aug 2019 22:53:12 -0500 Subject: [PATCH 1/2] imrpove embedded subexpressions rename #interpolatedStringContent to subexpression. change subexpression scope to not include 'interpolation'. change scopes for #interpolation to include embedded, keyword.other was punctuation.definition.variable. Change scope for regular `$()`, keyword.other was punctuation.definition.variable. removed redundant includes from #subexpression and #interpolation. --- PowerShellSyntax.tmLanguage | 61 ++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/PowerShellSyntax.tmLanguage b/PowerShellSyntax.tmLanguage index 11bab40..6516fc0 100644 --- a/PowerShellSyntax.tmLanguage +++ b/PowerShellSyntax.tmLanguage @@ -63,7 +63,7 @@ include - #interpolatedStringContent + #subexpression include @@ -214,15 +214,20 @@ begin - (\$)(\() + ((\$))(\() beginCaptures 1 name - punctuation.definition.variable.powershell + keyword.other.substatement.powershell 2 + + name + punctuation.definition.subexpression.powershell + + 3 name punctuation.section.group.begin.powershell @@ -666,7 +671,7 @@ - interpolatedStringContent + subexpression begin \( @@ -678,8 +683,6 @@ punctuation.section.group.begin.powershell - contentName - interpolated.simple.source.powershell end \) endCaptures @@ -690,43 +693,52 @@ punctuation.section.group.end.powershell + name + meta.group.simple.subexpression.powershell patterns include $self - - include - #interpolation - - - include - #interpolatedStringContent - interpolation begin - (\$)(\() + (((\$)))((\()) beginCaptures 1 name - punctuation.definition.variable.powershell + keyword.other.substatement.powershell 2 + + name + punctuation.definition.substatement.powershell + + 3 + + name + punctuation.section.embedded.substatement.begin.powershell + + 4 name punctuation.section.group.begin.powershell + 5 + + name + punctuation.section.embedded.substatement.begin.powershell + contentName interpolated.complex.source.powershell end - \) + (\)) endCaptures 0 @@ -734,21 +746,20 @@ name punctuation.section.group.end.powershell + 1 + + name + punctuation.section.embedded.substatement.end.powershell + + name + meta.embedded.substatement.powershell patterns include $self - - include - #interpolation - - - include - #interpolatedStringContent - numericConstant From 84a64bcaf1650f250e087ccc13598bff91198743 Mon Sep 17 00:00:00 2001 From: msftrncs Date: Fri, 16 Aug 2019 22:57:41 -0500 Subject: [PATCH 2/2] Adjust test, of embedded substatements in double quoted strings. --- spec/testfiles/syntax_test_TheBigTestFile.ps1 | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/spec/testfiles/syntax_test_TheBigTestFile.ps1 b/spec/testfiles/syntax_test_TheBigTestFile.ps1 index 83a1a43..1516e37 100644 --- a/spec/testfiles/syntax_test_TheBigTestFile.ps1 +++ b/spec/testfiles/syntax_test_TheBigTestFile.ps1 @@ -153,7 +153,11 @@ $variable.Name "This is my $($variable.Name)!" # <- punctuation.definition.string.begin.powershell string.quoted.double.powershell # ^^^^^^^^^^ ^^ string.quoted.double.powershell -# ^ ^ punctuation.definition.variable.powershell +# ^^ punctuation.section.embedded.substatement.begin.powershell +# ^ punctuation.section.embedded.substatement.end.powershell +# ^^^^^^^^^^^^^^^^^ meta.embedded.substatement.powershell +# ^ keyword.other.substatement.powershell +# ^ punctuation.definition.variable.powershell # ^ punctuation.section.group.begin.powershell # ^ punctuation.section.group.end.powershell # ^^^^^^^^ variable.other.readwrite.powershell @@ -372,7 +376,10 @@ $a3[1..2] # ^^^^^^^^^^^^ string.quoted.double.powershell "$(Invoke-Something)" # ^ ^ string.quoted.double.powershell -# ^ punctuation.definition.variable.powershell +# ^^ punctuation.section.embedded.substatement.begin.powershell +# ^ punctuation.section.embedded.substatement.end.powershell +# ^^^^^^^^^^^^^^^^^^^ meta.embedded.substatement.powershell +# ^ keyword.other.substatement.powershell # ^ punctuation.section.group.begin.powershell # ^ interpolated.complex.source.powershell support.function.powershell # ^ punctuation.section.group.end.powershell @@ -1183,7 +1190,7 @@ $file = join-path $env:SystemDrive "$([System.io.path]::GetRandomFileName()).ps1 # ^ support.function.powershell # ^ support.variable.drive.powershell # ^ variable.other.readwrite.powershell -# ^ string.quoted.double.powershell punctuation.definition.variable.powershell +# ^ string.quoted.double.powershell punctuation.definition.substatement.powershell punctuation.section.embedded.substatement.begin.powershell # ^ storage.type.powershell $ScriptBlock | Out-File $file -Force # <- punctuation.definition.variable.powershell @@ -1217,7 +1224,8 @@ get-thing | Out-WithYou > $null # destroy # ^^ constant.character.escape.powershell # ^^ ^^ ^^ ^^ ^^ not:constant.character.escape.powershell "When you call a method: $( get-number | %{ invoke-command $( [string]::format("Like (this{0})","what?") ) $var } )" -# ^ ^ punctuation.definition.variable.powershell +# ^ string.quoted.double.powershell punctuation.definition.substatement.powershell punctuation.section.embedded.substatement.begin.powershell +# ^ punctuation.definition.variable.powershell # ^ keyword.operator.other.powershell # ^ ^ meta.group.complex.subexpression.powershell punctuation.section.group.begin.powershell # ^ storage.type.powershell