LuaLS / LuaLS/lua-language-server

---@template<class: T1, class: T2>

オープン
#1,732 コメント 6 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

enhancement feat/generic
主要言語
Lua
スター
4.4k
フォーク
442
PR マージ指標
30日以内にマージされた PR はありません

説明

How are you using the lua-language-server?

Visual Studio Code Extension (sumneko.lua)

Which OS are you using?

Windows

What is the issue affecting?

Other

Expected Behaviour

image
image
image

Actual Behaviour

image
image
image

Reproduction steps

Is it possible to implement this annotation method?

---@diagnostic disable: missing-return

function CreateFramePool(...) end
function CreateFrame(...) end

---@template <class T>
---@class ObjectPoolMixin
---@field creationFunc fun(self: self)
---@field resetterFunc fun(self: self, object: T)
---@field activeObjects T[]
---@field inactiveObjects T[]
---@field hashinactiveObjects T[]
---@field numActiveObjects integer
ObjectPoolMixin = {};

---@template <class T>
---@param creationFunc fun(self: T)
---@param resetterFunc fun(self: self, object: T)
function ObjectPoolMixin:OnLoad(creationFunc, resetterFunc) end

---@template <class T>
---@return T object
---@return boolean isNew
function ObjectPoolMixin:Acquire() end

---@template <class T1, class T2>
---@class FramePoolMixin: ObjectPoolMixin<T2>
---@field parent T1
FramePoolMixin = {};

---@class Button1
---@field a table
---@field b integer
local Button1 = {};

---@class Button2
---@field c string
---@field d number
local Button2 = {};

---@class Frame1
local frame1 = CreateFrame("Frame");

---@class Frame2
local frame2 = CreateFrame("Frame");

---@class Frame1Pool: FramePoolMixin<Frame1, Button1>
frame1.pool = CreateFramePool("Button", frame1);

---@class Frame2Pool: FramePoolMixin<Frame2, Button2>
frame2.pool = CreateFramePool("Button", frame2);

local parent1 = frame1.pool.parent; -- Should be defined as Frame1
local parent2 = frame2.pool.parent; -- Should be defined as Frame2

local activeObjects1 = frame1.pool.activeObjects; -- Should be defined as Button1[]
local activeObjects2 = frame2.pool.activeObjects; -- Should be defined as Button2[]

local button1 = activeObjects1[1]; -- Should be defined as Button1 or nil
local button2 = activeObjects2[1]; -- Should be defined as Button2 or nil


Additional Notes

No response

Log File

No response

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

Issue 内の Lua 再現例から始め、@template と @class の継承アノテーション、および parent と activeObjects に期待される型に注目してください。language server が現在これらのアノテーションをどのように解釈しているかを追跡し、その後、例が両方の template パラメーターを保持し、示されているフィールドを Frame1/Frame2 および Button1[]/Button2[] として解決することを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
lua
領域
devtools
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。