LuaLS / LuaLS/lua-language-server
"array-like" table can't be natively annotated as enum
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der minimalen Lua-Reproduktion im Issue und verfolge, wie die @enum-Annotation für actions.all und der Action-Parameter beim Hover dargestellt werden. Vergleiche diesen Pfad mit dem bestehenden Verhalten für Aliase. Die Aufgabe ist erledigt, wenn beim Hover über den Action-Parameter die String-Member des Enums konsistent mit dem Hover-Ergebnis von actions.all angezeigt werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100