Skip to content

Commit 1fc5327

Browse files
committed
restrict requires to single line
1 parent 4ee1344 commit 1fc5327

File tree

1 file changed

+62
-43
lines changed

1 file changed

+62
-43
lines changed

PowerShellSyntax.tmLanguage

+62-43
Original file line numberDiff line numberDiff line change
@@ -5764,9 +5764,13 @@
57645764
</dict>
57655765
<key>RequiresDirective</key>
57665766
<dict>
5767-
<key>begin</key>
5767+
<key>comment</key>
5768+
<string>requires directive must be on single line, so capture and tokenize, current PS &lt;= 6.2 allow `requires` keyword without delimiter, but the parameters must follow with a delimiter!</string>
5769+
<key>oldbegin</key>
57685770
<string>^\s*(#)((?i:requires))(?![^\s{(,;&amp;|)}])</string>
5769-
<key>beginCaptures</key>
5771+
<key>match</key>
5772+
<string>^\s*(#)((?i:requires))(.?)(.*)$</string>
5773+
<key>captures</key>
57705774
<dict>
57715775
<key>1</key>
57725776
<dict>
@@ -5778,55 +5782,70 @@
57785782
<key>name</key>
57795783
<string>keyword.control.requires.powershell</string>
57805784
</dict>
5781-
</dict>
5782-
<key>end</key>
5783-
<string>$</string>
5784-
<key>name</key>
5785-
<string>comment.line.powershell meta.requires.powershell</string>
5786-
<key>patterns</key>
5787-
<array>
5785+
<key>3</key>
57885786
<dict>
5789-
<key>match</key>
5790-
<string>([\x{2013}-\x{2015}-](?i:Modules|PSSnapin|PSEdition|RunAsAdministrator|ShellId|Version)\b)(:)?</string>
5791-
<key>captures</key>
5792-
<dict>
5793-
<key>1</key>
5787+
<key>patterns</key>
5788+
<array>
57945789
<dict>
5790+
<key>match</key>
5791+
<string>\S</string>
57955792
<key>name</key>
5796-
<string>entity.name.parameter.powershell</string>
5793+
<string>invalid.source.powershell</string>
5794+
</dict>
5795+
</array>
5796+
</dict>
5797+
<key>4</key>
5798+
<dict>
5799+
<key>patterns</key>
5800+
<array>
5801+
<dict>
5802+
<key>match</key>
5803+
<string>([\x{2013}-\x{2015}-](?i:Modules|PSSnapin|PSEdition|RunAsAdministrator|ShellId|Version)\b)(:)?</string>
5804+
<key>captures</key>
5805+
<dict>
5806+
<key>1</key>
5807+
<dict>
5808+
<key>name</key>
5809+
<string>entity.name.parameter.powershell</string>
5810+
</dict>
5811+
<key>2</key>
5812+
<dict>
5813+
<key>name</key>
5814+
<string>punctuation.separator.parameter-value.powershell</string>
5815+
</dict>
5816+
</dict>
57975817
</dict>
5798-
<key>2</key>
57995818
<dict>
5819+
<key>comment</key>
5820+
<string>needs custom argument handler, single line quoted or unquoted arguments</string>
5821+
<key>match</key>
5822+
<string>(?&lt;!\x{2013}-\x{2015}-)\b\p{L}+|\d+(?:\.\d+)*</string>
58005823
<key>name</key>
5801-
<string>punctuation.separator.parameter-value.powershell</string>
5824+
<string>variable.parameter.powershell</string>
58025825
</dict>
5803-
</dict>
5804-
</dict>
5805-
<dict>
5806-
<key>comment</key>
5807-
<string>needs custom argument handler, single line quoted or unquoted arguments</string>
5808-
<key>match</key>
5809-
<string>(?&lt;!\x{2013}-\x{2015}-)\b\p{L}+|\d+(?:\.\d+)*</string>
5810-
<key>name</key>
5811-
<string>variable.parameter.powershell</string>
5812-
</dict>
5813-
<dict>
5814-
<key>match</key>
5815-
<string>,</string>
5816-
<key>name</key>
5817-
<string>punctuation.separator.powershell</string>
5818-
</dict>
5819-
<dict>
5820-
<key>comment</key>
5821-
<string>needs custom hashtable that does not auto continue to next line</string>
5822-
<key>include</key>
5823-
<string>#hashtable</string>
5824-
</dict>
5825-
<dict>
5826-
<key>include</key>
5827-
<string>#notCode</string>
5826+
<dict>
5827+
<key>match</key>
5828+
<string>,</string>
5829+
<key>name</key>
5830+
<string>punctuation.separator.powershell</string>
5831+
</dict>
5832+
<dict>
5833+
<key>comment</key>
5834+
<string>needs custom hashtable that does not auto continue to next line</string>
5835+
<key>include</key>
5836+
<string>#hashtable</string>
5837+
</dict>
5838+
<dict>
5839+
<key>include</key>
5840+
<string>#notCode</string>
5841+
</dict>
5842+
</array>
58285843
</dict>
5829-
</array>
5844+
</dict>
5845+
<key>oldend</key>
5846+
<string>$</string>
5847+
<key>name</key>
5848+
<string>comment.line.powershell meta.requires.powershell</string>
58305849
</dict>
58315850
<key>hashtable</key>
58325851
<dict>

0 commit comments

Comments
 (0)