diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-06-08 15:58:37 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-06-08 15:58:37 +0800 |
commit | a30de10b76398e6e0bacd06acca32915e1447cae (patch) | |
tree | 6878d52c4a6f1035cc596e1a1ea9ccbef2eb32d5 /script/core | |
parent | 083656e8a1e558b5898915925d910ad035e8f615 (diff) | |
download | lua-language-server-a30de10b76398e6e0bacd06acca32915e1447cae.zip |
update
Diffstat (limited to 'script/core')
-rw-r--r-- | script/core/rename.lua | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/script/core/rename.lua b/script/core/rename.lua index 98528bf7..6b67d4be 100644 --- a/script/core/rename.lua +++ b/script/core/rename.lua @@ -1,11 +1,11 @@ local files = require 'files' local vm = require 'vm' -local searcher = require 'core.searcher' local proto = require 'proto' local define = require 'proto.define' local util = require 'utility' local findSource = require 'core.find-source' -local ws = require 'workspace' +local guide = require 'parser.guide' +local noder = require 'core.noder' local Forcing @@ -185,7 +185,7 @@ local function renameField(source, newname, callback) end callback(source, source.start, source.finish, newname) elseif parent.type == 'setmethod' then - local uri = searcher.getUri(source) + local uri = guide.getUri(source) local text = files.getText(uri) local func = parent.value -- function mt:name () end --> mt['newname'] = function (self) end @@ -284,7 +284,7 @@ local function ofFieldThen(key, src, newname, callback) end local function ofField(source, newname, callback) - local key = searcher.getKeyName(source) + local key = guide.getKeyName(source) local node if source.type == 'tablefield' or source.type == 'tableindex' then @@ -298,7 +298,7 @@ local function ofField(source, newname, callback) end local function ofGlobal(source, newname, callback) - local key = searcher.getKeyName(source) + local key = guide.getKeyName(source) for _, src in ipairs(vm.getRefs(source)) do ofFieldThen(key, src, newname, callback) end @@ -314,18 +314,21 @@ local function ofLabel(source, newname, callback) end local function ofDocTypeName(source, newname, callback) - for _, doc in ipairs(vm.getDocDefines(source[1])) do + local oldname = source[1] + for _, doc in ipairs(vm.getRefs(source)) do if doc.type == 'doc.class.name' or doc.type == 'doc.type.name' or doc.type == 'doc.alias.name' then - callback(doc, doc.start, doc.finish, newname) + if oldname == doc[1] then + callback(doc, doc.start, doc.finish, newname) + end end end end local function ofDocParamName(source, newname, callback) callback(source, source.start, source.finish, newname) - local doc = searcher.getDocState(source) + local doc = noder.getDocState(source) if doc.bindSources then for _, src in ipairs(doc.bindSources) do if src.type == 'local' @@ -452,7 +455,7 @@ function m.rename(uri, pos, newname) local mark = {} rename(source, newname, function (target, start, finish, text) - local turi = files.getOriginUri(searcher.getUri(target)) + local turi = files.getOriginUri(guide.getUri(target)) if not turi then return end |