summaryrefslogtreecommitdiff
path: root/script/vm/ref.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-04-08 12:22:06 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-04-08 12:22:06 +0800
commita086e4a20d9f3f5db9947a682e1668c04c0c5d1b (patch)
tree7d203734c613dbe95b05d353dcb4acfc28f9657c /script/vm/ref.lua
parent5a8568991fe3d8570ec0d76dd7314d7f26b8b32b (diff)
downloadlua-language-server-a086e4a20d9f3f5db9947a682e1668c04c0c5d1b.zip
ref includes def
Diffstat (limited to 'script/vm/ref.lua')
-rw-r--r--script/vm/ref.lua18
1 files changed, 14 insertions, 4 deletions
diff --git a/script/vm/ref.lua b/script/vm/ref.lua
index 052d74eb..70e7c483 100644
--- a/script/vm/ref.lua
+++ b/script/vm/ref.lua
@@ -16,7 +16,6 @@ local function searchGetLocal(source, node, pushResult)
for _, ref in ipairs(node.node.ref) do
if ref.type == 'getlocal'
and ref.next
- and not guide.isSet(ref.next)
and guide.getKeyName(ref.next) == key then
pushResult(ref.next)
end
@@ -192,6 +191,7 @@ local searchByParentNode
local nodeSwitch = util.switch()
: case 'field'
: case 'method'
+ ---@async
: call(function (source, pushResult, fileNotify)
searchByParentNode(source.parent, pushResult, fileNotify)
end)
@@ -242,9 +242,7 @@ local function searchByLocalID(source, pushResult)
return
end
for _, src in ipairs(idSources) do
- if not guide.isSet(src) then
- pushResult(src)
- end
+ pushResult(src)
end
end
@@ -270,6 +268,17 @@ local function searchByNode(source, pushResult)
end
end
+local function searchByDef(source, pushResult)
+ if source.type == 'function'
+ or source.type == 'doc.type.function' then
+ return
+ end
+ local defs = vm.getDefs(source)
+ for _, def in ipairs(defs) do
+ pushResult(def)
+ end
+end
+
---@async
---@param source parser.object
---@param fileNotify fun(uri: uri): boolean
@@ -294,6 +303,7 @@ function vm.getRefs(source, fileNotify)
searchBySimple(source, pushResult)
searchByLocalID(source, pushResult)
searchByNode(source, pushResult)
+ searchByDef(source, pushResult)
searchByParentNode(source, pushResult, fileNotify)
return results