LuaLS / LuaLS/lua-language-server
"array-like" table can't be natively annotated as enum
まだ誰も着手していません。
- 主要言語
- Lua
- スター
- 4.4k
- フォーク
- 442
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
How are you using the lua-language-server?
Visual Studio Code Extension (sumneko.lua)
Which OS are you using?
Linux
What is the issue affecting?
Annotations, Hover
Expected Behaviour
On hover over action param in my function I'd like to get annotation consistent with already existing annotation that i get if i hover over all in actions.all :
(field) actions.all: {
[10]: string = "supportAttack",
[11]: string = "supportDefence",
[12]: string = "supportBoth",
[13]: string = "supportAttackPike",
[14]: string = "supportDefencePike",
[15]: string = "stanceShieldwall",
[16]: string = "stanceLastman",
[17]: string = "stanceBarrage",
[18]: string = "encamp",
[19]: string = "uncamp",
[1]: string = "retreat",
[20]: string = "destroyCamp",
[21]: string = "buildFort",
[22]: string = "demountFort",
[23]: string = "destroyFort",
[24]: string = "rest",
[25]: string = "respire",
[2]: string = "move",
[3]: string = "swap",
[4]: string = "forcedMove",
[5]: string = "melee",
[6]: string = "shoot",
[7]: string = "shoot2",
[8]: string = "breakthrough",
[9]: string = "enclosing",
}
Essentially i'd like enum for this array to give the same behavioir as alias like this
---@alias Action
---| '"retreat"'
---| '"move"
---| '"swap"'
---| '"forcedMove"'
---| '"melee"'
---| '"shoot"'
---| '"shoot2"'
---| '"breakthrough"
---| '"enclosing"'
---| '"supportAttack"'
---| '"supportDefence"'
---| '"supportBoth"'
---| '"supportAttackPike"'
---| '"supportDefencePike"'
---| '"stanceShieldwall"'
---| '"stanceLastman"'
---| '"stanceBarrage"'
---| '"encamp"'
---| '"uncamp"'
---| '"destroyCamp"'
---| '"buildFort"'
---| '"demountFort"'
---| '"destroyFort"'
---| '"rest"'
---| '"respire"'
Actual Behaviour
On hover over action param in my function I get this annotation:
(parameter) action: Action
{
}
Reproduction steps
Consider this minimal code snippet:
local actions = {}
---@enum Action
actions.all = {
"retreat",
"move",
"swap",
"forcedMove",
"melee",
"shoot",
"shoot2",
"breakthrough",
"enclosing",
"supportAttack",
"supportDefence",
"supportBoth",
"supportAttackPike",
"supportDefencePike",
"stanceShieldwall",
"stanceLastman",
"stanceBarrage",
"encamp",
"uncamp",
"destroyCamp",
"buildFort",
"demountFort",
"destroyFort",
"rest",
"respire",
}
actions.isStance = {stanceShieldwall = true, stanceLastman = true, stanceBarrage = true}
--- @param action Action
--- @return boolean
function actions.IsStance(action)
return actions.isStance[action]
end
Additional Notes
No response
Log File
No response
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
Issue 内の最小限の Lua 再現コードから始め、actions.all の @enum アノテーションと Action パラメーターがホバー時にどのように表現されるかを追跡します。その経路を既存の alias の挙動と比較します。Action パラメーターにホバーしたとき、actions.all のホバー結果と一貫して enum の string メンバーが表示されれば完了です。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- lua
- 領域
- devtools
- issue の種類
- 機能追加
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 活発さ
- 停滞
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 45/100