summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-07-21 17:17:55 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-07-21 17:17:55 +0800
commit2adc24974ffa9b804e9b99a9b8f777a5220f7e89 (patch)
treede39927f252de2a9f12ef3c436264345beb9674d /script/vm/compiler.lua
parent59285a7f6e18ea67e65a7eca9f21b564a2edfa2e (diff)
downloadlua-language-server-2adc24974ffa9b804e9b99a9b8f777a5220f7e89.zip
fix #1354
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua21
1 files changed, 15 insertions, 6 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index a71cdf70..46814830 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -293,6 +293,14 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
if set.type == 'doc.class' then
-- check ---@field
local hasFounded = {}
+
+ local function copyToSearched()
+ for fieldKey in pairs(hasFounded) do
+ searchedFields[fieldKey] = true
+ hasFounded[fieldKey] = nil
+ end
+ end
+
for _, field in ipairs(set.fields) do
local fieldKey = guide.getKeyName(field)
if fieldKey then
@@ -342,8 +350,9 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
end
end
end
+ copyToSearched()
-- check local field and global field
- if not hasFounded[key] and set.bindSource then
+ if not searchedFields[key] and set.bindSource then
local src = set.bindSource
if src.value and src.value.type == 'table' then
searchFieldSwitch('table', suri, src.value, key, ref, function (field)
@@ -357,9 +366,10 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
end
end)
end
+ copyToSearched()
searchFieldSwitch(src.type, suri, src, key, ref, function (field)
local fieldKey = guide.getKeyName(field)
- if fieldKey and not hasFounded[fieldKey] then
+ if fieldKey and not searchedFields[fieldKey] then
if not searchedFields[fieldKey]
and guide.isSet(field) then
hasFounded[fieldKey] = true
@@ -367,12 +377,10 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
end
end
end)
+ copyToSearched()
end
-- look into extends(if field not found)
- if not hasFounded[key] and set.extends then
- for fieldKey in pairs(hasFounded) do
- searchedFields[fieldKey] = true
- end
+ if not searchedFields[key] and set.extends then
for _, extend in ipairs(set.extends) do
if extend.type == 'doc.extends.name' then
local extendType = vm.getGlobal('type', extend[1])
@@ -381,6 +389,7 @@ function vm.getClassFields(suri, object, key, ref, pushResult)
end
end
end
+ copyToSearched()
end
end
end