Skip to content

Commit 6759b05

Browse files
committed
Make IntroducingToSequentialParentScopeSyntax and SequentialScope internal. Format.
1 parent 9945bf0 commit 6759b05

File tree

8 files changed

+32
-19
lines changed

8 files changed

+32
-19
lines changed

Sources/SwiftLexicalLookup/IntroducingToSequentialParentScopeSyntax.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
import SwiftSyntax
1414

15-
@_spi(Experimental) public protocol IntroducingToSequentialParentScopeSyntax: ScopeSyntax {
15+
protocol IntroducingToSequentialParentScopeSyntax: ScopeSyntax {
1616
/// Returns names matching lookup that should be
1717
/// handled by it's parent sequential scope.
1818
func introducesToSequentialParent(

Sources/SwiftLexicalLookup/LookupName.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import SwiftSyntax
2323
case newValue(AccessorDeclSyntax)
2424
/// `oldValue` available by default inside `didSet`.
2525
case oldValue(AccessorDeclSyntax)
26-
26+
2727
/// Syntax associated with this name.
2828
@_spi(Experimental) public var syntax: SyntaxProtocol {
2929
switch self {
@@ -39,7 +39,7 @@ import SwiftSyntax
3939
syntax
4040
}
4141
}
42-
42+
4343
/// Used for name comparison.
4444
var name: String {
4545
switch self {

Sources/SwiftLexicalLookup/LookupState.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Foundation
1515
@_spi(Experimental) public struct LookupState {
1616
/// Specifies scopes that introduce names to their parent and
1717
/// should be skipped during lookup in sequential scopes.
18-
@_spi(Experimental) public var skipSequentialIntroductionFrom: IntroducingToSequentialParentScopeSyntax?
19-
18+
var skipSequentialIntroductionFrom: IntroducingToSequentialParentScopeSyntax?
19+
2020
@_spi(Experimental) public init() {}
2121
}

Sources/SwiftLexicalLookup/ScopeImplementations.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ import SwiftSyntax
185185
}
186186
}
187187

188-
@_spi(Experimental) extension ForStmtSyntax: ScopeSyntax {
188+
@_spi(Experimental) extension ForStmtSyntax: ScopeSyntax {
189189
/// Names introduced in the `for` body.
190190
@_spi(Experimental) public var introducedNames: [LookupName] {
191191
LookupName.getNames(from: pattern)
@@ -367,6 +367,8 @@ import SwiftSyntax
367367
@_spi(Experimental) extension ExtensionDeclSyntax: TypeScopeSyntax {}
368368

369369
@_spi(Experimental) extension AccessorDeclSyntax: ScopeSyntax {
370+
/// Implicit and/or explicit names introduced
371+
/// withing the accessor..
370372
@_spi(Experimental) public var introducedNames: [LookupName] {
371373
if let parameters {
372374
LookupName.getNames(from: parameters)

Sources/SwiftLexicalLookup/ScopeSyntax.swift

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,12 @@ extension SyntaxProtocol {
5858
var introducedNames: [LookupName] { get }
5959
/// Finds all declarations `name` refers to. `syntax` specifies the node lookup was triggered with.
6060
/// If `name` set to `nil`, returns all available names at the given node.
61-
func lookup(for name: String?,
62-
at syntax: SyntaxProtocol,
63-
with config: LookupConfig,
64-
state: LookupState) -> [LookupResult]
61+
func lookup(
62+
for name: String?,
63+
at syntax: SyntaxProtocol,
64+
with config: LookupConfig,
65+
state: LookupState
66+
) -> [LookupResult]
6567
}
6668

6769
@_spi(Experimental) extension ScopeSyntax {
@@ -99,7 +101,8 @@ extension SyntaxProtocol {
99101
if filteredNames.isEmpty {
100102
return lookupInParent(for: name, at: syntax, with: config, state: state)
101103
} else {
102-
return [.fromScope(self, withNames: filteredNames)] + lookupInParent(for: name, at: syntax, with: config, state: state)
104+
return [.fromScope(self, withNames: filteredNames)]
105+
+ lookupInParent(for: name, at: syntax, with: config, state: state)
103106
}
104107
}
105108

Sources/SwiftLexicalLookup/SequentialScopeSyntax.swift

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SwiftSyntax
1515
/// Scope that, in addition to names introduced by itself,
1616
/// also handles names introduced by
1717
/// `IntroducingToSequentialParentScopeSyntax` children scopes.
18-
@_spi(Experimental) public protocol SequentialScopeSyntax: ScopeSyntax {
18+
protocol SequentialScopeSyntax: ScopeSyntax {
1919
/// Returns names introduced by `codeBlockItems`
2020
/// and included `IntroducingToSequentialParentScopeSyntax` children
2121
/// scopes that match the lookup.
@@ -29,8 +29,8 @@ import SwiftSyntax
2929
) -> [LookupResult]
3030
}
3131

32-
@_spi(Experimental) extension SequentialScopeSyntax {
33-
@_spi(Experimental) public func sequentialLookup(
32+
extension SequentialScopeSyntax {
33+
func sequentialLookup(
3434
in codeBlockItems: any Collection<CodeBlockItemSyntax>,
3535
for name: String?,
3636
at syntax: SyntaxProtocol,
@@ -47,7 +47,8 @@ import SwiftSyntax
4747
{
4848
// Check if the enocountered scope should be ignored.
4949
if let scopeToSkip = state.skipSequentialIntroductionFrom,
50-
scopeToSkip.id == introducingToParentScope.id {
50+
scopeToSkip.id == introducingToParentScope.id
51+
{
5152
continue
5253
}
5354

@@ -59,7 +60,12 @@ import SwiftSyntax
5960

6061
// Add names introduced by the encountered scope.
6162
result.append(
62-
contentsOf: introducingToParentScope.introducesToSequentialParent(for: name, at: syntax, with: config, state: state)
63+
contentsOf: introducingToParentScope.introducesToSequentialParent(
64+
for: name,
65+
at: syntax,
66+
with: config,
67+
state: state
68+
)
6369
)
6470
} else {
6571
// Extract new names from encountered node.

Sources/SwiftLexicalLookup/TypeScopeSyntax.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
import SwiftSyntax
1414

1515
@_spi(Experimental) public protocol TypeScopeSyntax: ScopeSyntax, DeclSyntaxProtocol {
16+
/// `self` and `Self` names referring to
17+
/// this scope.
1618
var implicitInstanceAndTypeNames: [LookupName] { get }
1719
}
1820

Tests/SwiftLexicalLookupTest/ExpectedName.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ enum ImplicitNameExpectation {
3131
case error(String)
3232
case newValue(String)
3333
case oldValue(String)
34-
34+
3535
func assertExpectation(marker: String, for name: LookupImplicitNameKind) {
3636
switch (name, self) {
3737
case (.self, .self): break
@@ -43,7 +43,7 @@ enum ImplicitNameExpectation {
4343
XCTFail("For marker \(marker), actual name kind \(name) doesn't match expected \(self)")
4444
}
4545
}
46-
46+
4747
var marker: String {
4848
switch self {
4949
case .self(let marker),
@@ -66,7 +66,7 @@ enum NameExpectation: ExpectedName {
6666
var marker: String {
6767
switch self {
6868
case .identifier(let marker),
69-
.declaration(let marker):
69+
.declaration(let marker):
7070
marker
7171
case .implicit(let implicitName):
7272
implicitName.marker

0 commit comments

Comments
 (0)