diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 12:22:06 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-08 12:22:06 +0800 |
commit | a086e4a20d9f3f5db9947a682e1668c04c0c5d1b (patch) | |
tree | 7d203734c613dbe95b05d353dcb4acfc28f9657c /script | |
parent | 5a8568991fe3d8570ec0d76dd7314d7f26b8b32b (diff) | |
download | lua-language-server-a086e4a20d9f3f5db9947a682e1668c04c0c5d1b.zip |
ref includes def
Diffstat (limited to 'script')
-rw-r--r-- | script/core/highlight.lua | 15 | ||||
-rw-r--r-- | script/core/rename.lua | 11 | ||||
-rw-r--r-- | script/vm/ref.lua | 18 |
3 files changed, 15 insertions, 29 deletions
diff --git a/script/core/highlight.lua b/script/core/highlight.lua index d07290f6..61e759ea 100644 --- a/script/core/highlight.lua +++ b/script/core/highlight.lua @@ -7,24 +7,11 @@ local guide = require 'parser.guide' ---@async local function eachRef(source, callback) - local uri = guide.getUri(source) - local mark = {} local refs = vm.getRefs(source, function () return false end) for _, ref in ipairs(refs) do - if not mark[ref] then - mark[ref] = true - callback(ref) - end - end - local defs = vm.getDefs(source) - for _, def in ipairs(defs) do - if not mark[def] - and guide.getUri(def) == uri then - mark[def] = true - callback(def) - end + callback(ref) end end diff --git a/script/core/rename.lua b/script/core/rename.lua index e95186c1..f1ee93c5 100644 --- a/script/core/rename.lua +++ b/script/core/rename.lua @@ -182,20 +182,9 @@ end ---@async local function ofField(source, newname, callback) local key = guide.getKeyName(source) - local mark = {} local refs = vm.getRefs(source) for _, ref in ipairs(refs) do - if not mark[ref] then - mark[ref] = true ofFieldThen(key, ref, newname, callback) - end - end - local defs = vm.getDefs(source) - for _, def in ipairs(defs) do - if not mark[def] then - mark[def] = true - ofFieldThen(key, def, newname, callback) - end end end 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 |