diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-03 19:19:08 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-03 19:19:08 +0800 |
commit | 14b4c403e3b423f5ee7f46438f3edea25f45ce2b (patch) | |
tree | 827e62cd550a8cc51b1f163b2ff78bdd1e1535a4 | |
parent | 2b2d9270b278d6f8b9eea5f20e3246355b91d711 (diff) | |
download | lua-language-server-14b4c403e3b423f5ee7f46438f3edea25f45ce2b.zip |
修正一些BUG
-rw-r--r-- | .vscode/settings.json | 6 | ||||
-rw-r--r-- | server/src/lsp.lua | 12 | ||||
-rw-r--r-- | server/src/matcher/compile.lua | 3 | ||||
-rw-r--r-- | server/src/method/textDocument/definition.lua | 2 |
4 files changed, 11 insertions, 12 deletions
diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 4a9bab7c..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "editor.insertSpaces": false, - "tslint.enable": true, - "typescript.tsc.autoDetect": "off", - "typescript.preferences.quoteStyle": "single" -}
\ No newline at end of file diff --git a/server/src/lsp.lua b/server/src/lsp.lua index 0aaa6896..e4bbb5f4 100644 --- a/server/src/lsp.lua +++ b/server/src/lsp.lua @@ -1,5 +1,6 @@ -local json = require 'json' -local parser = require 'parser' +local json = require 'json' +local parser = require 'parser' +local matcher = require 'matcher' local ErrorCodes = { -- Defined by JSON RPC @@ -168,7 +169,7 @@ function mt:loadText(uri) return nil end self:compileText(uri) - return obj.ast, obj.lines + return obj.results, obj.lines end function mt:compileText(uri) @@ -180,8 +181,9 @@ function mt:compileText(uri) return nil end self._need_compile[uri] = nil - obj.ast = parser:ast(obj.text) - obj.lines = parser:lines(obj.text) + local ast = parser:ast(obj.text) + obj.results = matcher.compile(ast) + obj.lines = parser:lines(obj.text) return obj end diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua index b28c3282..4776623b 100644 --- a/server/src/matcher/compile.lua +++ b/server/src/matcher/compile.lua @@ -491,6 +491,9 @@ function mt:searchActions(actions) end return function (ast) + if not ast then + return nil + end local searcher = setmetatable({ env = env { var = {}, diff --git a/server/src/method/textDocument/definition.lua b/server/src/method/textDocument/definition.lua index bcdd6cac..60130935 100644 --- a/server/src/method/textDocument/definition.lua +++ b/server/src/method/textDocument/definition.lua @@ -5,7 +5,7 @@ return function (lsp, params) local start_clock = os.clock() local uri = params.textDocument.uri local results, lines = lsp:loadText(uri) - if not ast then + if not results then return {} end -- lua是从1开始的,因此都要+1 |