From 02307701cf666dd884b497654b94b0f71f1f812e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Sat, 31 Oct 2020 17:02:25 +0800 Subject: =?UTF-8?q?=E6=94=AF=E6=8C=81=20doc.field?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/parser/guide.lua | 49 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 39 insertions(+), 10 deletions(-) (limited to 'script-beta/parser/guide.lua') diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index 7974f325..77d43e55 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -698,6 +698,8 @@ function m.getName(obj) return obj.class[1] elseif tp == 'doc.alias' then return obj.alias[1] + elseif tp == 'doc.field' then + return obj.field[1] end return m.getNameOfLiteral(obj) end @@ -765,6 +767,12 @@ function m.getKeyName(obj) elseif tp == 'field' or tp == 'method' then return 's|' .. obj[1] + elseif tp == 'doc.class' then + return 's|' .. obj.class[1] + elseif tp == 'doc.alias' then + return 's|' .. obj.alias[1] + elseif tp == 'doc.field' then + return 's|' .. obj.field[1] end return m.getKeyNameOfLiteral(obj) end @@ -1313,8 +1321,10 @@ function m.searchFields(status, obj, key, interface, deep) return results elseif obj.type == 'library' then local results = {} - for i = 1, #obj.fields do - results[i] = obj.fields[i] + if obj.fields then + for i = 1, #obj.fields do + results[i] = obj.fields[i] + end end return results else @@ -1464,6 +1474,8 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode) end elseif doc.type == 'doc.overload' then results[#results+1] = doc.overload + elseif doc.type == 'doc.field' then + results[#results+1] = doc end end local mark = {} @@ -1481,11 +1493,18 @@ function m.checkSameSimpleByBindDocs(status, obj, start, queue, mode) end end end - queue[#queue+1] = { - obj = res, - start = start, - force = true, - } + if res.type == 'doc.type.function' then + queue[#queue+1] = { + obj = res, + start = start, + force = true, + } + elseif res.type == 'doc.field' then + queue[#queue+1] = { + obj = res, + start = start + 1, + } + end end for _, res in ipairs(newStatus.results) do queue[#queue+1] = { @@ -1877,7 +1896,8 @@ function m.pushResult(status, mode, ref, simple) results[#results+1] = ref elseif ref.type == 'library' then results[#results+1] = ref - elseif ref.type == 'doc.type.function' then + elseif ref.type == 'doc.type.function' + or ref.type == 'doc.field' then results[#results+1] = ref end if ref.parent and ref.parent.type == 'return' then @@ -1914,7 +1934,8 @@ function m.pushResult(status, mode, ref, simple) end elseif ref.type == 'library' then results[#results+1] = ref - elseif ref.type == 'doc.type.function' then + elseif ref.type == 'doc.type.function' + or ref.type == 'doc.field' then results[#results+1] = ref end if ref.parent and ref.parent.type == 'return' then @@ -1946,7 +1967,8 @@ function m.pushResult(status, mode, ref, simple) end elseif ref.type == 'library' then results[#results+1] = ref - elseif ref.type == 'doc.type.function' then + elseif ref.type == 'doc.type.function' + or ref.type == 'doc.field' then results[#results+1] = ref end end @@ -2614,6 +2636,13 @@ function m.inferCheckDoc(status, source) end return true end + if source.type == 'doc.field' then + local results = m.getDocTypeNames(source.extends) + for _, res in ipairs(results) do + status.results[#status.results+1] = res + end + return true + end end function m.getVarargDocType(source) -- cgit v1.2.3