Skip to content

Commit 192656e

Browse files
committed
cleanup
1 parent 502b846 commit 192656e

File tree

2 files changed

+44
-30
lines changed

2 files changed

+44
-30
lines changed

script/parser/luadoc.lua

Lines changed: 34 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1629,6 +1629,14 @@ local function bindGeneric(binded)
16291629
end
16301630
end
16311631

1632+
local function bindDocWithSource(doc, source)
1633+
if not source.bindDocs then
1634+
source.bindDocs = {}
1635+
end
1636+
source.bindDocs[#source.bindDocs+1] = doc
1637+
doc.bindSource = source
1638+
end
1639+
16321640
local function bindDoc(source, binded)
16331641
local isParam = source.type == 'self'
16341642
or source.type == 'local'
@@ -1651,13 +1659,17 @@ local function bindDoc(source, binded)
16511659
or isParam then
16521660
goto CONTINUE
16531661
end
1662+
bindDocWithSource(doc, source)
1663+
ok = true
16541664
elseif doc.type == 'doc.type' then
16551665
if source.type == 'function'
16561666
or isParam
16571667
or source._bindedDocType then
16581668
goto CONTINUE
16591669
end
16601670
source._bindedDocType = true
1671+
bindDocWithSource(doc, source)
1672+
ok = true
16611673
elseif doc.type == 'doc.overload' then
16621674
if not source.bindDocs then
16631675
source.bindDocs = {}
@@ -1666,61 +1678,53 @@ local function bindDoc(source, binded)
16661678
if source.type ~= 'function' then
16671679
doc.bindSource = source
16681680
end
1681+
bindDocWithSource(doc, source)
1682+
ok = true
16691683
elseif doc.type == 'doc.param' then
1670-
local suc
16711684
if isParam
16721685
and doc.param[1] == source[1] then
1673-
suc = true
1686+
bindDocWithSource(doc, source)
1687+
ok = true
16741688
elseif source.type == '...'
16751689
and doc.param[1] == '...' then
1676-
suc = true
1690+
bindDocWithSource(doc, source)
1691+
ok = true
16771692
elseif source.type == 'self'
16781693
and doc.param[1] == 'self' then
1679-
suc = true
1680-
end
1681-
if source.type == 'function' then
1694+
bindDocWithSource(doc, source)
1695+
ok = true
1696+
elseif source.type == 'function' then
16821697
if not source.bindDocs then
16831698
source.bindDocs = {}
16841699
end
16851700
source.bindDocs[#source.bindDocs+1] = doc
16861701
end
1687-
1688-
if not suc then
1689-
goto CONTINUE
1690-
end
16911702
elseif doc.type == 'doc.vararg' then
1692-
if source.type ~= '...' then
1693-
goto CONTINUE
1703+
if source.type == '...' then
1704+
bindDocWithSource(doc, source)
1705+
ok = true
16941706
end
16951707
elseif doc.type == 'doc.return'
16961708
or doc.type == 'doc.generic'
16971709
or doc.type == 'doc.async'
16981710
or doc.type == 'doc.nodiscard' then
1699-
if source.type ~= 'function' then
1700-
goto CONTINUE
1711+
if source.type == 'function' then
1712+
bindDocWithSource(doc, source)
1713+
ok = true
17011714
end
17021715
elseif doc.type == 'doc.enum' then
17031716
if source.type == 'table' then
1704-
goto OK
1717+
bindDocWithSource(doc, source)
1718+
ok = true
17051719
end
17061720
if source.value and source.value.type == 'table' then
1707-
if not source.value.bindDocs then
1708-
source.value.bindDocs = {}
1709-
end
1710-
source.value.bindDocs[#source.value.bindDocs+1] = doc
1711-
doc.bindSource = source.value
1721+
bindDocWithSource(doc, source.value)
1722+
goto CONTINUE
17121723
end
1713-
goto CONTINUE
1714-
elseif doc.type ~= 'doc.comment' then
1715-
goto CONTINUE
1716-
end
1717-
::OK::
1718-
if not source.bindDocs then
1719-
source.bindDocs = {}
1724+
elseif doc.type == 'doc.comment' then
1725+
bindDocWithSource(doc, source)
1726+
ok = true
17201727
end
1721-
source.bindDocs[#source.bindDocs+1] = doc
1722-
doc.bindSource = source
1723-
ok = true
17241728
::CONTINUE::
17251729
end
17261730
return ok

test/hover/init.lua

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2136,3 +2136,13 @@ function test2()
21362136
2. integer
21372137
3. integer
21382138
]]
2139+
2140+
do return end
2141+
TEST [[
2142+
---@param x number
2143+
---@return boolean
2144+
local function <?f?>(
2145+
x
2146+
)
2147+
end
2148+
]]

0 commit comments

Comments
 (0)