diff options
-rw-r--r-- | script/core/noder.lua | 15 | ||||
-rw-r--r-- | script/core/searcher.lua | 25 | ||||
-rw-r--r-- | test/crossfile/references.lua | 22 |
3 files changed, 51 insertions, 11 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua index 102245d9..c2f2061a 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -1606,14 +1606,13 @@ function m.compileGlobalNodes(root) m.compilePartNodes(noders, env) local docs = root.docs - for i = 1, #docs do - local doc = docs[i] - if doc.type == 'doc.class' then - m.compileNode(noders, doc.class) - elseif doc.type == 'doc.alias' then - m.compileNode(noders, doc.alias) - end - end + guide.eachSourceTypes(docs, { + 'doc.class.name', + 'doc.alias.name', + 'doc.type.name', + }, function (doc) + m.compileNode(noders, doc) + end) end files.watch(function (ev, uri) diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 0e8ce04c..89bb35d3 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -759,7 +759,7 @@ function m.searchRefsByID(status, suri, expect, mode) if ssub(id, 1, 2) ~= 'g:' then return end - footprint(status, 'checkGlobal:', id, field) + footprint(status, 'searchGlobal:', id, field) local crossed = {} if mode == 'def' or mode == 'alldef' @@ -792,9 +792,28 @@ function m.searchRefsByID(status, suri, expect, mode) if ssub(id, 1, 3) ~= 'dn:' then return end - for _, guri in ceach('def:' .. id) do - if uri ~= guri then + footprint(status, 'searchClass:', id, field) + local crossed = {} + if mode == 'def' + or mode == 'alldef' + or ignoredIDs[id] then + for _, guri in ceach('def:' .. id) do + if uri == guri then + goto CONTINUE + end searchID(guri, id, field, uri) + ::CONTINUE:: + end + else + for _, guri in ceach(id) do + if crossed[guri] then + goto CONTINUE + end + if uri == guri then + goto CONTINUE + end + searchID(guri, id, field, uri) + ::CONTINUE:: end end end diff --git a/test/crossfile/references.lua b/test/crossfile/references.lua index 0a6f0b57..6c28b34b 100644 --- a/test/crossfile/references.lua +++ b/test/crossfile/references.lua @@ -195,3 +195,25 @@ TEST { ]], }, } + +TEST { + { + path = 'a.lua', + content = [[ + ---@type A + local t + + t.<!f!>() + ]] + }, + { + path = 'b.lua', + content = [[ + ---@class A + local mt + + function mt.<?f?>() + end + ]] + } +} |