diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2018-12-11 16:27:03 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2018-12-11 16:27:03 +0800 |
commit | 5b6a3da07d96345073a275e5e298d83ab3b5ead9 (patch) | |
tree | db995ed3369a250b458e1b2cd9c7bb0fd4c3752d /server/src | |
parent | c89e12dc4282c942ea91edbdb7bcab0657fb1ad6 (diff) | |
download | lua-language-server-5b6a3da07d96345073a275e5e298d83ab3b5ead9.zip |
转到定义可以用了
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/matcher/vm.lua | 2 | ||||
-rw-r--r-- | server/src/method/textDocument/hover.lua | 6 | ||||
-rw-r--r-- | server/src/method/textDocument/implementation.lua | 6 | ||||
-rw-r--r-- | server/src/method/textDocument/publishDiagnostics.lua | 10 | ||||
-rw-r--r-- | server/src/method/textDocument/references.lua | 6 | ||||
-rw-r--r-- | server/src/method/textDocument/rename.lua | 6 | ||||
-rw-r--r-- | server/src/service.lua | 19 |
7 files changed, 28 insertions, 27 deletions
diff --git a/server/src/matcher/vm.lua b/server/src/matcher/vm.lua index 7f99d087..2ee23488 100644 --- a/server/src/matcher/vm.lua +++ b/server/src/matcher/vm.lua @@ -440,7 +440,7 @@ function mt:getSimple(simple, mode) -- 函数的返回值一定是list value = self:call(value, args) if i < #simple then - value = value[1] + value = value[1] or self:createNil() end elseif obj.index then local index = self:getIndex(obj) diff --git a/server/src/method/textDocument/hover.lua b/server/src/method/textDocument/hover.lua index 29f7304a..3233b34a 100644 --- a/server/src/method/textDocument/hover.lua +++ b/server/src/method/textDocument/hover.lua @@ -2,13 +2,13 @@ local matcher = require 'matcher' return function (lsp, params) local uri = params.textDocument.uri - local results, lines = lsp:loadText(uri) - if not results then + local vm, lines = lsp:loadText(uri) + if not vm then return nil end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) - local text = matcher.hover(results, position) + local text = matcher.hover(vm.results, position) if not text then return nil end diff --git a/server/src/method/textDocument/implementation.lua b/server/src/method/textDocument/implementation.lua index 07d48870..4d77882d 100644 --- a/server/src/method/textDocument/implementation.lua +++ b/server/src/method/textDocument/implementation.lua @@ -2,13 +2,13 @@ local matcher = require 'matcher' return function (lsp, params) local uri = params.textDocument.uri - local results, lines = lsp:loadText(uri) - if not results then + local vm, lines = lsp:loadText(uri) + if not vm then return {} end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) - local positions = matcher.implementation(results, position) + local positions = matcher.implementation(vm.results, position) if not positions then return {} end diff --git a/server/src/method/textDocument/publishDiagnostics.lua b/server/src/method/textDocument/publishDiagnostics.lua index b0b36cb9..aa4a8340 100644 --- a/server/src/method/textDocument/publishDiagnostics.lua +++ b/server/src/method/textDocument/publishDiagnostics.lua @@ -76,12 +76,12 @@ local function createInfo(data, lines) end return function (lsp, params) - local results = params.results - local ast = params.ast - local lines = params.lines - local uri = params.uri + local vm = params.vm + local ast = params.ast + local lines = params.lines + local uri = params.uri - local datas = matcher.diagnostics(ast, results, lines, uri) + local datas = matcher.diagnostics(ast, vm.results, lines, uri) if not datas then -- 返回空表以清空之前的结果 diff --git a/server/src/method/textDocument/references.lua b/server/src/method/textDocument/references.lua index a4d8e6ab..22552fbd 100644 --- a/server/src/method/textDocument/references.lua +++ b/server/src/method/textDocument/references.lua @@ -3,13 +3,13 @@ local matcher = require 'matcher' return function (lsp, params) local uri = params.textDocument.uri local declarat = params.context.includeDeclaration - local results, lines = lsp:loadText(uri) - if not results then + local vm, lines = lsp:loadText(uri) + if not vm then return {} end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) - local positions = matcher.references(results, position, declarat) + local positions = matcher.references(vm.results, position, declarat) if not positions then return {} end diff --git a/server/src/method/textDocument/rename.lua b/server/src/method/textDocument/rename.lua index 6dd0d5ae..f9b16237 100644 --- a/server/src/method/textDocument/rename.lua +++ b/server/src/method/textDocument/rename.lua @@ -3,13 +3,13 @@ local matcher = require 'matcher' return function (lsp, params) local uri = params.textDocument.uri local newName = params.newName - local results, lines = lsp:loadText(uri) - if not results then + local vm, lines = lsp:loadText(uri) + if not vm then return {} end -- lua是从1开始的,因此都要+1 local position = lines:position(params.position.line + 1, params.position.character + 1) - local positions = matcher.rename(results, position, newName) + local positions = matcher.rename(vm.results, position, newName) if not positions then return {} end diff --git a/server/src/service.lua b/server/src/service.lua index 6e753b39..1513126b 100644 --- a/server/src/service.lua +++ b/server/src/service.lua @@ -186,7 +186,7 @@ function mt:loadText(uri) return nil end self:compileText(uri) - return obj.results, obj.lines + return obj.vm, obj.lines end function mt:compileText(uri) @@ -198,18 +198,19 @@ function mt:compileText(uri) return nil end self._needCompile[uri] = nil - local ast = parser:ast(obj.text) + local ast = parser:ast(obj.text) + obj.vm = matcher.vm(ast) - if not obj.vm then + obj.lines = parser:lines(obj.text, 'utf8') + if obj.vm then return obj end - obj.lines = parser:lines(obj.text, 'utf8') self._needDiagnostics[uri] = { - ast = ast, - vm = obj.vm, - lines = obj.lines, - uri = uri, + ast = ast, + vm = obj.vm, + lines = obj.lines, + uri = uri, } return obj @@ -226,7 +227,7 @@ function mt:on_tick() self:_doProto(proto) end self:_buildTextCache() - self:_doDiagnostic() + --self:_doDiagnostic() end function mt:listen() |