diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 17:15:16 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-11-29 17:15:16 +0800 |
commit | fd8737e3129c766752f81a69484bb073be7f72a0 (patch) | |
tree | edf6bb96e793b61cb923928d5728376b662dc56b /server/src/method/textDocument/definition.lua | |
parent | 9992c649cde19d4db8c9a9a7b47eb71bb2eaa283 (diff) | |
download | lua-language-server-fd8737e3129c766752f81a69484bb073be7f72a0.zip |
缓存语法树
Diffstat (limited to 'server/src/method/textDocument/definition.lua')
-rw-r--r-- | server/src/method/textDocument/definition.lua | 9 |
1 files changed, 2 insertions, 7 deletions
diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index 0878e29c..f5fb6472 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -3,16 +3,11 @@ local matcher = require 'matcher' return function (lsp, params) local uri = params.textDocument.uri - local text = lsp:loadText(uri) - if not text then + local ast, lines = lsp:loadText(uri) + if not ast then return nil, '找不到文件:' .. uri end local start_clock = os.clock() - local ast, err = parser:ast(text) - local lines = parser:lines(text) - if not ast then - return nil, err - end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) local suc, start, finish = matcher.definition(ast, position, 'utf8') |