diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-03 18:53:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-03 18:53:49 +0800 |
commit | bb58cb1593f7603c5eeb2bda59e23d27dc945e0d (patch) | |
tree | 9c7a10f8fd45179c9bdf07bf28dcd95155e30838 | |
parent | 495fcb427cdd57fd8304c15d71483ed80183e51d (diff) | |
download | lua-language-server-bb58cb1593f7603c5eeb2bda59e23d27dc945e0d.zip |
不要把单次结果存在语法树里
-rw-r--r-- | server/src/matcher/definition.lua | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index 32d901d1..26a51a4f 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -498,37 +498,34 @@ function mt:definition() for _, var in ipairs(self.results.vars) do for _, info in ipairs(var) do if self:isContainPos(info.source) then - self.result = { + return { type = 'var', var = var, } - return end end end for _, dots in ipairs(self.results.dots) do for _, info in ipairs(dots) do if self:isContainPos(info.source) then - self.result = { + return { type = 'dots', dots = dots, } - return end end end for _, label in ipairs(self.results.labels) do for _, info in ipairs(label) do if self:isContainPos(info.source) then - self.result = { + return { type = 'label', label = label, } - return end end end - log.error('no found') + return nil end local function parseResult(result) @@ -588,11 +585,11 @@ return function (ast, pos) searcher:createLocal('_ENV') searcher:searchActions(ast) - searcher:definition() + local result = searcher:definition() - if not searcher.result then + if not result then return false end - return parseResult(searcher.result) + return parseResult(result) end |