diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 20:16:39 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-02-09 20:16:39 +0800 |
commit | 3932717d816bfc4f98cd9640daca51fb6f2afe8c (patch) | |
tree | 934e153b2a5b1427de71e4dc87074bc6b7ae9b71 /script | |
parent | 2a439122a6d6d841fb99f08a1276c4400e5360fa (diff) | |
download | lua-language-server-3932717d816bfc4f98cd9640daca51fb6f2afe8c.zip |
cleanup
merge `doc.type.enums` and `doc.type.resumes` into `doc.type.types`
Diffstat (limited to 'script')
-rw-r--r-- | script/core/generic.lua | 2 | ||||
-rw-r--r-- | script/core/hover/description.lua | 11 | ||||
-rw-r--r-- | script/core/infer.lua | 3 | ||||
-rw-r--r-- | script/core/noder.lua | 10 | ||||
-rw-r--r-- | script/parser/guide.lua | 4 | ||||
-rw-r--r-- | script/parser/luadoc.lua | 8 |
6 files changed, 13 insertions, 25 deletions
diff --git a/script/core/generic.lua b/script/core/generic.lua index b383ee5d..2eb454ff 100644 --- a/script/core/generic.lua +++ b/script/core/generic.lua @@ -52,8 +52,6 @@ local function createValue(closure, proto, callback, road) end local value = instantValue(closure, proto) value.types = types - value.enums = proto.enums - value.resumes = proto.resumes noder.compileNode(noder.getNoders(proto), value) return value end diff --git a/script/core/hover/description.lua b/script/core/hover/description.lua index 8733fa25..43d15c39 100644 --- a/script/core/hover/description.lua +++ b/script/core/hover/description.lua @@ -160,7 +160,10 @@ local function buildEnumChunk(docType, name) end local types = {} for _, tp in ipairs(docType.types) do - types[#types+1] = tp[1] + if tp.type ~= 'doc.enum' + and tp.type ~= 'doc.resume' then + types[#types+1] = tp[1] + end end local lines = {} for _, typeUnit in ipairs(docType.types) do @@ -171,12 +174,12 @@ local function buildEnumChunk(docType, name) end end end - lines[#lines+1] = ('%s: %s'):format(name, table.concat(types)) + lines[#lines+1] = ('%s: %s'):format(name, table.concat(types, '|')) for _, enum in ipairs(enums) do local enumDes = (' %s %s'):format( (enum.default and '->') - or (enum.additional and '+>') - or ' |', + or (enum.additional and '+>') + or ' |', enum[1] ) if enum.comment then diff --git a/script/core/infer.lua b/script/core/infer.lua index 982b8ef3..3c62712e 100644 --- a/script/core/infer.lua +++ b/script/core/infer.lua @@ -337,9 +337,6 @@ function m.viewDocName(doc) for _, tp in ipairs(doc.types) do list[#list+1] = m.getDocName(tp) end - for _, enum in ipairs(doc.enums) do - list[#list+1] = m.getDocName(enum) - end return table.concat(list, '|') end return m.getDocName(doc) diff --git a/script/core/noder.lua b/script/core/noder.lua index 4ecfb032..0a04a744 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -174,7 +174,7 @@ local function getFieldEventName(field) if not firstType then return nil end - local firstEnum = #firstType.enums == 1 and #firstType.types == 0 and firstType.enums[1] + local firstEnum = firstType.types[1] if not firstEnum then return nil end @@ -182,7 +182,7 @@ local function getFieldEventName(field) if not secondType then return nil end - local secondTypeUnit = #secondType.enums == 0 and #secondType.types == 1 and secondType.types[1] + local secondTypeUnit = secondType.types[1] if not secondTypeUnit or secondTypeUnit.type ~= 'doc.type.function' then return nil end @@ -1026,12 +1026,6 @@ compileNodeMap = util.switch() end end end - for _, enumUnit in ipairs(source.enums) do - pushForward(noders, id, getID(enumUnit)) - end - for _, resumeUnit in ipairs(source.resumes) do - pushForward(noders, id, getID(resumeUnit)) - end for _, typeUnit in ipairs(source.types) do local unitID = getID(typeUnit) pushForward(noders, id, unitID) diff --git a/script/parser/guide.lua b/script/parser/guide.lua index e306f1e1..6f09d119 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -27,8 +27,6 @@ local type = type ---@field index parser.guide.object ---@field extends parser.guide.object[] ---@field types parser.guide.object[] ----@field enums parser.guide.object[] ----@field resumes parser.guide.object[] ---@field fields parser.guide.object[] ---@field typeGeneric table<integer, parser.guide.object[]> ---@field tkey parser.guide.object @@ -128,7 +126,7 @@ local childMap = { ['doc'] = {'#'}, ['doc.class'] = {'class', '#extends', 'comment'}, - ['doc.type'] = {'#types', '#enums', '#resumes', 'name', 'comment'}, + ['doc.type'] = {'#types', 'name', 'comment'}, ['doc.alias'] = {'alias', 'extends', 'comment'}, ['doc.param'] = {'param', 'extends', 'comment'}, ['doc.return'] = {'#returns', 'comment'}, diff --git a/script/parser/luadoc.lua b/script/parser/luadoc.lua index 576cdb5c..a47ebe34 100644 --- a/script/parser/luadoc.lua +++ b/script/parser/luadoc.lua @@ -570,8 +570,6 @@ function parseType(parent) type = 'doc.type', parent = parent, types = {}, - enums = {}, - resumes = {}, } while true do local tp, content = peekToken() @@ -617,7 +615,7 @@ function parseType(parent) parent = result, [1] = content, } - result.enums[#result.enums+1] = typeEnum + result.types[#result.types+1] = typeEnum if not result.start then result.start = typeEnum.start end @@ -685,7 +683,7 @@ function parseType(parent) else resume.comment = nextComm.text:match('#%s*(.+)', 3) end - result.resumes[#result.resumes+1] = resume + result.types[#result.types+1] = resume result.finish = resume.finish end comments = nil @@ -717,7 +715,7 @@ function parseType(parent) while pushResume() do end end - if #result.types == 0 and #result.enums == 0 and #result.resumes == 0 then + if #result.types == 0 then pushWarning { type = 'LUADOC_MISS_TYPE_NAME', start = getFinish(), |