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](https://github.com/rxi/classic/blob/master/classic.lua), 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
```lua
---@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.
```lua
---@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.
```lua
---@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 摘要。