diff options
-rw-r--r-- | server/src/core/document_symbol.lua | 4 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 25 |
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 |