LuaLS / LuaLS/lua-language-server

[Feature request] Annotation for referring to superclass

未关闭
#2,490 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

主要语言
Lua
星标
4.4k
派生
442
PR 合并指标
30 天内没有已合并 PR

描述

I'm trying to add annotations to classic, but encounter a few problems when doing so.

For example, the super field refers to the superclass. If I were to annotate super like this

---@class Object
---@field protected super Object

then subclasses will have a super field, but it will always refer to Object, instead of their superclass. The best solution I can come up with the current implementation is to set the super field each time a class is created.

---@class Animal : Object
---@field super Object
local Animal = Object:extend()

---@class Bird : Animal
---@field super Animal
local Bird = Object:extend()

This is a repetition of steps, which tells me DRY. I suggest something like a super annotation, which always refers to the superclass relative to which class it is being used.

---@class Object
---@field protected super super

---@class Animal : Object
local Animal = Object:extend()
-- Animal.super refers to Object

---@class Bird: Object
local Bird = Animal:extend()
-- Bird.super refers to Animal

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先查看 issue 中引用的 annotation 示例和 classic.lua 继承模型。确定类字段 annotation 在哪里解析,并定义相对于超类的 annotation 对 Object、Animal 和 Bird 应有的行为;issue 没有指定任何 LuaLS 文件或测试,因此需要在实现之前确定完成标准。

由索引模型根据 Issue 内容生成。

评估

技术栈
lua
领域
devtools
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。