LuaLS / LuaLS/lua-language-server

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

Aperta
#3,350 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
Lua
Stelle
4.4k
Fork
442
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

### 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.
```lua
--[[@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:
```lua
--[[@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
```lua
--[[@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:
```lua
--[[@class amazingClass]] --[[@field field1 string]] --[[@field field2 number]]
```
```lua
--[[@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:
```lua
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:
```lua
local width --[[@type integer ]], height --[[@type integer ]] = screen.width, screen.height
local logo --[[@type love.Image ]] = textures["logo.png"]
```

### Log File

_No response_

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Riproduci il problema in VSCode usando gli esempi di annotazioni inline di Lua riportati nella segnalazione, quindi confronta le annotazioni suddivise su più righe con più annotazioni su una sola riga. Traccia il modo in cui il language server associa le annotazioni correlate, come generics, parametri, valori restituiti, classi, campi e alias; il lavoro è completato quando le annotazioni sulla stessa riga vengono interpretate in modo coerente con le annotazioni su righe separate.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
lua
Ambito
devtools
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
45/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.