diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:22:35 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:22:35 +0800 |
commit | 1e914171e328c90237b98560cae49f6e386c01cf (patch) | |
tree | 515162ef88473805bd88e2ee018ea49798c331b4 /server/src | |
parent | 097e9c06c9a78d3ae845a7eec694a2dbe99161b0 (diff) | |
download | lua-language-server-1e914171e328c90237b98560cae49f6e386c01cf.zip |
整理代码
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/matcher/definition.lua | 6 | ||||
-rw-r--r-- | server/src/method/textDocument/definition.lua | 10 |
2 files changed, 8 insertions, 8 deletions
diff --git a/server/src/matcher/definition.lua b/server/src/matcher/definition.lua index b4a19b55..5b79aedd 100644 --- a/server/src/matcher/definition.lua +++ b/server/src/matcher/definition.lua @@ -1,5 +1,3 @@ -local findResult = require 'matcher.find_result' - local function parseResultAcrossUri(positions, vm, result) -- 跨越文件时,遍历的是值的绑定信息 for _, info in ipairs(result.value) do @@ -81,12 +79,10 @@ local function parseResult(vm, result) return positions end -return function (vm, pos) - local result = findResult(vm, pos) +return function (vm, result) if not result then return nil end - local positions = parseResult(vm, result) return positions end diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index 9115638b..75df54da 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -4,13 +4,17 @@ return function (lsp, params) local uri = params.textDocument.uri local vm, lines = lsp:loadVM(uri) if not vm then - return {} + return nil end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) - local positions = matcher.definition(vm, position) + local result = matcher.findResult(vm, position) + if not result then + return nil + end + local positions = matcher.definition(vm, result) if not positions then - return {} + return nil end local locations = {} |