summaryrefslogtreecommitdiff
path: root/script/core
diff options
context:
space:
mode:
Diffstat (limited to 'script/core')
-rw-r--r--script/core/noder.lua19
-rw-r--r--script/core/searcher.lua11
2 files changed, 23 insertions, 7 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 9bb2b9b5..b1eff89a 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -7,9 +7,11 @@ local SPLIT_CHAR = '\x1F'
local LAST_REGEX = SPLIT_CHAR .. '[^' .. SPLIT_CHAR .. ']*$'
local FIRST_REGEX = '^[^' .. SPLIT_CHAR .. ']*'
local ANY_FIELD_CHAR = '*'
+local INDEX_CHAR = '['
local RETURN_INDEX = SPLIT_CHAR .. '#'
local PARAM_INDEX = SPLIT_CHAR .. '&'
local TABLE_KEY = SPLIT_CHAR .. '<'
+local INDEX_FIELD = SPLIT_CHAR .. INDEX_CHAR
local ANY_FIELD = SPLIT_CHAR .. ANY_FIELD_CHAR
local URI_CHAR = '@'
local URI_REGEX = URI_CHAR .. '([^' .. URI_CHAR .. ']*)' .. URI_CHAR .. '(.*)'
@@ -71,15 +73,14 @@ local function getKey(source)
or source.type == 'getindex' then
local index = source.index
if not index then
- return ANY_FIELD_CHAR, source.node
+ return INDEX_CHAR, source.node
end
if index.type == 'string'
or index.type == 'boolean'
or index.type == 'number' then
return ('%q'):format(index[1] or ''), source.node
- elseif index.type ~= 'function'
- and index.type ~= 'table' then
- return ANY_FIELD_CHAR, source.node
+ else
+ return INDEX_CHAR, source.node
end
elseif source.type == 'tableindex' then
local index = source.index
@@ -377,6 +378,7 @@ m.PARAM_INDEX = PARAM_INDEX
m.TABLE_KEY = TABLE_KEY
m.ANY_FIELD = ANY_FIELD
m.URI_CHAR = URI_CHAR
+m.INDEX_FIELD = INDEX_FIELD
--- 寻找doc的主体
---@param obj parser.guide.object
@@ -433,6 +435,15 @@ function m.compileNode(noders, source)
end
end
end
+ if source.special == 'setmetatable'
+ or source.special == 'require'
+ or source.special == 'dofile'
+ or source.special == 'loadfile'
+ or source.special == 'rawset'
+ or source.special == 'rawget' then
+ local node = getNode(noders, id)
+ node.skip = true
+ end
-- self -> mt:xx
if source.type == 'local' and source[1] == 'self' then
local func = guide.getParentFunction(source)
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 2b4b4caa..5b187c3a 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -457,6 +457,9 @@ function m.searchRefsByID(status, uri, expect, mode)
status.crossed[id] = true
local isCall = field and field:sub(2, 2) == noder.RETURN_INDEX
local tid = id .. (field or '')
+ if FOOTPRINT then
+ status.footprint[#status.footprint+1] = ('checkGlobal:%s + %s, isCall: %s'):format(id, field, isCall, tid)
+ end
for guri, def in pairs(uris) do
if def then
crossSearch(status, guri, tid, mode)
@@ -509,7 +512,7 @@ function m.searchRefsByID(status, uri, expect, mode)
if node.require then
checkRequire(node.require, field)
- return true
+ return
end
local isSepcial = checkSpecial(id, node, field)
@@ -532,6 +535,8 @@ function m.searchRefsByID(status, uri, expect, mode)
if node.call then
callStack[#callStack] = nil
end
+
+ return false
end
local function checkAnyField(id, field)
@@ -574,8 +579,8 @@ function m.searchRefsByID(status, uri, expect, mode)
end
local node = noder.getNodeByID(root, id)
if node then
- local skip = searchNode(id, node, field)
- if skip then
+ searchNode(id, node, field)
+ if node.skip and field then
return
end
end