summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2022-03-12 00:56:17 +0800
committersumneko <sumneko@hotmail.com>2022-03-12 00:56:17 +0800
commite8e0f4d2db165be2d0df5ea9f3e2eb0bbc9df793 (patch)
tree9373e4d67206d9b75e3fda21e4020e04470811ad /script
parent18ef2f600c3f389e6984e2366e8b0c93d30d5792 (diff)
downloadlua-language-server-e8e0f4d2db165be2d0df5ea9f3e2eb0bbc9df793.zip
update
Diffstat (limited to 'script')
-rw-r--r--script/vm/compiler.lua35
-rw-r--r--script/vm/infer.lua4
2 files changed, 38 insertions, 1 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua
index 367fb334..7d622f37 100644
--- a/script/vm/compiler.lua
+++ b/script/vm/compiler.lua
@@ -425,6 +425,24 @@ local compilerMap = util.switch()
end
end
end
+
+ if source.parent.type == 'callargs' then
+ local call = source.parent.parent
+ local callNode = m.compileNode(call.node)
+ for n in nodeMgr.eachNode(callNode) do
+ if n.type == 'function' then
+ for index, arg in ipairs(n.args) do
+ if call.args[index] == source then
+ for fn in nodeMgr.eachNode(m.compileNode(arg)) do
+ if fn.type == 'doc.type.function' then
+ nodeMgr.setNode(source, fn)
+ end
+ end
+ end
+ end
+ end
+ end
+ end
end)
: case 'paren'
: call(function (source)
@@ -467,7 +485,22 @@ local compilerMap = util.switch()
end
end
if source.parent.type == 'funcargs' and not hasMarkDoc and not hasMarkParam then
- nodeMgr.setNode(source, globalMgr.getGlobal('type', 'any'))
+ local func = source.parent.parent
+ local funcNode = m.compileNode(func)
+ local hasDocArg
+ for n in nodeMgr.eachNode(funcNode) do
+ if n.type == 'doc.type.function' then
+ for index, arg in ipairs(n.args) do
+ if func.args[index] == source then
+ nodeMgr.setNode(source, m.compileNode(arg))
+ hasDocArg = true
+ end
+ end
+ end
+ end
+ if not hasDocArg then
+ nodeMgr.setNode(source, globalMgr.getGlobal('type', 'any'))
+ end
end
-- for x in ... do
if source.parent.type == 'in' then
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index 564c732c..b78be013 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -85,6 +85,7 @@ local viewNodeMap = util.switch()
end)
: case 'doc.type.function'
: call(function (source, options)
+ options['hasDocFunction'] = true
local args = {}
local rets = {}
local argView = ''
@@ -167,6 +168,9 @@ function m.getViews(source)
if options['hasNumber'] then
views['integer'] = nil
end
+ if options['hasDocFunction'] then
+ views['function'] = nil
+ end
if options['hasTable'] and not options['hasClass'] then
views['table'] = true
end