diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-22 14:52:14 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-22 14:52:14 +0800 |
commit | efa8bfce8228bc615e2870cbc4394bef0ab3cb9d (patch) | |
tree | c5c89bc67473c1525de1e1d912bab8517f59e7a9 /server/src/core | |
parent | adb221773bbfffcec5e486a8e4f52e44d594508b (diff) | |
download | lua-language-server-efa8bfce8228bc615e2870cbc4394bef0ab3cb9d.zip |
全局值跳转等待编译完成(转到定义超时1秒,查找引用超时5秒)
Diffstat (limited to 'server/src/core')
-rw-r--r-- | server/src/core/definition.lua | 56 | ||||
-rw-r--r-- | server/src/core/references.lua | 11 |
2 files changed, 28 insertions, 39 deletions
diff --git a/server/src/core/definition.lua b/server/src/core/definition.lua index 335d2185..a704cb57 100644 --- a/server/src/core/definition.lua +++ b/server/src/core/definition.lua @@ -19,54 +19,38 @@ local function parseValueSimily(callback, vm, source, lsp) end) end -local function parseValueCrossFile(callback, vm, source, lsp) - local value = source:bindValue() - value:eachInfo(function (info, src) - if src.uri == value.uri then - if info.type == 'local' or info.type == 'set' or info.type == 'return' then - callback(src) - end - end - end) - return nil -end - local function parseLocal(callback, vm, source, lsp) - local positions = {} local loc = source:bindLocal() local locSource = loc:getSource() - --if locSource:get 'arg' then - -- callback(locSource) - --end - local value = source:bindValue() - if value and value.uri ~= '' and value.uri ~= vm.uri then - parseValueCrossFile(callback, vm, source, lsp) - end callback(locSource) - if #positions == 0 then - return nil - end - return positions end local function parseValue(callback, vm, source, lsp) - if source:bindValue() then - source:bindValue():eachInfo(function (info, src) + local value = source:bindValue() + local isGlobal + if value then + isGlobal = value:isGlobal() + value:eachInfo(function (info, src) if info.type == 'set' or info.type == 'local' or info.type == 'return' then - callback(src) + if vm.uri == src:getUri() then + if source.id > src.id then + callback(src) + end + elseif value.uri == src:getUri() then + callback(src) + end end end) end local parent = source:get 'parent' if parent then parent:eachInfo(function (info, src) - if info[1] == source[1] then - if info.type == 'set child' then - callback(src) - end + if info.type == 'set child' and info[1] == source[1] then + callback(src) end end) end + return isGlobal end local function parseLabel(callback, vm, label, lsp) @@ -122,10 +106,12 @@ return function (vm, source, lsp) return nil end local list, callback = makeList(source) + local isGlobal if source:bindLocal() then parseLocal(callback, vm, source, lsp) - elseif source:bindValue() then - parseValue(callback, vm, source, lsp) + end + if source:bindValue() then + isGlobal = parseValue(callback, vm, source, lsp) --parseValueSimily(callback, vm, source, lsp) end if source:bindLabel() then @@ -135,11 +121,11 @@ return function (vm, source, lsp) jumpUri(callback, vm, source, lsp) end if source:get 'in index' then - parseValue(callback, vm, source, lsp) + isGlobal = parseValue(callback, vm, source, lsp) --parseValueSimily(callback, vm, source, lsp) end if source:get 'target class' then parseClass(callback, vm, source) end - return list + return list, isGlobal end diff --git a/server/src/core/references.lua b/server/src/core/references.lua index 10d8b2df..d07e48c7 100644 --- a/server/src/core/references.lua +++ b/server/src/core/references.lua @@ -1,13 +1,13 @@ local findSource = require 'core.find_source' local function parseResult(vm, source, declarat, callback) + local isGlobal if source:bindLabel() then source:bindLabel():eachInfo(function (info, src) if (declarat and info.type == 'set') or info.type == 'get' then callback(src) end end) - return end if source:bindLocal() then local loc = source:bindLocal() @@ -22,7 +22,6 @@ local function parseResult(vm, source, declarat, callback) callback(src) end end) - return end if source:bindFunction() then if declarat then @@ -40,6 +39,9 @@ local function parseResult(vm, source, declarat, callback) callback(src) end end) + if source:bindValue():isGlobal() then + isGlobal = true + end end local parent = source:get 'parent' if parent then @@ -51,6 +53,7 @@ local function parseResult(vm, source, declarat, callback) end end) end + return isGlobal end return function (vm, pos, declarat) @@ -60,7 +63,7 @@ return function (vm, pos, declarat) end local positions = {} local mark = {} - parseResult(vm, source, declarat, function (src) + local isGlobal = parseResult(vm, source, declarat, function (src) if mark[src] then return end @@ -78,5 +81,5 @@ return function (vm, pos, declarat) uri, } end) - return positions + return positions, isGlobal end |