From 9310038417408a5c2f6c148447d951f248fce2fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 5 Apr 2022 03:54:59 +0800 Subject: update --- script/core/hover/table.lua | 6 +++--- script/vm/compiler.lua | 8 ++++++-- test/hover/init.lua | 20 +++----------------- 3 files changed, 12 insertions(+), 22 deletions(-) diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua index a21910e3..88808daa 100644 --- a/script/core/hover/table.lua +++ b/script/core/hover/table.lua @@ -113,8 +113,8 @@ end local function getOptMap(fields, keyMap) local optMap = {} for _, field in ipairs(fields) do - if field.type == 'doc.field.name' then - if field.parent.optional then + if field.type == 'doc.field' then + if field.optional then local key = vm.getKeyName(field) if keyMap[key] then optMap[key] = true @@ -145,7 +145,7 @@ local function getInferMap(fields, keyMap) await.delay() local ifr = infer.getInfer(field) if inferMap[key] then - inferMap[key]:merge(ifr) + inferMap[key] = inferMap[key]:merge(ifr) else inferMap[key] = ifr end diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index 4dc3edef..fd1d1d5d 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -111,14 +111,14 @@ local searchFieldSwitch = util.switch() or (fn.name == 'number' and type(key) == 'number') or (fn.name == 'integer' and math.tointeger(key)) or (fn.name == 'string' and type(key) == 'string') then - pushResult(field.extends) + pushResult(field) end end end end if fieldKey.type == 'doc.field.name' then if key == nil or fieldKey[1] == key then - pushResult(field.extends) + pushResult(field) end end end @@ -852,6 +852,10 @@ local compilerSwitch = util.switch() : call(function (source) nodeMgr.setNode(source, m.compileNode(source.extends)) end) + : case 'doc.type.field' + : call(function (source) + nodeMgr.setNode(source, m.compileNode(source.extends)) + end) : case 'doc.param' : call(function (source) nodeMgr.setNode(source, m.compileNode(source.extends)) diff --git a/test/hover/init.lua b/test/hover/init.lua index 1fced5b3..6570c38c 100644 --- a/test/hover/init.lua +++ b/test/hover/init.lua @@ -1676,7 +1676,7 @@ TEST [[ ]] [[ global a: { - b: integer, + b: integer = 600, } ]] @@ -1684,7 +1684,7 @@ TEST [[ a. = 10 * 60 ]] [[ -global a.b: integer +global a.b: integer = 600 ]] TEST [[ @@ -1692,7 +1692,7 @@ a..c = 1 * 1 ]] [[ global a.b: { - c: integer, + c: integer = 1, } ]] @@ -1745,20 +1745,6 @@ print(b.) [[ field A.x: unknown ]] -TEST [[ ----@class A ----@field x number ----@field y number - ----@type A -local -]] -[[ -local t: A { - x: number, - y: number, -} -]] TEST [[ ---@return nil -- cgit v1.2.3