LuaLS / LuaLS/lua-language-server
"array-like" table can't be natively annotated as enum
Personne n'a encore pris cette issue.
- Langage dominant
- Lua
- Étoiles
- 4.4k
- Forks
- 442
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par la reproduction minimale en Lua dans l’issue et suivez la manière dont l’annotation @enum sur actions.all et le paramètre Action sont représentés au survol. Comparez ce chemin avec le comportement existant des alias. C’est terminé lorsque le survol du paramètre Action expose les membres string de l’enum de manière cohérente avec le résultat du survol de actions.all.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- lua
- Domaine
- devtools
- Type d'issue
- Fonctionnalité
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100