LuaLS / LuaLS/lua-language-server
"array-like" table can't be natively annotated as enum
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Lua
- Estrellas
- 4.4k
- Forks
- 442
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza con la reproducción mínima en Lua del issue y sigue cómo se representan al pasar el cursor la anotación @enum de actions.all y el parámetro Action. Compara ese recorrido con el comportamiento existente de los alias. Se considera terminado cuando al pasar el cursor sobre el parámetro Action se muestran los miembros string del enum de forma coherente con el resultado al pasar el cursor sobre actions.all.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- lua
- Área
- devtools
- Tipo de issue
- Nueva funcionalidad
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 45/100