summaryrefslogtreecommitdiff
path: root/src/method/textDocument
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2018-11-20 13:35:16 +0800
committer最萌小汐 <sumneko@hotmail.com>2018-11-20 13:35:16 +0800
commitc6e00ba82ab0e15fbbaad59ef91cfb08caeb6f7d (patch)
tree808fde71dbcd2a3d6436d381e2e6100e78281c29 /src/method/textDocument
parent4321271853b484150d37b9908fdab46fde0ad8fa (diff)
downloadlua-language-server-c6e00ba82ab0e15fbbaad59ef91cfb08caeb6f7d.zip
支持多个实现
Diffstat (limited to 'src/method/textDocument')
-rw-r--r--src/method/textDocument/implementation.lua39
1 files changed, 22 insertions, 17 deletions
diff --git a/src/method/textDocument/implementation.lua b/src/method/textDocument/implementation.lua
index 95bd0c20..6008efb7 100644
--- a/src/method/textDocument/implementation.lua
+++ b/src/method/textDocument/implementation.lua
@@ -10,7 +10,7 @@ return function (lsp, params)
local start_clock = os.clock()
-- lua是从1开始的,因此都要+1
local pos = parser.calcline.position_utf8(text, params.position.line + 1, params.position.character + 1)
- local suc, start, finish = matcher.implementation(text, pos)
+ local suc, results = matcher.implementation(text, pos)
if not suc then
if finish then
log.debug(start, uri)
@@ -20,23 +20,28 @@ return function (lsp, params)
return {}
end
- local start_row, start_col = parser.calcline.rowcol_utf8(text, start)
- local finish_row, finish_col = parser.calcline.rowcol_utf8(text, finish)
+ local locations = {}
+ for i, result in ipairs(results) do
+ local start, finish = result[1], result[2]
+ local start_row, start_col = parser.calcline.rowcol_utf8(text, start)
+ local finish_row, finish_col = parser.calcline.rowcol_utf8(text, finish)
+ locations[i] = {
+ uri = uri,
+ range = {
+ start = {
+ line = start_row - 1,
+ character = start_col - 1,
+ },
+ ['end'] = {
+ line = finish_row - 1,
+ -- 这里不用-1,因为前端期待的是匹配完成后的位置
+ character = finish_col,
+ },
+ }
+ }
+ end
- local response = {
- uri = uri,
- range = {
- start = {
- line = start_row - 1,
- character = start_col - 1,
- },
- ['end'] = {
- line = finish_row - 1,
- -- 这里不用-1,因为前端期待的是匹配完成后的位置
- character = finish_col,
- },
- },
- }
+ local response = locations
local passed_clock = os.clock() - start_clock
if passed_clock >= 0.01 then
log.warn(('[转到实现]耗时[%.3f]秒,文件大小[%s]字节'):format(passed_clock, #text))