diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-05-19 20:13:17 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-05-19 20:13:17 +0800 |
commit | 4b444113489aae83d31f97b41161822efd0b16f6 (patch) | |
tree | 092abe86d083d29af451b05c03a43d9d2727d2f7 | |
parent | 2f6d6b215d1c902533936a8ef6fc49b3b3f7f658 (diff) | |
download | lua-language-server-4b444113489aae83d31f97b41161822efd0b16f6.zip |
update
-rw-r--r-- | script/core/definition.lua | 2 | ||||
-rw-r--r-- | script/core/reference.lua | 14 | ||||
-rw-r--r-- | script/core/searcher.lua | 10 |
3 files changed, 21 insertions, 5 deletions
diff --git a/script/core/definition.lua b/script/core/definition.lua index 5d90dad6..973ce5f1 100644 --- a/script/core/definition.lua +++ b/script/core/definition.lua @@ -132,7 +132,7 @@ return function (uri, offset) local values = {} for _, src in ipairs(defs) do local value = searcher.getObjectValue(src) - if value and value ~= src then + if value and value ~= src and guide.isLiteral(value) then values[value] = true end end diff --git a/script/core/reference.lua b/script/core/reference.lua index efeb28b6..ca067a75 100644 --- a/script/core/reference.lua +++ b/script/core/reference.lua @@ -65,11 +65,23 @@ return function (uri, offset) local metaSource = vm.isMetaFile(uri) + local refs = vm.getRefs(source, 5) + local values = {} + for _, src in ipairs(refs) do + local value = searcher.getObjectValue(src) + if value and value ~= src and guide.isLiteral(value) then + values[value] = true + end + end + local results = {} - for _, src in ipairs(vm.getRefs(source, 5)) do + for _, src in ipairs(refs) do if src.dummy then goto CONTINUE end + if values[src] then + goto CONTINUE + end local root = guide.getRoot(src) if not root then goto CONTINUE diff --git a/script/core/searcher.lua b/script/core/searcher.lua index 47fadf98..f2f2bd18 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -64,8 +64,7 @@ function m.pushResult(status, mode, source) results[#results+1] = source end end - if parent.type == 'return' - or parent.type == 'callargs' then + if parent.type == 'return' then if noder.getID(source) ~= status.id then results[#results+1] = source end @@ -88,6 +87,10 @@ function m.pushResult(status, mode, source) or source.type == 'tablefield' or source.type == 'function' or source.type == 'table' + or source.type == 'string' + or source.type == 'boolean' + or source.type == 'number' + or source.type == 'nil' or source.type == 'doc.class.name' or source.type == 'doc.type.name' or source.type == 'doc.alias.name' @@ -359,9 +362,10 @@ function m.searchRefsByID(status, uri, expect, mode) return end status.crossedGlobal[firstID] = true + local tid = id .. (field or '') for guri in files.eachFile() do if not files.eq(uri, guri) then - crossSearch(status, guri, id, mode) + crossSearch(status, guri, tid, mode) end end end |