summaryrefslogtreecommitdiff
path: root/script/vm/compiler.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-22 03:54:03 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-22 03:54:03 +0800
commitb26b7f7029d895c672a0a4d057d00b36355acaa7 (patch)
treec98b1398b9fc1f1caf787c5e28bf17c8a312d7db /script/vm/compiler.lua
parent4c6375fea56e5362afc8eef1a4d32ebbe64c7391 (diff)
downloadlua-language-server-b26b7f7029d895c672a0a4d057d00b36355acaa7.zip
resolve `T[]` by `doc.type.table` or `doc.field`
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r--script/vm/compiler.lua28
1 files changed, 19 insertions, 9 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 883d89b9..4395eea4 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -184,7 +184,7 @@ local searchFieldSwitch = util.switch()
end)
-function vm.getClassFields(suri, node, key, ref, pushResult)
+function vm.getClassFields(suri, object, key, ref, pushResult)
local mark = {}
local function searchClass(class, searchedFields)
@@ -199,13 +199,23 @@ function vm.getClassFields(suri, node, key, ref, pushResult)
-- check ---@field
local hasFounded = {}
for _, field in ipairs(set.fields) do
- local fieldKey = guide.getKeyName(field)
- if fieldKey then
- if key == nil
- or fieldKey == key then
- if not searchedFields[fieldKey] then
+ if type(key) == 'table' then
+ local fieldNode = vm.compileNode(field.field)
+ if vm.isSubType(suri, key.name, fieldNode) then
+ if not searchedFields[key] then
pushResult(field)
- hasFounded[fieldKey] = true
+ hasFounded[key] = true
+ end
+ end
+ else
+ local fieldKey = guide.getKeyName(field)
+ if fieldKey then
+ if key == nil
+ or fieldKey == key then
+ if not searchedFields[fieldKey] then
+ pushResult(field)
+ hasFounded[fieldKey] = true
+ end
end
end
end
@@ -273,8 +283,8 @@ function vm.getClassFields(suri, node, key, ref, pushResult)
end
end
- searchClass(node)
- searchGlobal(node)
+ searchClass(object)
+ searchGlobal(object)
end
---@class parser.object