LuaLS / LuaLS/lua-language-server
@constraint Annotation for types/aliases
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- Lua
- Sterne
- 4.4k
- Forks
- 442
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Beschreibung
I was working with Annotations for documenting my code and wanted to add a warning if the user used a function that didn't fall under a specific pattern ("0x%x%x%x%x%x%x%x%x") and tried finding a workaround. I'm not 100% fluent with .lua and don't have the confidence to PR, so take my idea instead.
My idea for the annotation would be as follows:
--- @constraint con_color (string.find(T , "^0x%x%x%x%x%x%x%x%x$") or string.find(T , "^%x%x%x%x%x%x$"))
--- @alias color string<con_color>
--- @param col1 color
--- @param col2 color
local function set_col(col1, col2)
...
end
Obviously syntax could use work, but the basic idea would be to add a constraint, and have T or whatever variable name be the entry. This way you can give a warning to users about unsupported string or a number being too low/high being used. If there is already something like this please enlighten me as I couldn't find anything
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne mit der Überprüfung der bestehenden Verarbeitung von Annotationen für @alias und @param im Language Server, da das Issue keine spezifischen Dateien oder Tests nennt. Ermittle, wie eine vorgeschlagene @constraint-Syntax Aliase validieren und Warnungen erzeugen könnte, und lege die Syntax und das erwartete Verhalten vor der Implementierung fest; als erledigt gilt die Aufgabe, wenn dokumentierte Constraints für das Farbbeispiel funktionieren und ungültige Werte diagnostiziert werden.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- lua
- Bereich
- devtools
- Issue-Typ
- Feature
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Aktivitätsstatus
- Veraltet
- Klarheit
- Muss geklärt werden
- Anfängerfreundlichkeit
- 25/100