Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing field completion for generic class object #3055

Merged
merged 3 commits into from
Feb 6, 2025

Conversation

tomlau10
Copy link
Contributor

fixes #2196, fixes #2945
resolves #3041 (fixing this bug fulfills the requirement of that issue, such that the feature request becomes unnecessary)


Bug explanation: #2945 (comment)

Example after bugfix

---@class Array<T>: { [integer]: T }
---@field private length integer
local Array

function Array:push()
    self.  --> suggest `length`, `push(self)`
end

---@type Array<string>
local a

print(a.length) --> Field `length` is private, it can only be accessed in class `Array`.

a: --> suggest `push()`

Product placement

CppCXY's new lua language server written in rust has better generic support 😃


中文版

簡單在 searchFieldSwitch 增加對 doc.type.sign 的支持,以修復 generic class object 沒有 field completion 的問題。
目前其實還有一個問題,就是 field completion 還會列出 integer 😕
似是由 { [integer]: T } 獲取出來的 integer key field name

---@class Array<T>: { [integer]: T }

---@type Array<string>
local a
a. --> why suggest `integer` ??

但由於這個問題本身已存在,且我暫時也不清楚原因,就先不在此 PR 糾結了

@sumneko sumneko force-pushed the fix/generic_class_completion branch from 0e3eb41 to 3a8203e Compare February 6, 2025 07:01
@sumneko sumneko merged commit 2a57892 into LuaLS:master Feb 6, 2025
11 checks passed
@tomlau10 tomlau10 deleted the fix/generic_class_completion branch February 6, 2025 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants