diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-10 17:54:42 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-10 17:54:42 +0800 |
commit | 32fd9f2cef67919ef37d7a6396ae0a8c7d7f224f (patch) | |
tree | eb76f5d29360cd2cdc05ff428e9e4a7aa7f13c6b /script/vm/infer.lua | |
parent | 2178706a33e6f15a8cea567c352d9a567c38abb9 (diff) | |
download | lua-language-server-32fd9f2cef67919ef37d7a6396ae0a8c7d7f224f.zip |
update
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r-- | script/vm/infer.lua | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua index 90c10145..95a01658 100644 --- a/script/vm/infer.lua +++ b/script/vm/infer.lua @@ -12,16 +12,20 @@ local viewNodeMap = util.switch() : case 'nil' : case 'boolean' : case 'string' - : case 'table' : case 'function' - : case 'number' : case 'integer' : call(function (source, options) - if source.type == 'number' then - options['hasNumber'] = true - end return source.type end) + : case 'number' + : call(function (source, options) + options['hasNumber'] = true + return source.type + end) + : case 'table' + : call(function (source, options) + options['hasTable'] = true + end) : case 'global' : call(function (source, options) if source.cate == 'type' then @@ -29,6 +33,15 @@ local viewNodeMap = util.switch() return source.name end end) + : case 'doc.type.array' + : call(function (source, options) + options['hasClass'] = true + return m.viewType(source.node) .. '[]' + end) + : case 'doc.type.enum' + : call(function (source, options) + return source[1] + end) : getMap() ---@param node vm.node @@ -54,8 +67,8 @@ function m.viewType(source) if options['hasNumber'] then views['integer'] = nil end - if options['hasClass'] then - views['table'] = nil + if options['hasTable'] and not options['hasClass'] then + views['table'] = true end local array = {} for view in pairs(views) do |