diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2021-04-20 20:19:07 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2021-04-20 20:19:07 +0800 |
commit | 55ffa7c435d92d9b903c658afea1d085161197fa (patch) | |
tree | c4e924cdda8cd8f828b85353989095f5c8e167eb /script/core/linker.lua | |
parent | 257b21bfcfbeada4c18332a258b7ce4580482e6d (diff) | |
download | lua-language-server-55ffa7c435d92d9b903c658afea1d085161197fa.zip |
update
Diffstat (limited to 'script/core/linker.lua')
-rw-r--r-- | script/core/linker.lua | 54 |
1 files changed, 41 insertions, 13 deletions
diff --git a/script/core/linker.lua b/script/core/linker.lua index 20bf6b34..c31a8fd1 100644 --- a/script/core/linker.lua +++ b/script/core/linker.lua @@ -98,14 +98,11 @@ local function checkMode(source) if source.type == 'function' then return 'f' end - if source.type == 'doc.class.name' then - return 'dc' - end - if source.type == 'doc.type.name' then - return 'dt' - end - if source.type == 'doc.alias.name' then - return 'da' + if source.type == 'doc.class.name' + or source.type == 'doc.type.name' + or source.type == 'doc.alias.name' + or source.type == 'doc.extends.name' then + return 'd' end if isGlobal(source) then return 'g' @@ -140,11 +137,6 @@ local function checkForward(source) if source.value then -- x = y : x -> y list[#list+1] = source.value - elseif source.type == 'table' then - -- x = {y = 1} : x -> x.y - for _, keyvalue in ipairs(source) do - list[#list+1] = keyvalue - end end -- mt:f -> self if parent.type == 'setmethod' @@ -157,6 +149,21 @@ local function checkForward(source) end end end + -- source 绑定的 @class/@type + local bindDocs = source.bindDocs + if bindDocs then + for _, doc in ipairs(bindDocs) do + if doc.type == 'doc.class' then + list[#list+1] = doc.class + elseif doc.type == 'doc.type' then + if doc.types then + for _, typeUnit in ipairs(doc.types) do + list[#list+1] = typeUnit + end + end + end + end + end if #list == 0 then return nil else @@ -182,6 +189,24 @@ local function checkBackward(source) list[#list+1] = setmethod.node end end + if parent.parent and parent.parent.type == 'doc' then + -- @class 绑定的 source + if source.type == 'doc.class.name' then + if parent.type == 'doc.class' then + for _, src in ipairs(parent.bindSources) do + list[#list+1] = src + end + end + end + -- @type 绑定的 source + if source.type == 'doc.type.name' then + if parent.type == 'doc.type' and parent.parent.type == 'doc' then + for _, src in ipairs(parent.bindSources) do + list[#list+1] = src + end + end + end + end if #list == 0 then return nil else @@ -335,6 +360,9 @@ end ---获取source的ID function m.getID(source) + if not source then + return nil + end local link = m.getLink(source) if not link then return nil |