LuaLS / LuaLS/lua-language-server

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

Offen
#3,350 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Lua
Sterne
4.4k
Forks
442
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

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

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Reproduziere das Problem in VSCode anhand der Inline-Lua-Annotationsbeispiele aus dem Bericht und vergleiche anschließend über mehrere Zeilen aufgeteilte Annotationen mit mehreren Annotationen in einer Zeile. Verfolge, wie der Language Server zusammengehörige Annotationen wie Generics, Parameter, Rückgabewerte, Klassen, Felder und Aliase zuordnet; als erledigt gilt die Aufgabe, wenn Annotationen in derselben Zeile konsistent mit Annotationen in separaten Zeilen interpretiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
lua
Bereich
devtools
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.