LuaLS / LuaLS/lua-language-server

Feature Request: Hide a parameter from the annotation

Abierto
#2,033 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement question
Lenguaje dominante
Lua
Estrellas
4.4k
Forks
442
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

I have a table with a metatable assigned to it to implement inheritance. The metatable's `__index` metamethod intercepts a call to a function on the original table and gets the actual function from the "parent" table and then injects another parameter into the function call.

For example, the user would call the function like this: `tbl:Execute("hello", "world")` and the function would be implemented like this:

```lua
function ParentTable:Execute(data, hello, world)
-- data is a special parameter controlled by the metatable and is given a table value
-- hello is assigned "hello" and world is assigned "world"
end
```

The problem with this is that VS Code and LuaLS warns the user that they didn't provide a value to `data`. I have to use `@overload` to every single method to say you can call this method with just "hello" and "world" arguments provided.

I want to be able to tell LuaLS to completely hide/ignore the `data` parameter and pretend it doesn't exist; essentially moving all other parameter indexes down by 1 to fill the empty spot, so "hello" is recognized as parameter 1 and "world" as parameter 2.

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Empieza rastreando cómo LuaLS gestiona las anotaciones de parámetros de funciones, las declaraciones @overload y las llamadas interceptadas mediante el metamétodo __index de una metatabla. El trabajo estará terminado cuando LuaLS pueda ocultar el parámetro de datos inyectado, desplazar los argumentos visibles y dejar de advertir cuando los llamadores proporcionen únicamente hello y world.

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
5/5
Tiempo estimado
Más de una semana
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
25/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.