Skip to content

Commit 3932717

Browse files
committed
cleanup
merge `doc.type.enums` and `doc.type.resumes` into `doc.type.types`
1 parent 2a43912 commit 3932717

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

script/core/generic.lua

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ local function createValue(closure, proto, callback, road)
5252
end
5353
local value = instantValue(closure, proto)
5454
value.types = types
55-
value.enums = proto.enums
56-
value.resumes = proto.resumes
5755
noder.compileNode(noder.getNoders(proto), value)
5856
return value
5957
end

script/core/hover/description.lua

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,10 @@ local function buildEnumChunk(docType, name)
160160
end
161161
local types = {}
162162
for _, tp in ipairs(docType.types) do
163-
types[#types+1] = tp[1]
163+
if tp.type ~= 'doc.enum'
164+
and tp.type ~= 'doc.resume' then
165+
types[#types+1] = tp[1]
166+
end
164167
end
165168
local lines = {}
166169
for _, typeUnit in ipairs(docType.types) do
@@ -171,12 +174,12 @@ local function buildEnumChunk(docType, name)
171174
end
172175
end
173176
end
174-
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types))
177+
lines[#lines+1] = ('%s: %s'):format(name, table.concat(types, '|'))
175178
for _, enum in ipairs(enums) do
176179
local enumDes = (' %s %s'):format(
177180
(enum.default and '->')
178-
or (enum.additional and '+>')
179-
or ' |',
181+
or (enum.additional and '+>')
182+
or ' |',
180183
enum[1]
181184
)
182185
if enum.comment then

script/core/infer.lua

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -337,9 +337,6 @@ function m.viewDocName(doc)
337337
for _, tp in ipairs(doc.types) do
338338
list[#list+1] = m.getDocName(tp)
339339
end
340-
for _, enum in ipairs(doc.enums) do
341-
list[#list+1] = m.getDocName(enum)
342-
end
343340
return table.concat(list, '|')
344341
end
345342
return m.getDocName(doc)

script/core/noder.lua

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ local function getFieldEventName(field)
174174
if not firstType then
175175
return nil
176176
end
177-
local firstEnum = #firstType.enums == 1 and #firstType.types == 0 and firstType.enums[1]
177+
local firstEnum = firstType.types[1]
178178
if not firstEnum then
179179
return nil
180180
end
181181
local secondType = secondArg.extends
182182
if not secondType then
183183
return nil
184184
end
185-
local secondTypeUnit = #secondType.enums == 0 and #secondType.types == 1 and secondType.types[1]
185+
local secondTypeUnit = secondType.types[1]
186186
if not secondTypeUnit or secondTypeUnit.type ~= 'doc.type.function' then
187187
return nil
188188
end
@@ -1026,12 +1026,6 @@ compileNodeMap = util.switch()
10261026
end
10271027
end
10281028
end
1029-
for _, enumUnit in ipairs(source.enums) do
1030-
pushForward(noders, id, getID(enumUnit))
1031-
end
1032-
for _, resumeUnit in ipairs(source.resumes) do
1033-
pushForward(noders, id, getID(resumeUnit))
1034-
end
10351029
for _, typeUnit in ipairs(source.types) do
10361030
local unitID = getID(typeUnit)
10371031
pushForward(noders, id, unitID)

script/parser/guide.lua

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ local type = type
2727
---@field index parser.guide.object
2828
---@field extends parser.guide.object[]
2929
---@field types parser.guide.object[]
30-
---@field enums parser.guide.object[]
31-
---@field resumes parser.guide.object[]
3230
---@field fields parser.guide.object[]
3331
---@field typeGeneric table<integer, parser.guide.object[]>
3432
---@field tkey parser.guide.object
@@ -128,7 +126,7 @@ local childMap = {
128126

129127
['doc'] = {'#'},
130128
['doc.class'] = {'class', '#extends', 'comment'},
131-
['doc.type'] = {'#types', '#enums', '#resumes', 'name', 'comment'},
129+
['doc.type'] = {'#types', 'name', 'comment'},
132130
['doc.alias'] = {'alias', 'extends', 'comment'},
133131
['doc.param'] = {'param', 'extends', 'comment'},
134132
['doc.return'] = {'#returns', 'comment'},

script/parser/luadoc.lua

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -570,8 +570,6 @@ function parseType(parent)
570570
type = 'doc.type',
571571
parent = parent,
572572
types = {},
573-
enums = {},
574-
resumes = {},
575573
}
576574
while true do
577575
local tp, content = peekToken()
@@ -617,7 +615,7 @@ function parseType(parent)
617615
parent = result,
618616
[1] = content,
619617
}
620-
result.enums[#result.enums+1] = typeEnum
618+
result.types[#result.types+1] = typeEnum
621619
if not result.start then
622620
result.start = typeEnum.start
623621
end
@@ -685,7 +683,7 @@ function parseType(parent)
685683
else
686684
resume.comment = nextComm.text:match('#%s*(.+)', 3)
687685
end
688-
result.resumes[#result.resumes+1] = resume
686+
result.types[#result.types+1] = resume
689687
result.finish = resume.finish
690688
end
691689
comments = nil
@@ -717,7 +715,7 @@ function parseType(parent)
717715
while pushResume() do end
718716
end
719717

720-
if #result.types == 0 and #result.enums == 0 and #result.resumes == 0 then
718+
if #result.types == 0 then
721719
pushWarning {
722720
type = 'LUADOC_MISS_TYPE_NAME',
723721
start = getFinish(),

0 commit comments

Comments
 (0)