LuaLS / LuaLS/lua-language-server
Better global
未关闭
还没有人认领这个 Issue。
help wanted
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
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
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
该 issue 提出了新的 @global、@partial、@class 和 @environment 注解,用于区分 Lua 环境,但没有指定文件、测试或入口点。首先明确预期的环境和合并语义,然后定位注解和全局解析的实现。完成的标准是:提议的示例能够按描述解析全局变量,并且涵盖不同的环境组合。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 需要澄清
- 新手友好度
- 25/100