Skip to content

Commit 8ae5afd

Browse files
committed
Add suggested changes.
1 parent 6c897fe commit 8ae5afd

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

Sources/SwiftLexicalLookup/LookupResult.swift

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,34 @@ import SwiftSyntax
2121
/// Indicates where to perform member lookup.
2222
case lookInMembers(LookInMembersScopeSyntax)
2323
/// Indicates to lookup generic parameters of extended type.
24+
///
25+
/// ### Example
26+
/// ```swift
27+
/// extension Foo {
28+
/// func bar() {
29+
/// let a = A() // <-- lookup here
30+
/// }
31+
/// }
32+
/// ```
33+
/// For a lookup started at the marked position, `lookInGenericParametersOfExtendedType`
34+
/// will be included as one of the results prompting the client
35+
/// to lookup the generic parameters of of the extended `Foo` type.
2436
case lookInGenericParametersOfExtendedType(ExtensionDeclSyntax)
2537
/// Indicates this closure expression could introduce dollar identifiers.
38+
///
39+
/// ### Example
40+
/// ```swift
41+
/// func foo() {
42+
/// let a = {
43+
/// $0 // <-- lookup here
44+
/// }
45+
/// }
46+
/// ```
47+
/// When looking up for any identifier at the indicated position,
48+
/// the result will include `mightIntroduceDollarIdentifiers`
49+
/// result kind. If it's performed for a dollar identifier, `LookupName.dollarIdentifier`
50+
/// with the appropriate identifier will be used in the
51+
/// result associated with the closure expression inside `a`.
2652
case mightIntroduceDollarIdentifiers(ClosureExprSyntax)
2753

2854
/// Associated scope.

Sources/SwiftLexicalLookup/Scopes/ScopeImplementations.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -424,14 +424,14 @@ import SwiftSyntax
424424
if inRightTypeOrSameTypeRequirement(lookUpPosition) {
425425
return [.lookInGenericParametersOfExtendedType(self)] + [.lookInMembers(self)]
426426
+ defaultLookupImplementation(identifier, at: lookUpPosition, with: config)
427-
} else {
428-
return [.lookInGenericParametersOfExtendedType(self)]
429-
+ defaultLookupImplementation(identifier, at: lookUpPosition, with: config)
430427
}
431-
} else {
428+
432429
return [.lookInGenericParametersOfExtendedType(self)]
433-
+ lookupInParent(identifier, at: lookUpPosition, with: config)
430+
+ defaultLookupImplementation(identifier, at: lookUpPosition, with: config)
434431
}
432+
433+
return [.lookInGenericParametersOfExtendedType(self)]
434+
+ lookupInParent(identifier, at: lookUpPosition, with: config)
435435
}
436436

437437
/// Returns `true` if `checkedPosition` is a right type of a

Tests/SwiftLexicalLookupTest/ExpectedName.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ enum NameExpectation: ExpectedName {
8181
case (.declaration, .declaration): break
8282
case (.implicit(let implicitName), .implicit(let implicitNameExpectation)):
8383
implicitNameExpectation.assertExpectation(marker: marker, for: implicitName)
84-
case (.dollarIdentifier(_, let acutalStr), .dollarIdentifier(_, let expectedStr)):
84+
case (.dollarIdentifier(_, let actualStr), .dollarIdentifier(_, let expectedStr)):
8585
XCTAssert(
86-
acutalStr == expectedStr,
87-
"For marker \(marker), actual identifier \(acutalStr) doesn't match expected \(expectedStr)"
86+
actualStr == expectedStr,
87+
"For marker \(marker), actual identifier \(actualStr) doesn't match expected \(expectedStr)"
8888
)
8989
default:
9090
XCTFail("For marker \(marker), actual name kind \(name) doesn't match expected \(self)")

0 commit comments

Comments
 (0)