Skip to content

Commit 8b442ab

Browse files
committed
如果有 merge 属性,则跳过 duplicate-doc-alias 检查
1 parent 1b3a03e commit 8b442ab

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

script/core/diagnostics/duplicate-doc-alias.lua

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ return function (uri, callback)
1515
return
1616
end
1717

18+
local merged = {}
1819
local cache = {}
1920
for _, doc in ipairs(state.ast.docs) do
2021
if doc.type == 'doc.alias'
@@ -36,10 +37,11 @@ return function (uri, callback)
3637
finish = otherDoc.finish,
3738
uri = guide.getUri(otherDoc),
3839
}
40+
merged[name] = merged[name] or vm.docHasAttr(otherDoc, 'merge')
3941
end
4042
end
4143
end
42-
if #cache[name] > 1 then
44+
if not merged[name] and #cache[name] > 1 then
4345
callback {
4446
start = (doc.alias or doc.enum).start,
4547
finish = (doc.alias or doc.enum).finish,

script/parser/luadoc.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1026,6 +1026,7 @@ local docSwitch = util.switch()
10261026
local result = {
10271027
type = 'doc.alias',
10281028
}
1029+
result.docAttr = parseDocAttr()
10291030
result.alias = parseName('doc.alias.name', result)
10301031
if not result.alias then
10311032
pushWarning {

test/diagnostics/duplicate-doc-alias.lua

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,14 @@ TEST [[
88
---@class B
99
---@alias <!A!> B
1010
]]
11+
12+
TEST [[
13+
---@alias A integer
14+
---@alias(merge) A integer
15+
16+
---@enum B
17+
---@enum(merge) B
18+
19+
---@enum(key) C
20+
---@enum(key, merge) C
21+
]]

0 commit comments

Comments
 (0)