summaryrefslogtreecommitdiff
path: root/script
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2021-08-17 11:31:25 +0800
committer最萌小汐 <sumneko@hotmail.com>2021-08-17 11:31:25 +0800
commit3f730ff7d9db1e8e51133a2ba19ee951714f5d8d (patch)
tree8fa552ed7e849dc19fcf11d149cdb0486e8a078a /script
parentb55df9c6704750cf129f75e0408a76806a5e80bd (diff)
downloadlua-language-server-3f730ff7d9db1e8e51133a2ba19ee951714f5d8d.zip
improve
Diffstat (limited to 'script')
-rw-r--r--script/core/noder.lua16
-rw-r--r--script/core/rename.lua8
-rw-r--r--script/core/searcher.lua27
3 files changed, 27 insertions, 24 deletions
diff --git a/script/core/noder.lua b/script/core/noder.lua
index 893c5cac..a966498c 100644
--- a/script/core/noder.lua
+++ b/script/core/noder.lua
@@ -682,18 +682,10 @@ local function bindValue(noders, source, id)
if not valueType then
return
end
- if valueType ~= 'p:'
- and valueType ~= 's:'
- and valueType ~= 'c:' then
- pushBackward(noders, valueID, id, {
- reject = 'set',
- })
- else
- pushBackward(noders, valueID, id, {
- reject = 'set',
- deep = true,
- })
- end
+ pushBackward(noders, valueID, id, {
+ reject = 'set',
+ deep = true,
+ })
end
local function compileCallParam(noders, call, sourceID)
diff --git a/script/core/rename.lua b/script/core/rename.lua
index 46c2630c..d0a0e25f 100644
--- a/script/core/rename.lua
+++ b/script/core/rename.lua
@@ -185,27 +185,27 @@ local function ofField(source, newname, callback)
else
node = source.node
end
- for _, src in ipairs(vm.getRefs(node, '*')) do
+ for _, src in ipairs(vm.getAllRefs(node, '*')) do
ofFieldThen(key, src, newname, callback)
end
end
local function ofGlobal(source, newname, callback)
local key = guide.getKeyName(source)
- for _, src in ipairs(vm.getRefs(source)) do
+ for _, src in ipairs(vm.getAllRefs(source)) do
ofFieldThen(key, src, newname, callback)
end
end
local function ofLabel(source, newname, callback)
- for _, src in ipairs(vm.getRefs(source)) do
+ for _, src in ipairs(vm.getAllRefs(source)) do
callback(src, src.start, src.finish, newname)
end
end
local function ofDocTypeName(source, newname, callback)
local oldname = source[1]
- for _, doc in ipairs(vm.getRefs(source)) do
+ for _, doc in ipairs(vm.getAllRefs(source)) do
if doc.type == 'doc.class.name'
or doc.type == 'doc.type.name'
or doc.type == 'doc.alias.name' then
diff --git a/script/core/searcher.lua b/script/core/searcher.lua
index 2fc24437..f653d29f 100644
--- a/script/core/searcher.lua
+++ b/script/core/searcher.lua
@@ -81,7 +81,7 @@ local ignoredIDs = {
---@class searcher
local m = {}
----@alias guide.searchmode '"ref"'|'"def"'|'"field"'|'"allref"'|'"alldef"'
+---@alias guide.searchmode '"ref"'|'"def"'|'"field"'|'"allref"'|'"alldef"'|'"allfield"'
local pushDefResultsMap = util.switch()
: case 'local'
@@ -199,13 +199,17 @@ local function pushResult(status, mode, source, force)
return
end
- if mode == 'def' or mode == 'alldef' then
+ if mode == 'def'
+ or mode == 'alldef' then
local f = pushDefResultsMap[source.type]
if f and f(source, status) then
results[#results+1] = source
return
end
- elseif mode == 'ref' or mode == 'field' or mode == 'allref' then
+ elseif mode == 'ref'
+ or mode == 'field'
+ or mode == 'allfield'
+ or mode == 'allref' then
local f = pushRefResultsMap[source.type]
if f and f(source, status) then
results[#results+1] = source
@@ -675,7 +679,7 @@ function m.searchRefsByID(status, suri, expect, mode)
---@param field string
---@param info node.info
local function checkInfoBeforeBackward(uri, id, field, info)
- if info.deep and mode ~= 'allref' then
+ if info.deep and mode ~= 'allref' and mode ~= 'allfield' then
return false
end
if not checkThenPushReject(uri, 'backward', info) then
@@ -704,7 +708,10 @@ function m.searchRefsByID(status, suri, expect, mode)
or id == 'dn:string' then
return
end
- if mode ~= 'ref' and mode ~= 'field' and mode ~= 'allref' and not field then
+ if mode ~= 'ref'
+ and mode ~= 'allfield'
+ and mode ~= 'allref'
+ and not field then
return
end
for backwardID, info in eachBackward(nodersMap[uri], id) do
@@ -733,7 +740,7 @@ function m.searchRefsByID(status, suri, expect, mode)
-- Special rule: ('').XX -> stringlib.XX
if id == 'str:'
or id == 'dn:string' then
- if field or mode == 'field' then
+ if field or mode == 'field' or mode == 'allfield' then
searchID(uri, 'dn:stringlib', field)
else
searchID(uri, 'dn:string', field)
@@ -1114,8 +1121,12 @@ function m.searchFields(status, source, mode, field)
if cached then
return
end
- local newStatus = m.status(source, field, 'field')
- m.searchRefsByID(newStatus, uri, id, 'field')
+ local fieldMode = 'field'
+ if mode == 'allref' then
+ fieldMode = 'allfield'
+ end
+ local newStatus = m.status(source, field, fieldMode)
+ m.searchRefsByID(newStatus, uri, id, fieldMode)
local results = newStatus.results
for i = 1, #results do
local def = results[i]