Skip to content

Commit b17800e

Browse files
committed
NFC: Add comment for swift-testing display name logic
1 parent 1f854dd commit b17800e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Sources/SourceKitLSP/Swift/SwiftTestingScanner.swift

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,20 @@ final class SyntacticSwiftTestingTestScanner: SyntaxVisitor {
345345

346346
let (hasBackticks, baseName) = backtickIfNeeded(identifier)
347347
let fullName = "\(baseName)(\(parameters))"
348+
349+
// If we have a display name provided by the attribute, use it, otherwise
350+
// we can infer the display name from a raw identifier if we have one.
351+
//
352+
// A raw identifier is considered an alternative way of spelling the display
353+
// name, so e.g these have the same display name:
354+
//
355+
// ```
356+
// @Test("foo bar") func foo() {}
357+
// @Test func `foo bar`() {}
358+
// ```
359+
//
360+
// as such it shouldn't include any parameters. If we just have a regular
361+
// name then we use the full name as the display name.
348362
let displayName = attributeData.displayName ?? (hasBackticks ? identifier.name : fullName)
349363

350364
let range = snapshot.absolutePositionRange(

0 commit comments

Comments
 (0)