LuaLS / LuaLS/lua-language-server
[Feature Request] @mixin - @class specific syntax to define applied mixins
还没有人认领这个 Issue。
- 主要语言
- Lua
- 星标
- 4.4k
- 派生
- 442
- PR 合并指标
- 30 天内没有已合并 PR
描述
What
A way to indicate that the members of a @class type are applied to a subject @class outside of the inheritance chain
Technical
@mixin type, ...
Adds the values of type, ... to the subject class' definition. Mixins are applied in the order they are specified; values of the same key are overwrote as each mixin is processed
Example
This:
---@class Mixin1
---@field foo number
---@field bar number
---@class Mixin2
---@field bar string
---@field baz string
---@class Subject
---@field key boolean
---@field foo boolean
---@mixin Mixin1, Mixin2
Would get interpreted as
---@class Subject
---@field key boolean (defined by field; wasn't altered by mixins)
---@field foo number (defined by field, overwrote by mixin1, not overwrite by mixin2)
---@field bar string (defined by mixin1, overwrite by mixin2)
---@field baz string (defined by mixin2)
Use case
I currently have sub-classes that get assigned valves from reusable dictionary tables outside their inheritance chain. The only way to document those modifications is to statically define the fields each time a mixin is applied
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
未指定文件或测试。首先跟踪 language server 如何解析现有的 @class 注解和继承,然后确定有序应用 @mixin 和字段覆盖应适合放在哪里。完成的标准是:语法按照所述的优先级规则进行解析,并且有针对多个 mixin 和冲突的测试覆盖。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- lua
- 领域
- devtools
- Issue 类型
- 功能
- 难度
- 5/5
- 预计耗时
- 一周以上
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100