diff options
-rw-r--r-- | script/core/noder.lua | 3 | ||||
-rw-r--r-- | script/core/searcher.lua | 37 | ||||
-rw-r--r-- | script/files.lua | 1 | ||||
-rw-r--r-- | script/vm/eachDef.lua | 2 | ||||
-rw-r--r-- | test/definition/init.lua | 6 |
5 files changed, 48 insertions, 1 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua index 137b4355..8bcc87e5 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -189,6 +189,9 @@ local function checkMode(source) or source.type == 'doc.type.name' or source.type == 'doc.alias.name' or source.type == 'doc.extends.name' then + if source.typeGeneric then + return 'dg:' + end return 'dn:' end if source.type == 'doc.field.name' then diff --git a/script/core/searcher.lua b/script/core/searcher.lua index c0111c9d..9765777c 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -23,6 +23,20 @@ local function checkFunctionReturn(source) return nil end +local ignoredIDs = { + ['dn:nil'] = true, + ['dn:any'] = true, + ['dn:boolean'] = true, + ['dn:string'] = true, + ['dn:table'] = true, + ['dn:number'] = true, + ['dn:integer'] = true, + ['dn:userdata'] = true, + ['dn:lightuserdata'] = true, + ['dn:function'] = true, + ['dn:thread'] = true, +} + local m = {} ---@alias guide.searchmode '"ref"'|'"def"'|'"field"' @@ -201,7 +215,11 @@ function m.searchRefsByID(status, uri, expect, mode) local callStack = status.callStack local mark = {} + local function search(id, field) + if ignoredIDs[id] then + --return + end local cmark = mark[id] if not cmark then cmark = {} @@ -381,6 +399,23 @@ function m.searchRefsByID(status, uri, expect, mode) end end + local function checkClass(id, node, field) + if id:sub(1, 3) ~= 'dn:' then + return + end + local firstID = noder.getFirstID(id) + if status.crossedClass[firstID] then + return + end + status.crossedClass[firstID] = true + local tid = id .. (field or '') + for guri in files.eachFile() do + if not files.eq(uri, guri) then + crossSearch(status, guri, tid, mode) + end + end + end + local function searchNode(id, node, field) if node.call then callStack[#callStack+1] = node.call @@ -407,6 +442,7 @@ function m.searchRefsByID(status, uri, expect, mode) end checkGlobal(id, node, field) + checkClass(id, node, field) if node.call then callStack[#callStack] = nil @@ -471,6 +507,7 @@ function m.status(parentStatus, interface, deep) --mark = parentStatus and parentStatus.mark or {}, callStack = {}, crossedGlobal = {}, + crossedClass = {}, results = {}, } return status diff --git a/script/files.lua b/script/files.lua index 3f3d633e..bb143250 100644 --- a/script/files.lua +++ b/script/files.lua @@ -345,6 +345,7 @@ function m.getAllUris() i = i + 1 files[i] = uri end + table.sort(files) end return m._pairsCache end diff --git a/script/vm/eachDef.lua b/script/vm/eachDef.lua index b120c8a5..e6af8d99 100644 --- a/script/vm/eachDef.lua +++ b/script/vm/eachDef.lua @@ -42,7 +42,7 @@ function vm.getDefs(source, deep) if not cache or cache.deep < deep then cache = getDefs(source, deep) cache.deep = deep - vm.getCache('eachDef')[source] = cache + --vm.getCache('eachDef')[source] = cache end return cache end diff --git a/test/definition/init.lua b/test/definition/init.lua index af302669..78170e0e 100644 --- a/test/definition/init.lua +++ b/test/definition/init.lua @@ -51,8 +51,14 @@ function TEST(script) positions[i] = { result.target.start, result.target.finish } end end + if not founded(target, positions) then + core('', pos) + end assert(founded(target, positions)) else + if #target ~= 0 then + core('', pos) + end assert(#target == 0) end end |