diff options
author | sumneko <sumneko@hotmail.com> | 2022-03-09 02:14:25 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2022-03-09 02:14:25 +0800 |
commit | 75df2fd38fe75e951ea80b5f1abae8772437ae04 (patch) | |
tree | 28e147e6fad887186424156421b2e31cc4a19fc9 /script/vm/infer.lua | |
parent | 9fb4ddc94e72856a98239d6f519f70ebaae2f03f (diff) | |
download | lua-language-server-75df2fd38fe75e951ea80b5f1abae8772437ae04.zip |
update
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r-- | script/vm/infer.lua | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua index 5adbfcb5..fc60cfa5 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -11,12 +11,16 @@ local viewNodeMap = util.switch() : case 'function' : case 'number' : case 'integer' - : call(function (source) + : call(function (source, options) + if source.type == 'number' then + options['hasNumber'] = true + end return source.type end) : case 'global' - : call(function (source) + : call(function (source, options) if source.cate == 'type' then + options['hasClass'] = true return source.name end end) @@ -24,26 +28,30 @@ local viewNodeMap = util.switch() ---@param node vm.node ---@return string? -local function viewNode(node) +local function viewNode(node, options) if viewNodeMap[node.type] then - return viewNodeMap[node.type](node) + return viewNodeMap[node.type](node, options) end end ---@param source parser.object function m.viewType(source) local compiler = require 'vm.compiler' - local node = compiler.compileNode(source) - local views = {} + local node = compiler.compileNode(source) + local views = {} + local options = {} for n in nodeMgr.eachNode(node) do - local view = viewNode(n) + local view = viewNode(n, options) if view then views[view] = true end end - if views['number'] then + if options['hasNumber'] then views['integer'] = nil end + if options['hasClass'] then + views['table'] = nil + end local array = {} for view in pairs(views) do array[#array+1] = view |