summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2019-03-13 18:19:21 +0800
committer最萌小汐 <sumneko@hotmail.com>2019-03-13 18:19:21 +0800
commit9ae9210c5250d3f53a358fd04ac5a947ac244963 (patch)
treea25fd4c2ed7f6a0bce8ad81bc19b90689cbfc785
parent68265491e70460966276752586a3e58c0781b0c8 (diff)
downloadlua-language-server-9ae9210c5250d3f53a358fd04ac5a947ac244963.zip
修正一些bug
-rw-r--r--server/src/core/document_symbol.lua4
-rw-r--r--server/src/vm/vm.lua25
2 files changed, 16 insertions, 13 deletions
diff --git a/server/src/core/document_symbol.lua b/server/src/core/document_symbol.lua
index 7411b079..e22fd4db 100644
--- a/server/src/core/document_symbol.lua
+++ b/server/src/core/document_symbol.lua
@@ -65,7 +65,7 @@ local function buildLocal(vm, source, callback)
kind = SymbolKind.Variable
end
local valueSource = value:getSource()
- if valueSource.start == 0 or value.uri ~= vm.uri then
+ if not valueSource or valueSource.start == 0 or value.uri ~= vm.uri then
valueSource = source
end
local name = hvr.name
@@ -119,7 +119,7 @@ local function buildSet(vm, source, callback)
kind = SymbolKind.Property
end
local valueSource = value:getSource()
- if valueSource.start == 0 or value.uri ~= vm.uri then
+ if not valueSource or valueSource.start == 0 or value.uri ~= vm.uri then
valueSource = source
end
local name = hvr.name
diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua
index 3b6a2110..000d0284 100644
--- a/server/src/vm/vm.lua
+++ b/server/src/vm/vm.lua
@@ -185,6 +185,9 @@ function mt:tryRequireOne(strValue, mode)
if type(str) == 'string' then
-- 支持 require 'xxx' 的转到定义
local strSource = strValue:getSource()
+ if not strSource then
+ return nil
+ end
self:instantSource(strSource)
local uri
if mode == 'require' then
@@ -716,7 +719,7 @@ function mt:doReturn(action)
value.uri = self:getUri()
func:setReturn(n, value)
local source = action[n] or value:getSource()
- if source.start == 0 then
+ if not source or source.start == 0 then
source = self:getDefaultSource()
end
value:addInfo('return', source)
@@ -1077,7 +1080,7 @@ function mt:instantSource(source)
if sourceMgr.instant(source) then
source:setUri(self:getUri())
self.sources[#self.sources+1] = source
- CachedSource[source] = true
+ --CachedSource[source] = true
end
return source
end
@@ -1183,14 +1186,14 @@ return function (ast, lsp, uri)
if not suc then
return nil, res
end
- local total = 0
- local alive = 0
- for source in pairs(CachedSource) do
- if not source:isDead() then
- alive = alive + 1
- end
- total = total + 1
- end
- log.debug(('CachedSource: %d/%d'):format(alive, total))
+ --local total = 0
+ --local alive = 0
+ --for source in pairs(CachedSource) do
+ -- if not source:isDead() then
+ -- alive = alive + 1
+ -- end
+ -- total = total + 1
+ --end
+ --log.debug(('CachedSource: %d/%d'):format(alive, total))
return res
end