summaryrefslogtreecommitdiff
path: root/script/vm/infer.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-10 20:31:47 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-10 20:31:47 +0800
commit04601c7da4a485d84be5e0b9864acf27f978c275 (patch)
tree7edcc2cf6868dfb1cf85412591f03faf5bf8c108 /script/vm/infer.lua
parent38a2b7f9df15b8737ba6fba27861eba50b2277b6 (diff)
downloadlua-language-server-04601c7da4a485d84be5e0b9864acf27f978c275.zip
doc.type.integer
Diffstat (limited to 'script/vm/infer.lua')
-rw-r--r--script/vm/infer.lua25
1 files changed, 18 insertions, 7 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index c396f3ec..80558eaf 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -1,5 +1,7 @@
local util = require 'utility'
local nodeMgr = require 'vm.node'
+local config = require 'config'
+local guide = require 'parser.guide'
---@class vm.infer-manager
local m = {}
@@ -33,6 +35,10 @@ local viewNodeMap = util.switch()
return source.name
end
end)
+ : case 'doc.type.integer'
+ : call(function (source, options)
+ return ('%d'):format(source[1])
+ end)
: case 'doc.type.name'
: call(function (source, options)
return source[1]
@@ -56,15 +62,19 @@ local function viewNode(node, options)
end
end
-local function eraseAlias(node, viewMap)
+local function eraseAlias(node, viewMap, options)
for n in nodeMgr.eachNode(node) do
if n.type == 'global' and n.cate == 'type' then
for _, set in ipairs(n:getSets()) do
if set.type == 'doc.alias' then
- for _, ext in ipairs(set.extends.types) do
- local view = viewNode(ext, {})
- if view and view ~= n.name then
- viewMap[view] = nil
+ if options['expandAlias'] then
+ viewMap[n.name] = nil
+ else
+ for _, ext in ipairs(set.extends.types) do
+ local view = viewNode(ext, {})
+ if view and view ~= n.name then
+ viewMap[view] = nil
+ end
end
end
end
@@ -81,8 +91,9 @@ function m.getViews(source)
if node.type == 'union' and node.lastViews then
return node.lastViews
end
- local views = {}
+ local views = {}
local options = {}
+ options['expandAlias'] = config.get(guide.getUri(source), 'Lua.hover.expandAlias')
if node.type == 'union' then
node.lastViews = views
end
@@ -99,7 +110,7 @@ function m.getViews(source)
views['table'] = true
end
if options['hasClass'] then
- eraseAlias(node, views)
+ eraseAlias(node, views, options)
end
return views
end