summaryrefslogtreecommitdiff
path: root/server/src/matcher/rename.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-12 17:24:19 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-12 17:24:19 +0800
commit8d112ba2f517e9ca6cf4146c16d713f8d7eabd03 (patch)
tree0223cc006bb1debb51ba9a6714863f084a1e1639 /server/src/matcher/rename.lua
parent3b48f52ca21700f928e3e463736e280f46b2a2c7 (diff)
downloadlua-language-server-8d112ba2f517e9ca6cf4146c16d713f8d7eabd03.zip
优化性能
Diffstat (limited to 'server/src/matcher/rename.lua')
-rw-r--r--server/src/matcher/rename.lua15
1 files changed, 7 insertions, 8 deletions
diff --git a/server/src/matcher/rename.lua b/server/src/matcher/rename.lua
index b395c696..1033d331 100644
--- a/server/src/matcher/rename.lua
+++ b/server/src/matcher/rename.lua
@@ -1,16 +1,15 @@
local findResult = require 'matcher.find_result'
local parser = require 'parser'
-local function parseResult(result, newName)
+local function parseResult(result, source, newName)
local positions = {}
local tp = result.type
if tp == 'local' or tp == 'field' then
- local var = result.object
- local key = result.info.source[1]
- if var.disableRename then
+ local key = source[1]
+ if result.disableRename then
return positions
end
- if result.info.source.index then
+ if source.index then
if not parser.grammar(newName, 'Exp') then
return positions
end
@@ -20,7 +19,7 @@ local function parseResult(result, newName)
end
end
local mark = {}
- for _, info in ipairs(var) do
+ for _, info in ipairs(result) do
if not mark[info.source] then
mark[info.source] = info
if info.source[1] == key then
@@ -43,10 +42,10 @@ local function parseResult(result, newName)
end
return function (vm, pos, newName)
- local result = findResult(vm.results, pos)
+ local result, source = findResult(vm, pos)
if not result then
return nil
end
- local positions = parseResult(result, newName)
+ local positions = parseResult(result, source, newName)
return positions
end