summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--script/core/diagnostics/unused-function.lua20
-rw-r--r--script/core/searcher.lua3
-rw-r--r--test/crossfile/definition.lua20
3 files changed, 35 insertions, 8 deletions
diff --git a/script/core/diagnostics/unused-function.lua b/script/core/diagnostics/unused-function.lua
index 523bca6e..8f6ccaac 100644
--- a/script/core/diagnostics/unused-function.lua
+++ b/script/core/diagnostics/unused-function.lua
@@ -41,14 +41,20 @@ return function (uri, callback)
if isToBeClosed(parent) then
return false
end
+ await.delay()
+ if parent.type == 'setlocal' then
+ parent = parent.node
+ end
+ local refs = parent.ref
local hasGet
- local refs = vm.getRefs(source)
- for _, src in ipairs(refs) do
- if guide.isGet(src) then
- local func = guide.getParentFunction(src)
- if not checkFunction(func) then
- hasGet = true
- break
+ if refs then
+ for _, src in ipairs(refs) do
+ if guide.isGet(src) then
+ local func = guide.getParentFunction(src)
+ if not checkFunction(func) then
+ hasGet = true
+ break
+ end
end
end
end
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 973c57a9..2fc24437 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -305,7 +305,7 @@ local function stop(status, msg)
log.warn(msg)
if FOOTPRINT then
FOOTPRINT = false
- log.debug(status.mode)
+ log.error(status.mode)
log.debug(tconcat(status.footprint, '\n'))
end
return
@@ -799,6 +799,7 @@ function m.searchRefsByID(status, suri, expect, mode)
local crossed = {}
if mode == 'def'
or mode == 'alldef'
+ or mode == 'field'
or ignoredIDs[id]
or id == 'dn:string'
or hasCall(field) then
diff --git a/test/crossfile/definition.lua b/test/crossfile/definition.lua
index 308c754f..6fb17082 100644
--- a/test/crossfile/definition.lua
+++ b/test/crossfile/definition.lua
@@ -829,3 +829,23 @@ print(t.x.<?a?>)
]]
}
}
+
+--TEST {
+-- {
+-- path = 'a.lua',
+-- content = [[
+-----@type Class
+--local m
+--m.<!xx!> = 1
+-- ]]
+-- },
+-- {
+-- path = 'b.lua',
+-- content = [[
+-----@class Class
+--local m
+--
+--print(m.<?xx?>)
+-- ]]
+-- }
+--}