diff options
author | AlexCai2019 <89138532+AlexCai2019@users.noreply.github.com> | 2022-05-08 01:43:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-08 01:43:28 +0800 |
commit | 0fd83c4ca9f82a02becab6c304a8a7de75098507 (patch) | |
tree | be9790d9d4823fe728c5b36e94093fe5f42b7725 /script/vm/sign.lua | |
parent | 89203efad8c9b5513e05ca4d5696107924865b10 (diff) | |
parent | 67b4c574849d1667e0ecb39c51aeed8e30b43056 (diff) | |
download | lua-language-server-0fd83c4ca9f82a02becab6c304a8a7de75098507.zip |
Merge branch 'sumneko:master' into master
Diffstat (limited to 'script/vm/sign.lua')
-rw-r--r-- | script/vm/sign.lua | 29 |
1 files changed, 21 insertions, 8 deletions
diff --git a/script/vm/sign.lua b/script/vm/sign.lua index 2d45a5a7..fe112bc2 100644 --- a/script/vm/sign.lua +++ b/script/vm/sign.lua @@ -1,6 +1,6 @@ local guide = require 'parser.guide' +---@class vm local vm = require 'vm.vm' -local infer = require 'vm.infer' ---@class vm.sign ---@field parent parser.object @@ -16,12 +16,12 @@ end ---@param uri uri ---@param args parser.object +---@param removeGeneric true? ---@return table<string, vm.node> -function mt:resolve(uri, args) +function mt:resolve(uri, args, removeGeneric) if not args then return nil end - local globalMgr = require 'vm.global-manager' local resolved = {} ---@param object parser.object @@ -33,7 +33,7 @@ function mt:resolve(uri, args) -- 'number' -> `T` for n in node:eachObject() do if n.type == 'string' then - local type = globalMgr.declareGlobal('type', n[1], guide.getUri(n)) + local type = vm.declareGlobal('type', n[1], guide.getUri(n)) resolved[key] = vm.createNode(type, resolved[key]) end end @@ -48,6 +48,19 @@ function mt:resolve(uri, args) -- number[] -> T[] resolve(object.node, vm.compileNode(n.node)) end + if n.type == 'doc.type.table' then + -- { [integer]: number } -> T[] + local tvalueNode = vm.getTableValue(uri, node, 'integer') + if tvalueNode then + resolve(object.node, tvalueNode) + end + end + if n.type == 'global' and n.cate == 'type' then + -- ---@field [integer]: number -> T[] + vm.getClassFields(uri, n, vm.declareGlobal('type', 'integer'), false, function (field) + resolve(object.node, vm.compileNode(field.extends)) + end) + end end end if object.type == 'doc.type.table' then @@ -98,7 +111,7 @@ function mt:resolve(uri, args) goto CONTINUE end end - local view = infer.viewObject(obj) + local view = vm.viewObject(obj) if view then knownTypes[view] = true end @@ -114,10 +127,10 @@ function mt:resolve(uri, args) local function buildArgNode(argNode, knownTypes) local newArgNode = vm.createNode() for n in argNode:eachObject() do - if argNode:isOptional() and vm.isFalsy(n) then + if argNode:hasFalsy() then goto CONTINUE end - local view = infer.viewObject(n) + local view = vm.viewObject(n) if knownTypes[view] then goto CONTINUE end @@ -156,7 +169,7 @@ function mt:resolve(uri, args) end ---@return vm.sign -return function () +function vm.createSign() local genericMgr = setmetatable({ signList = {}, }, mt) |