LuaLS / LuaLS/lua-language-server

Annotations in inline comments do not recognize others on the same line

Abierto
#3,350 0 comentarios 0 reacciones 0 asignados Ver en GitHub

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, Type Checking

Expected Behaviour

Placing multiple annotations in inline comments like so works fine: the generics are interpreted correctly.

--[[@generic C]]
--[[@param any C]]
--[[@return C]]
local function exampleGeneric(any) return any end

So one would expect grouping them together on the same line (like this) would also work:

--[[@generic C]] --[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end
Actual Behaviour

In the previous example, the generic seems to be defined, but doesn't carry over properly to the other two annotations. Similarly, adding a line break between the first and second annotation like this

--[[@generic C]]
--[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end

allows the generic to be recognized by the second annotation, but not the third. This behavior is also visible in other annotations that require others to be nearby, such as with classes and fields, and aliases.

Reproduction steps
  1. Open VSCode
  2. Paste either of the following examples into an empty lua file:
--[[@class amazingClass]] --[[@field field1 string]] --[[@field field2 number]]
--[[@generic C]] --[[@param any C]] --[[@return C]]
local function exampleGeneric(any) return any end
Additional Notes

While I realize there is little practical use for some of these cases, such as the class definition (as it starts to take up a lot of horizontal space really quickly when defining new fields), this is especially useful when creating a plugin that allows for inline annotation definitions like the following:

local width: integer, height: integer = screen.width, screen.height
local logo: love.Image = textures["logo.png"]

which generates inline comments like so in order to preserve syntax coloring, as well as line numbers during runtime:

local width --[[@type integer ]], height --[[@type integer ]] = screen.width, screen.height
local logo --[[@type love.Image ]] = textures["logo.png"]
Log File

No response

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

Reproduce el problema en VSCode usando los ejemplos de anotaciones inline de Lua del informe y, después, compara las anotaciones divididas entre varias líneas con varias anotaciones en una sola línea. Rastrea cómo el language server asocia anotaciones relacionadas, como genéricos, parámetros, valores de retorno, clases, campos y alias; se considera terminado cuando las anotaciones en la misma línea se interpretan de forma coherente con las anotaciones en líneas separadas.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
lua
Área
devtools
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
45/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.