Skip to content

Commit e7c52e9

Browse files
author
David Ungar
committed
Rename getSource and getInput for clarity about absence.
1 parent 54fdd8d commit e7c52e9

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraph.swift

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,20 +54,21 @@ import SwiftOptions
5454
self.creationPhase = phase
5555
}
5656

57-
@_spi(Testing) public func getSource(for input: TypedVirtualPath,
58-
function: String = #function,
59-
file: String = #file,
60-
line: Int = #line) -> DependencySource {
61-
guard let source = inputDependencySourceMap.getSource(for: input)
57+
@_spi(Testing) public func getRequiredSource(for input: TypedVirtualPath,
58+
function: String = #function,
59+
file: String = #file,
60+
line: Int = #line) -> DependencySource {
61+
guard let source = inputDependencySourceMap.getSourceIfKnown(for: input)
6262
else {
6363
fatalError("\(input.file.basename) not found in inputDependencySourceMap, \(file):\(line) in \(function)")
6464
}
6565
return source
6666
}
67-
@_spi(Testing) public func getInput(for source: DependencySource) -> TypedVirtualPath? {
67+
68+
@_spi(Testing) public func getNeededInput(for source: DependencySource) -> TypedVirtualPath? {
6869
guard let input =
6970
info.simulateGetInputFailure ? nil
70-
: inputDependencySourceMap.getInput(for: source)
71+
: inputDependencySourceMap.getInputIfKnown(for: source)
7172
else {
7273
info.diagnosticEngine.emit(warning: "Failed to find source file for '\(source.file.basename)', recovering with a full rebuild. Next build will be incremental.")
7374
info.reporter?.report(
@@ -144,7 +145,7 @@ extension ModuleDependencyGraph {
144145
return TransitivelyInvalidatedInputSet()
145146
}
146147
return collectInputsRequiringCompilationAfterProcessing(
147-
dependencySource: getSource(for: input))
148+
dependencySource: getRequiredSource(for: input))
148149
}
149150
}
150151

@@ -166,14 +167,14 @@ extension ModuleDependencyGraph {
166167
/// speculatively scheduled in the first wave.
167168
func collectInputsInvalidatedBy(input: TypedVirtualPath
168169
) -> TransitivelyInvalidatedInputArray {
169-
let changedSource = getSource(for: input)
170+
let changedSource = getRequiredSource(for: input)
170171
let allDependencySourcesToRecompile =
171172
collectSwiftDepsUsing(dependencySource: changedSource)
172173

173174
return allDependencySourcesToRecompile.compactMap {
174175
depedencySource in
175176
guard depedencySource != changedSource else {return nil}
176-
let dependentInput = inputDependencySourceMap.getInput(for: depedencySource)
177+
let dependentInput = inputDependencySourceMap.getInputIfKnown(for: depedencySource)
177178
info.reporter?.report(
178179
"Found dependent of \(input.file.basename):", dependentInput)
179180
return dependentInput
@@ -193,7 +194,7 @@ extension ModuleDependencyGraph {
193194
/// Does the graph contain any dependency nodes for a given source-code file?
194195
func containsNodes(forSourceFile file: TypedVirtualPath) -> Bool {
195196
precondition(file.type == .swift)
196-
guard let source = inputDependencySourceMap.getSource(for: file) else {
197+
guard let source = inputDependencySourceMap.getSourceIfKnown(for: file) else {
197198
return false
198199
}
199200
return containsNodes(forDependencySource: source)
@@ -253,7 +254,7 @@ extension ModuleDependencyGraph {
253254
func collectInputsRequiringCompilation(byCompiling input: TypedVirtualPath
254255
) -> TransitivelyInvalidatedInputSet? {
255256
precondition(input.type == .swift)
256-
let dependencySource = getSource(for: input)
257+
let dependencySource = getRequiredSource(for: input)
257258
return collectInputsRequiringCompilationAfterProcessing(
258259
dependencySource: dependencySource)
259260
}
@@ -340,7 +341,7 @@ extension ModuleDependencyGraph {
340341
) -> TransitivelyInvalidatedInputSet? {
341342
var invalidatedInputs = TransitivelyInvalidatedInputSet()
342343
for invalidatedSwiftDeps in collectSwiftDepsUsingInvalidated(nodes: directlyInvalidatedNodes) {
343-
guard let invalidatedInput = getInput(for: invalidatedSwiftDeps)
344+
guard let invalidatedInput = getNeededInput(for: invalidatedSwiftDeps)
344345
else {
345346
return nil
346347
}

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/InputDependencySourceMap.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ import TSCBasic
3333

3434
// MARK: - Accessing
3535
extension InputDependencySourceMap {
36-
@_spi(Testing) public func getSource(for input: TypedVirtualPath) -> DependencySource? {
36+
@_spi(Testing) public func getSourceIfKnown(for input: TypedVirtualPath) -> DependencySource? {
3737
biMap[input]
3838
}
3939

40-
@_spi(Testing) public func getInput(for source: DependencySource) -> TypedVirtualPath? {
40+
@_spi(Testing) public func getInputIfKnown(for source: DependencySource) -> TypedVirtualPath? {
4141
biMap[source]
4242
}
4343

Sources/SwiftDriver/IncrementalCompilation/ModuleDependencyGraphParts/Tracer.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ extension ModuleDependencyGraph.Tracer {
121121
path.compactMap { node in
122122
node.dependencySource.map {
123123
source in
124-
graph.inputDependencySourceMap.getInput(for: source).map {
124+
graph.inputDependencySourceMap.getInputIfKnown(for: source).map {
125125
input in
126126
"\(node.key) in \(input.file.basename)"
127127
}

0 commit comments

Comments
 (0)