diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-22 03:54:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-22 03:54:03 +0800 |
commit | b26b7f7029d895c672a0a4d057d00b36355acaa7 (patch) | |
tree | c98b1398b9fc1f1caf787c5e28bf17c8a312d7db /script/vm/compiler.lua | |
parent | 4c6375fea56e5362afc8eef1a4d32ebbe64c7391 (diff) | |
download | lua-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.lua | 28 |
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 |