summaryrefslogtreecommitdiff
path: root/server/src/matcher
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-05 18:40:52 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-05 18:40:52 +0800
commit87a7ea0746191bec7f24315cef85c79be37d0bf8 (patch)
tree8615abfb26db534e7478430d405feb576d3aa69f /server/src/matcher
parentc8464b46347c08a2d63083670e19c5b3d8de86ee (diff)
downloadlua-language-server-87a7ea0746191bec7f24315cef85c79be37d0bf8.zip
对可使用的命名进行限制
Diffstat (limited to 'server/src/matcher')
-rw-r--r--server/src/matcher/rename.lua16
1 files changed, 13 insertions, 3 deletions
diff --git a/server/src/matcher/rename.lua b/server/src/matcher/rename.lua
index 13e72189..3b697309 100644
--- a/server/src/matcher/rename.lua
+++ b/server/src/matcher/rename.lua
@@ -1,4 +1,5 @@
local findResult = require 'matcher.find_result'
+local parser = require 'parser'
local function tryMeta(var)
local keys = {}
@@ -20,7 +21,7 @@ local function tryMeta(var)
return nil
end
-local function parseResult(result)
+local function parseResult(result, newName)
local positions = {}
local tp = result.type
if tp == 'var' then
@@ -29,6 +30,15 @@ local function parseResult(result)
if var.disable_rename and key == 'self' then
return positions
end
+ if result.info.source.index then
+ if not parser.grammar(newName, 'Exp') then
+ return positions
+ end
+ else
+ if not parser.grammar(newName, 'Name') then
+ return positions
+ end
+ end
for _, info in ipairs(var) do
if info.source[1] == key then
positions[#positions+1] = {info.source.start, info.source.finish}
@@ -51,11 +61,11 @@ local function parseResult(result)
return positions
end
-return function (results, pos)
+return function (results, pos, newName)
local result = findResult(results, pos)
if not result then
return nil
end
- local positions = parseResult(result)
+ local positions = parseResult(result, newName)
return positions
end