diff options
Diffstat (limited to 'script')
-rw-r--r-- | script/core/linker.lua | 54 | ||||
-rw-r--r-- | script/core/searcher.lua | 27 |
2 files changed, 57 insertions, 24 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 diff --git a/script/core/searcher.lua b/script/core/searcher.lua index a29407e7..29509d18 100644 --- a/script/core/searcher.lua +++ b/script/core/searcher.lua @@ -22,7 +22,9 @@ function m.pushResult(status, mode, ref) or ref.type == 'setindex' or ref.type == 'tableindex' or ref.type == 'tablefield' - or ref.type == 'function' then + or ref.type == 'function' + or ref.type == 'doc.class.name' + or ref.type == 'doc.alias.name' then results[#results+1] = ref end elseif mode == 'ref' then @@ -41,7 +43,11 @@ function m.pushResult(status, mode, ref) or ref.type == 'getindex' or ref.type == 'tableindex' or ref.type == 'tablefield' - or ref.type == 'function' then + or ref.type == 'function' + or ref.type == 'doc.class.name' + or ref.type == 'doc.type.name' + or ref.type == 'doc.alias.name' + or ref.type == 'doc.extends.name' then results[#results+1] = ref end elseif mode == 'field' then @@ -101,11 +107,11 @@ function m.searchRefsByID(status, uri, expect, mode) return end local id = link.id - checkLastID(id, field) + search(id, field) if field then id = id .. field + search(id) end - search(id) end local function getReturnSetByFunc(func, index) @@ -152,12 +158,8 @@ function m.searchRefsByID(status, uri, expect, mode) m.searchRefs(newStatus, func, 'ref') for _, ref in ipairs(newStatus.results) do local set = getReturnSetByFunc(ref, link.freturn) - if set then - local id = linker.getID(set) - if id then - search(id) - end - end + local setID = linker.getID(set) + search(setID) end end @@ -182,6 +184,9 @@ function m.searchRefsByID(status, uri, expect, mode) local stackCount = 0 local mark = {} search = function (id, field) + if not id then + return + end if mark[id] then return end @@ -201,11 +206,11 @@ function m.searchRefsByID(status, uri, expect, mode) checkForward(eachLink, field) checkBackward(eachLink, field) end + checkLastID(id, field) stackCount = stackCount - 1 end search(expect) - checkLastID(expect) searchFunction(expect) end |