Skip to content

Commit 0778739

Browse files
Merge pull request #183 from msftrncs/embeddedSubexpressions
Embedded subexpressions
2 parents 2fb86c4 + 84a64bc commit 0778739

File tree

2 files changed

+48
-29
lines changed

2 files changed

+48
-29
lines changed

PowerShellSyntax.tmLanguage

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
</dict>
6464
<dict>
6565
<key>include</key>
66-
<string>#interpolatedStringContent</string>
66+
<string>#subexpression</string>
6767
</dict>
6868
<dict>
6969
<key>include</key>
@@ -239,15 +239,20 @@
239239
</dict>
240240
<dict>
241241
<key>begin</key>
242-
<string>(\$)(\()</string>
242+
<string>((\$))(\()</string>
243243
<key>beginCaptures</key>
244244
<dict>
245245
<key>1</key>
246246
<dict>
247247
<key>name</key>
248-
<string>punctuation.definition.variable.powershell</string>
248+
<string>keyword.other.substatement.powershell</string>
249249
</dict>
250250
<key>2</key>
251+
<dict>
252+
<key>name</key>
253+
<string>punctuation.definition.subexpression.powershell</string>
254+
</dict>
255+
<key>3</key>
251256
<dict>
252257
<key>name</key>
253258
<string>punctuation.section.group.begin.powershell</string>
@@ -689,7 +694,7 @@
689694
</dict>
690695
</array>
691696
</dict>
692-
<key>interpolatedStringContent</key>
697+
<key>subexpression</key>
693698
<dict>
694699
<key>begin</key>
695700
<string>\(</string>
@@ -701,8 +706,6 @@
701706
<string>punctuation.section.group.begin.powershell</string>
702707
</dict>
703708
</dict>
704-
<key>contentName</key>
705-
<string>interpolated.simple.source.powershell</string>
706709
<key>end</key>
707710
<string>\)</string>
708711
<key>endCaptures</key>
@@ -713,65 +716,73 @@
713716
<string>punctuation.section.group.end.powershell</string>
714717
</dict>
715718
</dict>
719+
<key>name</key>
720+
<string>meta.group.simple.subexpression.powershell</string>
716721
<key>patterns</key>
717722
<array>
718723
<dict>
719724
<key>include</key>
720725
<string>$self</string>
721726
</dict>
722-
<dict>
723-
<key>include</key>
724-
<string>#interpolation</string>
725-
</dict>
726-
<dict>
727-
<key>include</key>
728-
<string>#interpolatedStringContent</string>
729-
</dict>
730727
</array>
731728
</dict>
732729
<key>interpolation</key>
733730
<dict>
734731
<key>begin</key>
735-
<string>(\$)(\()</string>
732+
<string>(((\$)))((\())</string>
736733
<key>beginCaptures</key>
737734
<dict>
738735
<key>1</key>
739736
<dict>
740737
<key>name</key>
741-
<string>punctuation.definition.variable.powershell</string>
738+
<string>keyword.other.substatement.powershell</string>
742739
</dict>
743740
<key>2</key>
741+
<dict>
742+
<key>name</key>
743+
<string>punctuation.definition.substatement.powershell</string>
744+
</dict>
745+
<key>3</key>
746+
<dict>
747+
<key>name</key>
748+
<string>punctuation.section.embedded.substatement.begin.powershell</string>
749+
</dict>
750+
<key>4</key>
744751
<dict>
745752
<key>name</key>
746753
<string>punctuation.section.group.begin.powershell</string>
747754
</dict>
755+
<key>5</key>
756+
<dict>
757+
<key>name</key>
758+
<string>punctuation.section.embedded.substatement.begin.powershell</string>
759+
</dict>
748760
</dict>
749761
<key>contentName</key>
750762
<string>interpolated.complex.source.powershell</string>
751763
<key>end</key>
752-
<string>\)</string>
764+
<string>(\))</string>
753765
<key>endCaptures</key>
754766
<dict>
755767
<key>0</key>
756768
<dict>
757769
<key>name</key>
758770
<string>punctuation.section.group.end.powershell</string>
759771
</dict>
772+
<key>1</key>
773+
<dict>
774+
<key>name</key>
775+
<string>punctuation.section.embedded.substatement.end.powershell</string>
776+
</dict>
760777
</dict>
778+
<key>name</key>
779+
<string>meta.embedded.substatement.powershell</string>
761780
<key>patterns</key>
762781
<array>
763782
<dict>
764783
<key>include</key>
765784
<string>$self</string>
766785
</dict>
767-
<dict>
768-
<key>include</key>
769-
<string>#interpolation</string>
770-
</dict>
771-
<dict>
772-
<key>include</key>
773-
<string>#interpolatedStringContent</string>
774-
</dict>
775786
</array>
776787
</dict>
777788
<key>numericConstant</key>

spec/testfiles/syntax_test_TheBigTestFile.ps1

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,11 @@ $variable.Name
153153
"This is my $($variable.Name)!"
154154
# <- punctuation.definition.string.begin.powershell string.quoted.double.powershell
155155
# ^^^^^^^^^^ ^^ string.quoted.double.powershell
156-
# ^ ^ punctuation.definition.variable.powershell
156+
# ^^ punctuation.section.embedded.substatement.begin.powershell
157+
# ^ punctuation.section.embedded.substatement.end.powershell
158+
# ^^^^^^^^^^^^^^^^^ meta.embedded.substatement.powershell
159+
# ^ keyword.other.substatement.powershell
160+
# ^ punctuation.definition.variable.powershell
157161
# ^ punctuation.section.group.begin.powershell
158162
# ^ punctuation.section.group.end.powershell
159163
# ^^^^^^^^ variable.other.readwrite.powershell
@@ -372,7 +376,10 @@ $a3[1..2]
372376
# ^^^^^^^^^^^^ string.quoted.double.powershell
373377
"$(Invoke-Something)"
374378
# ^ ^ string.quoted.double.powershell
375-
# ^ punctuation.definition.variable.powershell
379+
# ^^ punctuation.section.embedded.substatement.begin.powershell
380+
# ^ punctuation.section.embedded.substatement.end.powershell
381+
# ^^^^^^^^^^^^^^^^^^^ meta.embedded.substatement.powershell
382+
# ^ keyword.other.substatement.powershell
376383
# ^ punctuation.section.group.begin.powershell
377384
# ^ interpolated.complex.source.powershell support.function.powershell
378385
# ^ punctuation.section.group.end.powershell
@@ -1204,7 +1211,7 @@ $file = join-path $env:SystemDrive "$([System.io.path]::GetRandomFileName()).ps1
12041211
# ^ support.function.powershell
12051212
# ^ support.variable.drive.powershell
12061213
# ^ variable.other.readwrite.powershell
1207-
# ^ string.quoted.double.powershell punctuation.definition.variable.powershell
1214+
# ^ string.quoted.double.powershell punctuation.definition.substatement.powershell punctuation.section.embedded.substatement.begin.powershell
12081215
# ^ storage.type.powershell
12091216
$ScriptBlock | Out-File $file -Force
12101217
# <- punctuation.definition.variable.powershell
@@ -1238,7 +1245,8 @@ get-thing | Out-WithYou > $null # destroy
12381245
# ^^ constant.character.escape.powershell
12391246
# ^^ ^^ ^^ ^^ ^^ not:constant.character.escape.powershell
12401247
"When you call a method: $( get-number | %{ invoke-command $( [string]::format("Like (this{0})","what?") ) $var } )"
1241-
# ^ ^ punctuation.definition.variable.powershell
1248+
# ^ string.quoted.double.powershell punctuation.definition.substatement.powershell punctuation.section.embedded.substatement.begin.powershell
1249+
# ^ punctuation.definition.variable.powershell
12421250
# ^ keyword.operator.other.powershell
12431251
# ^ ^ meta.group.complex.subexpression.powershell punctuation.section.group.begin.powershell
12441252
# ^ storage.type.powershell

0 commit comments

Comments
 (0)