summaryrefslogtreecommitdiff
path: root/script/vm
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-01 19:00:18 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-01 19:00:18 +0800
commit1938e690dae0aa2028f8fce6564486f02dd73c5f (patch)
treedb560500eaddf0bda81c6e7fc0497314bde3f307 /script/vm
parentd699b4cac83b81b023323076b74d3d03b6b13ee6 (diff)
downloadlua-language-server-1938e690dae0aa2028f8fce6564486f02dd73c5f.zip
update
Diffstat (limited to 'script/vm')
-rw-r--r--script/vm/infer.lua22
1 files changed, 19 insertions, 3 deletions
diff --git a/script/vm/infer.lua b/script/vm/infer.lua
index 61d76caf..5a6ec369 100644
--- a/script/vm/infer.lua
+++ b/script/vm/infer.lua
@@ -18,9 +18,10 @@ mt.__index = mt
mt._hasNumber = false
mt._hasTable = false
mt._hasClass = false
+mt._hasFunctionDef = false
+mt._hasDocFunction = false
mt._isParam = false
mt._isLocal = false
-mt._hasDocFunction = false
m.NULL = setmetatable({}, mt)
@@ -38,7 +39,6 @@ local viewNodeSwitch = util.switch()
: case 'nil'
: case 'boolean'
: case 'string'
- : case 'function'
: case 'integer'
: call(function (source, infer)
return source.type
@@ -52,6 +52,14 @@ local viewNodeSwitch = util.switch()
: call(function (source, infer)
infer._hasTable = true
end)
+ : case 'function'
+ : call(function (source, infer)
+ local parent = source.parent
+ if guide.isSet(parent) then
+ infer._hasFunctionDef = true
+ end
+ return source.type
+ end)
: case 'local'
: call(function (source, infer)
if source.parent == 'funcargs' then
@@ -156,7 +164,15 @@ function mt:_trim()
self.views['integer'] = nil
end
if self._hasDocFunction then
- self.views['function'] = nil
+ if self._hasFunctionDef then
+ for view in pairs(self.views) do
+ if view:sub(1, 4) == 'fun(' then
+ self.views[view] = nil
+ end
+ end
+ else
+ self.views['function'] = nil
+ end
end
if self._hasTable and not self._hasClass then
self.views['table'] = true