summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/hover/arg.lua2
-rw-r--r--script/core/hover/name.lua4
-rw-r--r--script/core/hover/return.lua3
-rw-r--r--script/core/infer.lua8
-rw-r--r--script/core/noder.lua17
5 files changed, 28 insertions, 6 deletions
diff --git a/script/core/hover/arg.lua b/script/core/hover/arg.lua
index 41371689..822be2b6 100644
--- a/script/core/hover/arg.lua
+++ b/script/core/hover/arg.lua
@@ -64,7 +64,7 @@ local function asDocFunction(source)
args[i] = ('%s%s: %s'):format(
name,
arg.optional and '?' or '',
- vm.getInferType(arg.extends)
+ infer.searchAndViewInfers(arg.extends)
)
else
args[i] = ('%s%s'):format(
diff --git a/script/core/hover/name.lua b/script/core/hover/name.lua
index 6db6e8ea..f56161f5 100644
--- a/script/core/hover/name.lua
+++ b/script/core/hover/name.lua
@@ -44,8 +44,8 @@ local function asGlobal(source)
end
local function asDocFunction(source)
- local doc = searcher.getParentType(source, 'doc.type')
- or searcher.getParentType(source, 'doc.overload')
+ local doc = guide.getParentType(source, 'doc.type')
+ or guide.getParentType(source, 'doc.overload')
if not doc or not doc.bindSources then
return ''
end
diff --git a/script/core/hover/return.lua b/script/core/hover/return.lua
index 050e25cd..0f0d85e0 100644
--- a/script/core/hover/return.lua
+++ b/script/core/hover/return.lua
@@ -1,4 +1,3 @@
-local vm = require 'vm'
local infer = require 'core.infer'
local function getReturnDualByDoc(source)
@@ -92,7 +91,7 @@ local function asDocFunction(source)
local returns = {}
for i, rtn in ipairs(source.returns) do
local rtnText = ('%s%s'):format(
- vm.getInferType(rtn),
+ infer.searchAndViewInfers(rtn),
rtn.optional and '?' or ''
)
if i == 1 then
diff --git a/script/core/infer.lua b/script/core/infer.lua
index ce89a6c9..d6ed61f9 100644
--- a/script/core/infer.lua
+++ b/script/core/infer.lua
@@ -125,7 +125,13 @@ local function searchInferOfValue(value, infers)
return true
end
if value.type == 'table' then
- infers['table'] = true
+ if value.array then
+ local node = m.searchAndViewInfers(value.array)
+ local infer = node .. '[]'
+ infers[infer] = true
+ else
+ infers['table'] = true
+ end
return true
end
if value.type == 'number' then
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 58144a27..8d5b9a07 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -126,6 +126,10 @@ local function getKey(source)
return source.start, nil
elseif source.type == '...' then
return source.start, nil
+ elseif source.type == 'varargs' then
+ if source.node then
+ return source.node.start, nil
+ end
elseif source.type == 'select' then
return ('%d%s%d'):format(source.start, RETURN_INDEX, source.sindex)
elseif source.type == 'call' then
@@ -576,6 +580,9 @@ function m.compileNode(noders, source)
pushBackward(noders, funcXID, id)
end
end
+ if source.vararg.type == 'varargs' then
+ pushForward(noders, id, getID(source.vararg))
+ end
end
if source.type == 'doc.type.function' then
if source.returns then
@@ -695,6 +702,16 @@ function m.compileNode(noders, source)
end
end
end
+ if source.type == 'table' then
+ if #source == 1 and source[1].type == 'varargs' then
+ source.array = source[1]
+ local nodeID = ('%s%s'):format(
+ id,
+ ANY_FIELD
+ )
+ pushForward(noders, nodeID, getID(source[1]))
+ end
+ end
if source.type == 'main' then
if source.returns then
for _, rtn in ipairs(source.returns) do