Skip to content

Commit 88ae41a

Browse files
committed
Naming tweaks.
1 parent dfbef8d commit 88ae41a

File tree

9 files changed

+18
-18
lines changed

9 files changed

+18
-18
lines changed

CHANGELOG.md

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

1313
- Fix guard-let shorthand syntax.
1414
- Fix accuracy of unused parameter analysis for overridden and protocol conforming functions.
15-
- Fix retaining buildFinalResult(_:) and buildLimitedAvailability(_:) result builder methods.
15+
- Fix retaining `buildFinalResult(_:)` and `buildLimitedAvailability(_:)` result builder methods.
1616

1717
## 2.10.1 (2022-11-20)
1818

Sources/PeripheryKit/Analyzer/Analyzer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public final class Analyzer {
5252

5353
DeclarationMarker.self,
5454
RedundantProtocolMarker.self,
55-
IfLetShorthandPropertyReferenceRetainer.self
55+
LetShorthandPropertyReferenceRetainer.self
5656
]
5757

5858
private let graph: SourceGraph

Sources/PeripheryKit/Analyzer/Visitors/IfLetShorthandPropertyReferenceRetainer.swift renamed to Sources/PeripheryKit/Analyzer/Visitors/letShorthandPropertyReferenceRetainer.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import Foundation
22

33
/// Workaround for https://github.com/apple/swift/issues/61509.
4-
final class IfLetShorthandPropertyReferenceRetainer: SourceGraphVisitor {
4+
final class LetShorthandPropertyReferenceRetainer: SourceGraphVisitor {
55
static func make(graph: SourceGraph) -> Self {
66
return self.init(graph: graph)
77
}
@@ -21,7 +21,7 @@ final class IfLetShorthandPropertyReferenceRetainer: SourceGraphVisitor {
2121
for property in properties {
2222
guard let propertyName = property.name,
2323
let parent = property.parent,
24-
parent.declarations.contains(where: { $0.ifLetShorthandIdentifiers.contains(propertyName) })
24+
parent.declarations.contains(where: { $0.letShorthandIdentifiers.contains(propertyName) })
2525
else { continue }
2626
graph.markReachable(property)
2727
}

Sources/PeripheryKit/Indexer/Declaration.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ public final class Declaration {
175175
public var commentCommands: Set<CommentCommand> = []
176176
public var references: Set<Reference> = []
177177
public var declaredType: String?
178-
public var ifLetShorthandIdentifiers: Set<String> = []
178+
public var letShorthandIdentifiers: Set<String> = []
179179

180180
public var parent: Declaration?
181181
var related: Set<Reference> = []

Sources/PeripheryKit/Indexer/SwiftIndexer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public final class SwiftIndexer {
361361
decl.modifiers = Set(result.modifiers)
362362
decl.commentCommands = Set(result.commentCommands)
363363
decl.declaredType = result.variableType
364-
decl.ifLetShorthandIdentifiers = result.ifLetShorthandIdentifiers
364+
decl.letShorthandIdentifiers = result.letShorthandIdentifiers
365365

366366
for ref in decl.references.union(decl.related) {
367367
if result.inheritedTypeLocations.contains(ref.location) {

Sources/PeripheryKit/Syntax/DeclarationVisitor.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@ final class DeclarationVisitor: PeripherySyntaxVisitor {
1919
inheritedTypeLocations: Set<SourceLocation>,
2020
genericParameterLocations: Set<SourceLocation>,
2121
genericConformanceRequirementLocations: Set<SourceLocation>,
22-
ifLetShorthandIdentifiers: Set<String>
22+
letShorthandIdentifiers: Set<String>
2323
)
2424

2525
private let sourceLocationBuilder: SourceLocationBuilder
2626
private let typeSyntaxInspector: TypeSyntaxInspector
2727
private(set) var results: [Result] = []
28-
private var ifLetShorthandIdentifiers: Set<String> = []
28+
private var letShorthandIdentifiers: Set<String> = []
2929
private var functionDeclStackDepth = 0
3030

3131
var resultsByLocation: [SourceLocation: Result] {
@@ -267,7 +267,7 @@ final class DeclarationVisitor: PeripherySyntaxVisitor {
267267
let parentStmt = node.parent?.parent?.parent,
268268
(parentStmt.is(IfStmtSyntax.self) || parentStmt.is(GuardStmtSyntax.self))
269269
else { return }
270-
ifLetShorthandIdentifiers.insert(identifier.text)
270+
letShorthandIdentifiers.insert(identifier.text)
271271
}
272272

273273
// MARK: - Private
@@ -290,13 +290,13 @@ final class DeclarationVisitor: PeripherySyntaxVisitor {
290290
AttributeSyntax($0)?.attributeName.text ?? CustomAttributeSyntax($0)?.attributeName.firstToken?.text
291291
} ?? []
292292
let location = sourceLocationBuilder.location(at: position)
293-
var ifLetShorthandIdentifiers = Set<String>()
293+
var letShorthandIdentifiers = Set<String>()
294294

295-
// Only associate if-let shorthand identifiers in nested functions with the top-most
295+
// Only associate let shorthand identifiers in nested functions with the top-most
296296
// function.
297297
if functionDeclStackDepth == 0 {
298-
ifLetShorthandIdentifiers = self.ifLetShorthandIdentifiers
299-
self.ifLetShorthandIdentifiers.removeAll()
298+
letShorthandIdentifiers = self.letShorthandIdentifiers
299+
self.letShorthandIdentifiers.removeAll()
300300
}
301301

302302
results.append((
@@ -312,7 +312,7 @@ final class DeclarationVisitor: PeripherySyntaxVisitor {
312312
typeLocations(for: inheritanceClause),
313313
typeLocations(for: genericParameterClause),
314314
typeLocations(for: genericWhereClause),
315-
ifLetShorthandIdentifiers
315+
letShorthandIdentifiers
316316
))
317317
}
318318

Tests/Fixtures/RetentionFixtures/testRetainsResultBuilderMethods.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,11 @@ class FixtureClass130 {
3030
Array(components.joined())
3131
}
3232

33-
static func buildFinalResult(_ component: FixtureClass130.Component) -> Component {
33+
static func buildFinalResult(_ component: Component) -> Component {
3434
component
3535
}
3636

37-
static func buildLimitedAvailability(_ component: FixtureClass130.Component) -> Component {
37+
static func buildLimitedAvailability(_ component: Component) -> Component {
3838
component
3939
}
4040
}

Tests/PeripheryTests/RetentionTest.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ final class RetentionTest: SourceGraphTestCase {
10011001
}
10021002
}
10031003

1004-
func testIfLetShorthandSyntax() {
1004+
func testLetShorthandSyntax() {
10051005
analyze(retainPublic: true) {
10061006
assertReferenced(.class("FixtureClass117")) {
10071007
self.assertReferenced(.varInstance("simpleProperty"))
@@ -1015,7 +1015,7 @@ final class RetentionTest: SourceGraphTestCase {
10151015
self.assertReferenced(.varInstance("propertyReferencedFromPropertyAccessor"))
10161016
}
10171017

1018-
// This property should be referenced, but the if-let shorthand workaround doesn't
1018+
// This property should be referenced, but the let shorthand workaround doesn't
10191019
// handle properties at global (file) scope. This will remain broken until the
10201020
// issue is resolved in Swift: https://github.com/apple/swift/issues/61509.
10211021
self.assertNotReferenced(.varGlobal("fixtureClass117StaticProperty"))

0 commit comments

Comments
 (0)