summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
Diffstat (limited to 'script')
-rw-r--r--script/core/hover/table.lua5
-rw-r--r--script/parser/guide.lua52
-rw-r--r--script/parser/luadoc.lua1
3 files changed, 29 insertions, 29 deletions
diff --git a/script/core/hover/table.lua b/script/core/hover/table.lua
index 9fd79a25..58e64951 100644
--- a/script/core/hover/table.lua
+++ b/script/core/hover/table.lua
@@ -31,9 +31,10 @@ local function getKey(src)
end
local function getFieldFull(src)
- local tp = vm.getInferType(src)
+ local value = guide.getObjectValue(src) or src
+ local tp = vm.getInferType(value, 0)
--local class = vm.getClass(src)
- local literal = vm.getInferLiteral(src)
+ local literal = vm.getInferLiteral(value)
if type(literal) == 'string' and #literal >= 50 then
literal = literal:sub(1, 47) .. '...'
end
diff --git a/script/parser/guide.lua b/script/parser/guide.lua
index ea250356..31bc1a30 100644
--- a/script/parser/guide.lua
+++ b/script/parser/guide.lua
@@ -1350,6 +1350,10 @@ function m.getCallValue(source)
else
return
end
+ if call.node.special == 'pcall'
+ or call.node.special == 'xpcall' then
+ return call.args[1], call.args, index - 1
+ end
return call.node, call.args, index
end
@@ -1688,7 +1692,7 @@ function m.checkSameSimpleByDoc(status, obj, start, pushQueue, mode)
end
local state = m.getDocState(obj)
if state.type == 'doc.type' and mode == 'ref' then
- m.checkSameSimpleOfRefByDocSource(status, state, start, pushQueue, mode)
+ m.checkSameSimpleOfRefByDocSource(status, state, start - (obj.arrayLevel or 0), pushQueue, mode)
end
return true
elseif obj.type == 'doc.field' then
@@ -1900,13 +1904,13 @@ function m.checkSameSimpleInCall(status, ref, start, pushQueue, mode)
return
end
status.share.crossCallCount = status.share.crossCallCount or 0
- if status.share.crossCallCount >= 5 then
- return
- end
- status.share.crossCallCount = status.share.crossCallCount + 1
-- 检查赋值是 semetatable() 的情况
m.checkSameSimpleInValueOfSetMetaTable(status, func, start, pushQueue)
-- 检查赋值是 func() 的情况
+ if status.share.crossCallCount >= 2 then
+ return
+ end
+ status.share.crossCallCount = status.share.crossCallCount + 1
local objs = m.checkSameSimpleInCallInSameFile(status, func, args, index)
if status.interface.call then
local cobjs = status.interface.call(func, args, index)
@@ -2311,18 +2315,12 @@ function m.pushResult(status, mode, ref, simple)
elseif ref.type == 'setglobal'
or ref.type == 'getglobal' then
results[#results+1] = ref
- elseif ref.type == 'function' then
- results[#results+1] = ref
- elseif ref.type == 'table' then
- results[#results+1] = ref
elseif ref.type == 'call' then
if ref.node.special == 'rawset'
or ref.node.special == 'rawget' then
results[#results+1] = ref
end
- elseif ref.type == 'doc.type.function'
- or ref.type == 'doc.class.name'
- or ref.type == 'doc.field' then
+ elseif ref.type == 'doc.field' then
results[#results+1] = ref
end
elseif mode == 'deffield' then
@@ -2336,17 +2334,11 @@ function m.pushResult(status, mode, ref, simple)
results[#results+1] = ref
elseif ref.type == 'setglobal' then
results[#results+1] = ref
- elseif ref.type == 'function' then
- results[#results+1] = ref
- elseif ref.type == 'table' then
- results[#results+1] = ref
elseif ref.type == 'call' then
if ref.node.special == 'rawset' then
results[#results+1] = ref
end
- elseif ref.type == 'doc.type.function'
- or ref.type == 'doc.class.name'
- or ref.type == 'doc.field' then
+ elseif ref.type == 'doc.field' then
results[#results+1] = ref
end
end
@@ -3700,10 +3692,18 @@ function m.inferByDef(status, obj)
for _, src in ipairs(newStatus.results) do
local inferStatus = m.status(newStatus)
m.searchInfer(inferStatus, src)
- for _, infer in ipairs(inferStatus.results) do
- if not mark[infer.source] then
- mark[infer.source] = true
- status.results[#status.results+1] = infer
+ if #inferStatus.results == 0 then
+ status.results[#status.results+1] = {
+ type = 'any',
+ source = src,
+ level = 0,
+ }
+ else
+ for _, infer in ipairs(inferStatus.results) do
+ if not mark[infer.source] then
+ mark[infer.source] = true
+ status.results[#status.results+1] = infer
+ end
end
end
end
@@ -3731,7 +3731,7 @@ local function inferBySetOfLocal(status, source)
end
end
-function m.inferBySet(status, source)
+function m.inferByLocalRef(status, source)
if #status.results ~= 0 then
return
end
@@ -4117,18 +4117,16 @@ function m.searchInfer(status, obj)
return
end
+ m.inferByLocalRef(status, obj)
if status.deep then
tracy.ZoneBeginN('inferByDef')
m.inferByDef(status, obj)
tracy.ZoneEnd()
end
- m.inferBySet(status, obj)
m.inferByCall(status, obj)
m.inferByGetTable(status, obj)
m.inferByUnary(status, obj)
m.inferByBinary(status, obj)
- m.inferByCallReturn(status, obj)
- m.inferByPCallReturn(status, obj)
m.cleanInfers(status.results, obj)
if makeCache then
makeCache(status.results)
diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua
index 990b4606..1a45878e 100644
--- a/script/parser/luadoc.lua
+++ b/script/parser/luadoc.lua
@@ -257,6 +257,7 @@ local function parseTypeUnitArray(node)
finish = getFinish(),
node = node,
}
+ node.arrayLevel = (node.arrayLevel or 0) + 1
return result
end