LuaLS / LuaLS/lua-language-server
Better global
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'm going to do some work for global variable distinguishing environments.
At present, my idea is as follows:
---@global global -- the table will be merged into current globals. the second `global` can be omitted
local t = {
X = 1,
Y = 2,
Z = 3,
}
print(X) -- `X` is `t.X`
---@global module1, module2 -- the table will be merged into environment `module1` and `module2`
local t = {
X = 1,
Y = 2,
Z = 3,
}
print(X) -- `x` is undefined
---@environment module1, global -- set the current environment can visit `module1` and `global`
print(X) -- `X` is `t.X`
---@environment module1
print(X) -- `X` is `t.X` and `print` is undefined
EDIT:
---@partial class _G -- the table will be merged into class `_G`. the default environment is class `_G`
local t = {
X = 1,
Y = 2,
Z = 3,
}
print(X) -- `X` is `t.X`
---@class module1
local t = {
X = 1,
Y = 2,
Z = 3,
}
print(X) -- `x` is undefined
---@environment module1, _G -- set the current environment can visit class `module1` and `_G`
print(X) -- `X` is `t.X`
---@environment module1
print(X) -- `X` is `t.X` and `print` is undefined
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
Das Issue schlägt neue @global-, @partial-, @class- und @environment-Annotationen zur Unterscheidung von Lua-Umgebungen vor, nennt jedoch keine Dateien, Tests oder Einstiegspunkte. Beginne damit, die beabsichtigte Umgebung und Zusammenführungssemantik zu klären, und finde anschließend die Implementierungen für Annotationen und globale Auflösung. Als erledigt gilt die Aufgabe, wenn die vorgeschlagenen Beispiele globale Variablen wie beschrieben auflösen und die verschiedenen Umgebungskombinationen abgedeckt sind.
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