summaryrefslogtreecommitdiff
path: root/server/src/method/textDocument/definition.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-12-03 19:10:26 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-12-03 19:10:26 +0800
commit2b2d9270b278d6f8b9eea5f20e3246355b91d711 (patch)
tree2f7dd5288178b9e1418725a58791d907d6f5d1fa /server/src/method/textDocument/definition.lua
parentbb58cb1593f7603c5eeb2bda59e23d27dc945e0d (diff)
downloadlua-language-server-2b2d9270b278d6f8b9eea5f20e3246355b91d711.zip
编译语法树与朝赵定义分离
Diffstat (limited to 'server/src/method/textDocument/definition.lua')
-rw-r--r--server/src/method/textDocument/definition.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua
index bb8918d6..bcdd6cac 100644
--- a/server/src/method/textDocument/definition.lua
+++ b/server/src/method/textDocument/definition.lua
@@ -4,20 +4,20 @@ local matcher = require 'matcher'
return function (lsp, params)
local start_clock = os.clock()
local uri = params.textDocument.uri
- local ast, lines = lsp:loadText(uri)
+ local results, lines = lsp:loadText(uri)
if not ast then
return {}
end
-- lua是从1开始的,因此都要+1
local position = lines:position(params.position.line + 1, params.position.character + 1, 'utf8')
- local suc, results = matcher.definition(ast, position)
- if not suc then
+ local positions = matcher.definition(results, position)
+ if not positions then
return {}
end
local locations = {}
- for i, result in ipairs(results) do
- local start, finish = result[1], result[2]
+ for i, position in ipairs(positions) do
+ local start, finish = position[1], position[2]
local start_row, start_col = lines:rowcol(start, 'utf8')
local finish_row, finish_col = lines:rowcol(finish, 'utf8')
locations[i] = {