Skip to content

Commit c8547e5

Browse files
alexr00Tyriar
andauthored
Update tree-sitter-wasm (#278399)
* Update tree-sitter-wasm * Update test results * Update pwsh && tests, fix prompt Fixes #274548 --------- Co-authored-by: Daniel Imms <[email protected]>
1 parent 5e1893f commit c8547e5

File tree

10 files changed

+116
-40
lines changed

10 files changed

+116
-40
lines changed

extensions/vscode-colorize-tests/test/colorize-tree-sitter-results/test_css.json

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,20 @@
125125
"light_modern": "string: #A31515"
126126
}
127127
},
128+
{
129+
"c": "mystyle.css",
130+
"t": "string.quoted.double.css",
131+
"r": {
132+
"dark_plus": "string: #CE9178",
133+
"light_plus": "string: #A31515",
134+
"dark_vs": "string: #CE9178",
135+
"light_vs": "string: #A31515",
136+
"hc_black": "string: #CE9178",
137+
"dark_modern": "string: #CE9178",
138+
"hc_light": "string: #0F4A85",
139+
"light_modern": "string: #A31515"
140+
}
141+
},
128142
{
129143
"c": "\"",
130144
"t": "string.quoted.double.css",
@@ -209,6 +223,20 @@
209223
"light_modern": "string: #A31515"
210224
}
211225
},
226+
{
227+
"c": "mystyle.css",
228+
"t": "string.quoted.double.css",
229+
"r": {
230+
"dark_plus": "string: #CE9178",
231+
"light_plus": "string: #A31515",
232+
"dark_vs": "string: #CE9178",
233+
"light_vs": "string: #A31515",
234+
"hc_black": "string: #CE9178",
235+
"dark_modern": "string: #CE9178",
236+
"hc_light": "string: #0F4A85",
237+
"light_modern": "string: #A31515"
238+
}
239+
},
212240
{
213241
"c": "\"",
214242
"t": "string.quoted.double.css",
@@ -307,6 +335,20 @@
307335
"light_modern": "string: #A31515"
308336
}
309337
},
338+
{
339+
"c": "bluish.css",
340+
"t": "string.quoted.double.css",
341+
"r": {
342+
"dark_plus": "string: #CE9178",
343+
"light_plus": "string: #A31515",
344+
"dark_vs": "string: #CE9178",
345+
"light_vs": "string: #A31515",
346+
"hc_black": "string: #CE9178",
347+
"dark_modern": "string: #CE9178",
348+
"hc_light": "string: #0F4A85",
349+
"light_modern": "string: #A31515"
350+
}
351+
},
310352
{
311353
"c": "\"",
312354
"t": "string.quoted.double.css",
@@ -3387,6 +3429,20 @@
33873429
"light_modern": "string: #A31515"
33883430
}
33893431
},
3432+
{
3433+
"c": "<angle>",
3434+
"t": "string.quoted.single.css",
3435+
"r": {
3436+
"dark_plus": "string: #CE9178",
3437+
"light_plus": "string: #A31515",
3438+
"dark_vs": "string: #CE9178",
3439+
"light_vs": "string: #A31515",
3440+
"hc_black": "string: #CE9178",
3441+
"dark_modern": "string: #CE9178",
3442+
"hc_light": "string: #0F4A85",
3443+
"light_modern": "string: #A31515"
3444+
}
3445+
},
33903446
{
33913447
"c": "'",
33923448
"t": "string.quoted.single.css",
@@ -7307,6 +7363,20 @@
73077363
"light_modern": "string: #A31515"
73087364
}
73097365
},
7366+
{
7367+
"c": "#B3AE94",
7368+
"t": "string.quoted.single.css",
7369+
"r": {
7370+
"dark_plus": "string: #CE9178",
7371+
"light_plus": "string: #A31515",
7372+
"dark_vs": "string: #CE9178",
7373+
"light_vs": "string: #A31515",
7374+
"hc_black": "string: #CE9178",
7375+
"dark_modern": "string: #CE9178",
7376+
"hc_light": "string: #0F4A85",
7377+
"light_modern": "string: #A31515"
7378+
}
7379+
},
73107380
{
73117381
"c": "'",
73127382
"t": "string.quoted.single.css",
@@ -8413,6 +8483,20 @@
84138483
"light_modern": "string: #A31515"
84148484
}
84158485
},
8486+
{
8487+
"c": "codicon-",
8488+
"t": "meta.selector.css string.quoted.single.css",
8489+
"r": {
8490+
"dark_plus": "string: #CE9178",
8491+
"light_plus": "string: #A31515",
8492+
"dark_vs": "string: #CE9178",
8493+
"light_vs": "string: #A31515",
8494+
"hc_black": "string: #CE9178",
8495+
"dark_modern": "string: #CE9178",
8496+
"hc_light": "string: #0F4A85",
8497+
"light_modern": "string: #A31515"
8498+
}
8499+
},
84168500
{
84178501
"c": "'",
84188502
"t": "meta.selector.css string.quoted.single.css",

package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@
8484
"@vscode/spdlog": "^0.15.2",
8585
"@vscode/sqlite3": "5.1.8-vscode",
8686
"@vscode/sudo-prompt": "9.3.1",
87-
"@vscode/tree-sitter-wasm": "^0.2.0",
87+
"@vscode/tree-sitter-wasm": "^0.3.0",
8888
"@vscode/vscode-languagedetection": "1.0.21",
8989
"@vscode/windows-mutex": "^0.5.0",
9090
"@vscode/windows-process-tree": "^0.6.0",

remote/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remote/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"@vscode/proxy-agent": "^0.36.0",
1212
"@vscode/ripgrep": "^1.15.13",
1313
"@vscode/spdlog": "^0.15.2",
14-
"@vscode/tree-sitter-wasm": "^0.2.0",
14+
"@vscode/tree-sitter-wasm": "^0.3.0",
1515
"@vscode/vscode-languagedetection": "1.0.21",
1616
"@vscode/windows-process-tree": "^0.6.0",
1717
"@vscode/windows-registry": "^1.1.0",

remote/web/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

remote/web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"@microsoft/1ds-core-js": "^3.2.13",
77
"@microsoft/1ds-post-js": "^3.2.13",
88
"@vscode/iconv-lite-umd": "0.7.1",
9-
"@vscode/tree-sitter-wasm": "^0.2.0",
9+
"@vscode/tree-sitter-wasm": "^0.3.0",
1010
"@vscode/vscode-languagedetection": "1.0.21",
1111
"@xterm/addon-clipboard": "^0.2.0-beta.119",
1212
"@xterm/addon-image": "^0.9.0-beta.136",

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/tools/runInTerminalTool.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,9 @@ function createPowerShellModelDescription(shell: string): string {
6565
`This tool allows you to execute ${isWinPwsh ? 'Windows PowerShell 5.1' : 'PowerShell'} commands in a persistent terminal session, preserving environment variables, working directory, and other context across multiple commands.`,
6666
'',
6767
'Command Execution:',
68-
// TODO: Even for pwsh 7+ we want to use `;` to chain commands since the tree sitter grammar
69-
// doesn't parse `&&`. We want to change this to avoid `&&` only in Windows PowerShell when
70-
// the grammar supports it https://github.com/airbus-cert/tree-sitter-powershell/issues/27
71-
'- Use semicolons ; to chain commands on one line, NEVER use && even when asked explicitly',
68+
// IMPORTANT: PowerShell 5 does not support `&&` so always re-write them to `;`. Note that
69+
// the behavior of `&&` differs a little from `;` but in general it's fine
70+
isWinPwsh ? '- Use semicolons ; to chain commands on one line, NEVER use && even when asked explicitly' : '- Prefer ; when chaining commands on one line',
7271
'- Prefer pipelines | for object-based data flow',
7372
'- Never create a sub-shell (eg. powershell -c "command") unless explicitly asked',
7473
'',

src/vs/workbench/contrib/terminalContrib/chatAgentTools/browser/treeSitterCommandParser.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,8 @@ export class TreeSitterCommandParser extends Disposable {
3434
async extractPwshDoubleAmpersandChainOperators(commandLine: string): Promise<QueryCapture[]> {
3535
const captures = await this._queryTree(TreeSitterCommandParserLanguage.PowerShell, commandLine, [
3636
'(',
37-
' (command',
38-
' (command_elements',
39-
' (generic_token) @double.ampersand',
40-
' (#eq? @double.ampersand "&&")))',
37+
' (pipeline',
38+
' (pipeline_chain_tail) @double.ampersand)',
4139
')',
4240
].join('\n'));
4341
return captures;

src/vs/workbench/contrib/terminalContrib/chatAgentTools/test/electron-browser/treeSitterCommandParser.test.ts

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,14 @@ suite('TreeSitterCommandParser', () => {
212212
test('&& with complex commands', () => t('Get-ChildItem -Path C:\\ && Set-Location C:\\Users', ['&&']));
213213
test('&& with parameters', () => t('Get-Process -Name notepad && Stop-Process -Name notepad', ['&&']));
214214
test('&& with pipeline inside', () => t('Get-Process | Where-Object {$_.Name -eq "notepad"} && Write-Host "Found"', ['&&']));
215-
// TODO: A lot of these tests are skipped until proper parsing of && is supported in https://github.com/airbus-cert/tree-sitter-powershell/issues/27
216-
test.skip('nested && in script blocks', () => t('if ($true) { echo hello && echo world } && echo done', ['&&', '&&']));
217-
test.skip('&& with method calls', () => t('"hello".ToUpper() && "world".ToLower()', ['&&']));
218-
test.skip('&& with array operations', () => t('@(1,2,3) | ForEach-Object { $_ } && Write-Host "done"', ['&&']));
219-
test.skip('&& with hashtable', () => t('@{key="value"} && Write-Host "created"', ['&&']));
220-
test.skip('&& with type casting', () => t('[int]"123" && [string]456', ['&&']));
221-
test.skip('&& with comparison operators', () => t('5 -gt 3 && "hello" -like "h*"', ['&&']));
222-
test.skip('&& with variable assignment', () => t('$var = "test" && Write-Host $var', ['&&']));
223-
test.skip('&& with expandable strings', () => t('$name="World" && "Hello $name"', ['&&']));
215+
test('nested && in script blocks', () => t('if ($true) { echo hello && echo world }', ['&&']));
216+
test('&& with method calls', () => t('"hello".ToUpper() && "world".ToLower()', ['&&']));
217+
test('&& with array operations', () => t('@(1,2,3) | ForEach-Object { $_ } && Write-Host "done"', ['&&']));
218+
test('&& with hashtable', () => t('@{key="value"} && Write-Host "created"', ['&&']));
219+
test('&& with type casting', () => t('[int]"123" && [string]456', ['&&']));
220+
test('&& with comparison operators', () => t('5 -gt 3 && "hello" -like "h*"', ['&&']));
221+
test('&& with variable assignment', () => t('$var = "test" && Write-Host $var', ['&&']));
222+
test('&& with expandable strings', () => t('$name="World" && "Hello $name"', ['&&']));
224223
test('&& with subexpressions', () => t('Write-Host $(Get-Date) && Get-Location', ['&&']));
225224
test('&& with here-strings', () => t('Write-Host @"\nhello\nworld\n"@ && Get-Date', ['&&']));
226225
test('&& with splatting', () => t('$params = @{Path="C:\\"}; Get-ChildItem @params && Write-Host "done"', ['&&']));
@@ -230,7 +229,7 @@ suite('TreeSitterCommandParser', () => {
230229
test('&& with error handling', () => t('try { Get-Content "file.txt" && Write-Host "success" } catch { Write-Error "failed" }', ['&&']));
231230
test('&& inside foreach', () => t('ForEach-Object { Write-Host $_.Name && Write-Host $_.Length }', ['&&']));
232231
test('&& with conditional logic', () => t('if (Test-Path "file.txt") { Get-Content "file.txt" && Write-Host "read" }', ['&&']));
233-
test.skip('&& with switch statement', () => t('switch ($var) { 1 { "one" && "first" } 2 { "two" && "second" } }', ['&&', '&&']));
232+
test('&& with switch statement', () => t('switch ($var) { 1 { "one" && "first" } 2 { "two" && "second" } }', ['&&', '&&']));
234233
test('&& in do-while', () => t('do { Write-Host $i && $i++ } while ($i -lt 5)', ['&&']));
235234
test('&& in for loop', () => t('for ($i=0; $i -lt 5; $i++) { Write-Host $i && Start-Sleep 1 }', ['&&']));
236235
test('&& with parallel processing', () => t('1..10 | ForEach-Object -Parallel { Write-Host $_ && Start-Sleep 1 }', ['&&']));
@@ -239,22 +238,18 @@ suite('TreeSitterCommandParser', () => {
239238
suite('edge cases', () => {
240239
test('empty string', () => t('', []));
241240
test('whitespace only', () => t(' \n\t ', []));
242-
test('single &', () => t('Get-Date & Get-Location', []));
243-
test.skip('triple &&&', () => t('echo hello &&& echo world', ['&&']));
244-
test.skip('&& at beginning', () => t('&& echo hello', ['&&']));
245-
test('&& at end', () => t('echo hello &&', ['&&']));
241+
test('triple &&&', () => t('echo hello &&& echo world', ['&&']));
246242
test('spaced && operators', () => t('echo hello & & echo world', []));
247243
test('&& with unicode', () => t('Write-Host "测试" && Write-Host "🚀"', ['&&']));
248244
test('very long command with &&', () => t('Write-Host "' + 'a'.repeat(1000) + '" && Get-Date', ['&&']));
249245
test('deeply nested with &&', () => t('if ($true) { if ($true) { if ($true) { echo nested && echo deep } } }', ['&&']));
250246
test('&& with escaped characters', () => t('Write-Host "hello`"world" && Get-Date', ['&&']));
251-
test.skip('&& with backticks', () => t('Write-Host `hello && Get-Date', ['&&']));
252-
test.skip('malformed syntax with &&', () => t('echo "unclosed && Get-Date', ['&&']));
247+
test('&& with backticks', () => t('Write-Host `hello && Get-Date', ['&&']));
253248
});
254249

255250
suite('real-world scenarios', () => {
256251
test('git workflow', () => t('git add . && git commit -m "message" && git push', ['&&', '&&']));
257-
test.skip('build and test', () => t('dotnet build && dotnet test && dotnet publish', ['&&', '&&']));
252+
test('build and test', () => t('dotnet build && dotnet test && dotnet publish', ['&&', '&&']));
258253
test('file operations', () => t('New-Item -Type File "test.txt" && Add-Content "test.txt" "hello" && Get-Content "test.txt"', ['&&', '&&']));
259254
test('service management', () => t('Stop-Service spooler && Set-Service spooler -StartupType Manual && Start-Service spooler', ['&&', '&&']));
260255
test('registry operations', () => t('New-Item -Path "HKCU:\\Software\\Test" && Set-ItemProperty -Path "HKCU:\\Software\\Test" -Name "Value" -Value "Data"', ['&&']));

0 commit comments

Comments
 (0)