diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:52:59 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-26 13:52:59 +0800 |
commit | ca498542d4424322e2172425ab02a8986deb477b (patch) | |
tree | 093d0af88667c1fac500b0940473fa7b768f724c /server/src/method/textDocument | |
parent | 3b76eaf9620585c8f4b3304de030767e61ceb42c (diff) | |
download | lua-language-server-ca498542d4424322e2172425ab02a8986deb477b.zip |
跨文件的一个提示
Diffstat (limited to 'server/src/method/textDocument')
-rw-r--r-- | server/src/method/textDocument/definition.lua | 16 | ||||
-rw-r--r-- | server/src/method/textDocument/implementation.lua | 26 |
2 files changed, 39 insertions, 3 deletions
diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index 75df54da..1f21d67d 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -1,5 +1,18 @@ local matcher = require 'matcher' +local function checkWorkSpaceComplete(lsp, result) + if result.value then + if not result.value.isRequire then + return + end + else + if not result.isRequire then + return + end + end + lsp:checkWorkSpaceComplete() +end + return function (lsp, params) local uri = params.textDocument.uri local vm, lines = lsp:loadVM(uri) @@ -12,6 +25,9 @@ return function (lsp, params) if not result then return nil end + + checkWorkSpaceComplete(lsp, result) + local positions = matcher.definition(vm, result) if not positions then return nil diff --git a/server/src/method/textDocument/implementation.lua b/server/src/method/textDocument/implementation.lua index c42acf05..c92a8c56 100644 --- a/server/src/method/textDocument/implementation.lua +++ b/server/src/method/textDocument/implementation.lua @@ -1,16 +1,36 @@ local matcher = require 'matcher' +local function checkWorkSpaceComplete(lsp, result) + if result.value then + if not result.value.isRequire then + return + end + else + if not result.isRequire then + return + end + end + lsp:checkWorkSpaceComplete() +end + 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.implementation(vm, position) + local result = matcher.findResult(vm, position) + if not result then + return nil + end + + checkWorkSpaceComplete(lsp, result) + + local positions = matcher.implementation(vm, result) if not positions then - return {} + return nil end local locations = {} |