Skip to content

Commit

Permalink
Merge pull request #183 from msftrncs/embeddedSubexpressions
Browse files Browse the repository at this point in the history
Embedded subexpressions
  • Loading branch information
andyleejordan committed Mar 17, 2021
2 parents 2fb86c4 + 84a64bc commit 0778739
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 29 deletions.
61 changes: 36 additions & 25 deletions PowerShellSyntax.tmLanguage
Expand Up @@ -63,7 +63,7 @@
</dict>
<dict>
<key>include</key>
<string>#interpolatedStringContent</string>
<string>#subexpression</string>
</dict>
<dict>
<key>include</key>
Expand Down Expand Up @@ -239,15 +239,20 @@
</dict>
<dict>
<key>begin</key>
<string>(\$)(\()</string>
<string>((\$))(\()</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.variable.powershell</string>
<string>keyword.other.substatement.powershell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.subexpression.powershell</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.section.group.begin.powershell</string>
Expand Down Expand Up @@ -689,7 +694,7 @@
</dict>
</array>
</dict>
<key>interpolatedStringContent</key>
<key>subexpression</key>
<dict>
<key>begin</key>
<string>\(</string>
Expand All @@ -701,8 +706,6 @@
<string>punctuation.section.group.begin.powershell</string>
</dict>
</dict>
<key>contentName</key>
<string>interpolated.simple.source.powershell</string>
<key>end</key>
<string>\)</string>
<key>endCaptures</key>
Expand All @@ -713,65 +716,73 @@
<string>punctuation.section.group.end.powershell</string>
</dict>
</dict>
<key>name</key>
<string>meta.group.simple.subexpression.powershell</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
<dict>
<key>include</key>
<string>#interpolation</string>
</dict>
<dict>
<key>include</key>
<string>#interpolatedStringContent</string>
</dict>
</array>
</dict>
<key>interpolation</key>
<dict>
<key>begin</key>
<string>(\$)(\()</string>
<string>(((\$)))((\())</string>
<key>beginCaptures</key>
<dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.definition.variable.powershell</string>
<string>keyword.other.substatement.powershell</string>
</dict>
<key>2</key>
<dict>
<key>name</key>
<string>punctuation.definition.substatement.powershell</string>
</dict>
<key>3</key>
<dict>
<key>name</key>
<string>punctuation.section.embedded.substatement.begin.powershell</string>
</dict>
<key>4</key>
<dict>
<key>name</key>
<string>punctuation.section.group.begin.powershell</string>
</dict>
<key>5</key>
<dict>
<key>name</key>
<string>punctuation.section.embedded.substatement.begin.powershell</string>
</dict>
</dict>
<key>contentName</key>
<string>interpolated.complex.source.powershell</string>
<key>end</key>
<string>\)</string>
<string>(\))</string>
<key>endCaptures</key>
<dict>
<key>0</key>
<dict>
<key>name</key>
<string>punctuation.section.group.end.powershell</string>
</dict>
<key>1</key>
<dict>
<key>name</key>
<string>punctuation.section.embedded.substatement.end.powershell</string>
</dict>
</dict>
<key>name</key>
<string>meta.embedded.substatement.powershell</string>
<key>patterns</key>
<array>
<dict>
<key>include</key>
<string>$self</string>
</dict>
<dict>
<key>include</key>
<string>#interpolation</string>
</dict>
<dict>
<key>include</key>
<string>#interpolatedStringContent</string>
</dict>
</array>
</dict>
<key>numericConstant</key>
Expand Down
16 changes: 12 additions & 4 deletions spec/testfiles/syntax_test_TheBigTestFile.ps1
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -1204,7 +1211,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
Expand Down Expand Up @@ -1238,7 +1245,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
Expand Down

0 comments on commit 0778739

Please sign in to comment.