From a30de10b76398e6e0bacd06acca32915e1447cae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 8 Jun 2021 15:58:37 +0800 Subject: update --- script/core/rename.lua | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'script/core') 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 -- cgit v1.2.3