Skip to content

Commit 1548bf0

Browse files
committed
Exclude expected completions for underscored attributes
Don't check completions for e.g `@_spi` or its arguments.
1 parent 939af6a commit 1548bf0

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

SourceKitStressTester/Sources/StressTester/ActionGenerators.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,15 @@ private struct ActionToken {
503503
return nil
504504
}
505505
}
506+
507+
// Avoid matching for underscored attributes since we hide completions for
508+
// those.
509+
if let attr = parent.ancestorOrSelf(mapping: { $0.as(AttributeSyntax.self) }),
510+
let ident = attr.attributeName.as(IdentifierTypeSyntax.self),
511+
ident.name.text.hasPrefix("_") {
512+
return nil
513+
}
514+
506515
if let parent = parent.as(DeclReferenceExprSyntax.self), parent.baseName == token {
507516
if let refArgs = parent.argumentNames {
508517
let name = SwiftName(base: token.text, labels: refArgs.arguments.map{ $0.name.text })

SourceKitStressTester/Tests/StressTesterToolTests/ActionGeneratorTests.swift

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,11 @@ class ActionGeneratorTests: XCTestCase {
9797

9898
// FIXME: completion doesn't suggest anonymous closure params (e.g. $0)
9999
(#line, "$0.first", [/*"$0",*/ "first"]),
100-
(#line, "[1,2,4].filter{ $0 == 4 }", ["call:filter"/*, "$0"*/])
100+
(#line, "[1,2,4].filter{ $0 == 4 }", ["call:filter"/*, "$0"*/]),
101+
102+
// We don't include completions for underscored attributes.
103+
(#line, "@_underscored(a: Foo)", []),
104+
(#line, "@_spi(Foo)", []),
101105
]
102106

103107
for test in cases {

0 commit comments

Comments
 (0)