keywords scoped in places where not actually keywords, IF inside simple interpolation `()` for instance

未關閉
#152 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
42/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
停滯
技術堆疊
powershell
領域
devtools, tooling

研究方向

Start by reproducing the reported scoping with the PowerShell samples in the issue and compare the result with PSReadLine, where the construct is treated as a command. Inspect the syntax grammar's root patterns and repositories, then verify that if and similarly limited keywords such as in are scoped only where valid, without regressing valid interpolation highlighting.

由索引模型根據 Issue 內容生成。

描述

Environment
  • Editor and Version: VS Code: 1.31 Insiders / 1.30.1
  • Your primary theme: Monokai Dimmed (modified)
Issue Description

In the following image and code, the if is being scoped as 'keyword.control', as if it was valid to utilize an IF statement at this point. However it is not valid, and the code instead causes an error stating that The term 'if' is not recognized as the name … No syntax error is reported by EditorServices either. PSReadLine however does indicate that the if would be treated as a command instead of a keyword.

Screenshots

VS Code:
image
PSReadLine
image
(keywords would be green)

Expected Behavior

I would like to expect that this case would not receive 'keyword.control' scoping, so that I am not led to believe the given command might actually be correct. A quick attempt to correct this indicates that this will require some reorganization, because too many items are in the root patterns and not in the repository.

This also shows that there is more to argument mode vs. expression mode than I had originally thought. Control statements cannot always be used everywhere a command can be used. This also affects other limited scope keywords, such as in, which is scoped as 'keyword.control' in more places than it should be.

Code Samples
    '<?xml version="1.0"' + (if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'

The correct code:

    '<?xml version="1.0"' + $(if ($encoding) {' encoding="' + $encoding + '"'}) + '?>'
主要語言
PowerShell
星號
151
分支
55
PR 合併指標
30 天內沒有已合併 PR

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

PowerShell/EditorSyntax 的其他 Issue

查看 PowerShell/EditorSyntax 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。