diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-25 23:28:55 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-25 23:28:55 +0800 |
commit | 40cce47bf1f7bfd4d8945a0a189367f9dbb12f2d (patch) | |
tree | 4cd55f60d6d5925603e171b9d7b4635afe963a80 | |
parent | 438df4d04ad4bd978226868e85723b28a7765be4 (diff) | |
download | lua-language-server-40cce47bf1f7bfd4d8945a0a189367f9dbb12f2d.zip |
update
-rw-r--r-- | script/vm/def.lua | 8 | ||||
-rw-r--r-- | script/vm/ref.lua | 34 |
2 files changed, 18 insertions, 24 deletions
diff --git a/script/vm/def.lua b/script/vm/def.lua index 5a227ce4..9c4ff376 100644 --- a/script/vm/def.lua +++ b/script/vm/def.lua @@ -202,7 +202,7 @@ local function searchByNode(source, pushResult) return end for n in nodeMgr.eachNode(node) do - if n.type == 'global' and n.cate == 'type' then + if n.type == 'global' then for _, set in ipairs(n:getSets()) do pushResult(set) end @@ -228,12 +228,6 @@ function vm.getDefs(source) end if not mark[src] then mark[src] = true - if src.type == 'global' then - for _, set in ipairs(src:getSets()) do - pushResult(set) - end - return - end if guide.isSet(src) or guide.isLiteral(src) then results[#results+1] = src diff --git a/script/vm/ref.lua b/script/vm/ref.lua index 2574a098..be709950 100644 --- a/script/vm/ref.lua +++ b/script/vm/ref.lua @@ -68,9 +68,19 @@ simpleMap = util.switch() : case 'goto' : call(function (source, pushResult) if source.node then + simpleMap['label'](source.node, pushResult) pushResult(source.node) end end) + : case 'label' + : call(function (source, pushResult) + pushResult(source) + if source.ref then + for _, ref in ipairs(source.ref) do + pushResult(ref) + end + end + end) : getMap() local searchFieldMap = util.switch() @@ -106,9 +116,7 @@ local searchFieldMap = util.switch() local sources = localID.getSources(node, key) if sources then for _, src in ipairs(sources) do - if guide.isSet(src) then - pushResult(src) - end + pushResult(src) end end end) @@ -181,9 +189,7 @@ local function searchByLocalID(source, pushResult) return end for _, src in ipairs(idSources) do - if guide.isSet(src) then - pushResult(src) - end + pushResult(src) end end @@ -202,10 +208,13 @@ local function searchByNode(source, pushResult) return end for n in nodeMgr.eachNode(node) do - if n.type == 'global' and n.cate == 'type' then + if n.type == 'global' then for _, set in ipairs(n:getSets()) do pushResult(set) end + for _, get in ipairs(n:getGets()) do + pushResult(get) + end else pushResult(n) end @@ -226,16 +235,7 @@ function vm.getRefs(source) end if not mark[src] then mark[src] = true - if src.type == 'global' then - for _, set in ipairs(src:getSets()) do - pushResult(set) - end - return - end - if guide.isSet(src) - or guide.isLiteral(src) then - results[#results+1] = src - end + results[#results+1] = src end end |