summaryrefslogtreecommitdiff
path: root/script-beta/core/rename.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-12-14 17:06:51 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-12-14 17:06:51 +0800
commit45fb8f5578e6d11d845d0676d97a392ace627cb7 (patch)
tree77120b0a0e48d275dbb87ba28d5d4eb6ddf6c5df /script-beta/core/rename.lua
parent83611b3112bd6c4bf0fe51df585549aa32e9ff51 (diff)
downloadlua-language-server-45fb8f5578e6d11d845d0676d97a392ace627cb7.zip
rename field
Diffstat (limited to 'script-beta/core/rename.lua')
-rw-r--r--script-beta/core/rename.lua18
1 files changed, 15 insertions, 3 deletions
diff --git a/script-beta/core/rename.lua b/script-beta/core/rename.lua
index d8a39ea2..581fd19a 100644
--- a/script-beta/core/rename.lua
+++ b/script-beta/core/rename.lua
@@ -227,7 +227,18 @@ local function ofLocal(source, newname, callback)
end
local function ofField(source, newname, callback)
- return vm.eachRef(source, function (info)
+ local key = guide.getKeyName(source)
+ local tbl
+ if source.type == 'tablefield'
+ or source.type == 'tableindex' then
+ tbl = source.parent
+ else
+ tbl = source.node
+ end
+ return vm.eachField(tbl, function (info)
+ if info.key ~= key then
+ return
+ end
local src = info.source
if src.type == 'tablefield'
or src.type == 'getfield'
@@ -278,8 +289,9 @@ local function rename(source, newname, callback)
return ofLocal(source.node, newname, callback)
elseif source.type == 'field'
or source.type == 'method'
- or source.type == 'tablefield'
- or source.type == 'string'
+ or source.type == 'string' then
+ return ofField(source.parent, newname, callback)
+ elseif source.type == 'tablefield'
or source.type == 'setglobal'
or source.type == 'getglobal' then
return ofField(source, newname, callback)