Skip to content

Commit

Permalink
fix #1288
Browse files Browse the repository at this point in the history
  • Loading branch information
sumneko committed Jul 6, 2022
1 parent 48c53a3 commit eeb24f3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
* `CHG` completion: `completion.callSnippet` no longer generate parameter types
* `CHG` hover: show `---@type {x: number, y: number}` as detail instead of `table`
* `FIX` [#1278](https://github.com/sumneko/lua-language-server/issues/1278)
* `FIX` [#1288](https://github.com/sumneko/lua-language-server/issues/1288)

## 3.4.1
`2022-7-5`
Expand Down
24 changes: 9 additions & 15 deletions script/vm/compiler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,6 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
-- check local field and global field
if not hasFounded[key] and set.bindSources then
for _, src in ipairs(set.bindSources) do
local skipSetLocal
if src.value and src.value.type == 'table' then
searchFieldSwitch('table', suri, src.value, key, ref, function (field)
local fieldKey = guide.getKeyName(field)
Expand All @@ -345,25 +344,20 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
and guide.isSet(field) then
hasFounded[fieldKey] = true
pushResult(field, true)
if src.type == 'local' then
skipSetLocal = true
end
end
end
end)
end
if not skipSetLocal then
searchFieldSwitch(src.type, suri, src, key, ref, function (field)
local fieldKey = guide.getKeyName(field)
if fieldKey then
if not searchedFields[fieldKey]
and guide.isSet(field) then
hasFounded[fieldKey] = true
pushResult(field, true)
end
searchFieldSwitch(src.type, suri, src, key, ref, function (field)
local fieldKey = guide.getKeyName(field)
if fieldKey and not hasFounded[fieldKey] then
if not searchedFields[fieldKey]
and guide.isSet(field) then
hasFounded[fieldKey] = true
pushResult(field, true)
end
end)
end
end
end)
end
end
-- look into extends(if field not found)
Expand Down
17 changes: 17 additions & 0 deletions test/hover/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2074,3 +2074,20 @@ local <?f?>
[[
local f: fun():(x: number, y: boolean)
]]

TEST [[
---@class MyClass
local MyClass = {
a = 1
}
function MyClass:Test()
<?self?>
end
]]
[[
(self) self: MyClass {
Test: function,
a: integer = 1,
}
]]

0 comments on commit eeb24f3

Please sign in to comment.