@@ -23,7 +23,7 @@ extension ModuleDependencyGraph {
23
23
// Shorthands
24
24
/*@_spi(Testing)*/ public typealias Graph = ModuleDependencyGraph
25
25
26
- public private( set) var results = Results ( )
26
+ public private( set) var invalidatedNodes = DirectlyInvalidatedNodes ( )
27
27
28
28
/// the graph to be integrated
29
29
let sourceGraph : SourceFileDependencyGraph
@@ -48,6 +48,14 @@ extension ModuleDependencyGraph {
48
48
var reporter : IncrementalCompilationState . Reporter ? {
49
49
destination. info. reporter
50
50
}
51
+
52
+ var sourceType : FileType {
53
+ sourceGraph. dependencySource. typedFile. type
54
+ }
55
+
56
+ var isUpdating : Bool {
57
+ destination. phase. isUpdating
58
+ }
51
59
}
52
60
}
53
61
// MARK: - integrate a graph
@@ -60,7 +68,7 @@ extension ModuleDependencyGraph.Integrator {
60
68
/*@_spi(Testing)*/ public static func integrate(
61
69
from g: SourceFileDependencyGraph ,
62
70
into destination: Graph
63
- ) -> Results {
71
+ ) -> DirectlyInvalidatedNodes {
64
72
var integrator = Self ( sourceGraph: g, destination: destination)
65
73
integrator. integrate ( )
66
74
@@ -69,21 +77,21 @@ extension ModuleDependencyGraph.Integrator {
69
77
}
70
78
destination. dotFileWriter? . write ( g)
71
79
destination. dotFileWriter? . write ( destination)
72
- return integrator. results
80
+ return integrator. invalidatedNodes
73
81
}
74
82
75
83
private mutating func integrate( ) {
76
84
integrateEachSourceNode ( )
77
85
handleDisappearedNodes ( )
78
86
// Ensure transitive closure will get started.
79
- destination. ensureGraphWillRetrace ( results . all )
87
+ destination. ensureGraphWillRetrace ( invalidatedNodes )
80
88
}
81
89
private mutating func integrateEachSourceNode( ) {
82
90
sourceGraph. forEachNode { integrate ( oneNode: $0) }
83
91
}
84
92
private mutating func handleDisappearedNodes( ) {
85
93
for (_, node) in disappearedNodes {
86
- results . addDisappeared ( node)
94
+ addDisappeared ( node)
87
95
destination. nodeFinder. remove ( node)
88
96
}
89
97
}
@@ -122,7 +130,7 @@ extension ModuleDependencyGraph.Integrator {
122
130
disappearedNodes. removeValue ( forKey: matchHere. key)
123
131
if matchHere. fingerprint != integrand. fingerprint {
124
132
matchHere. setFingerprint ( integrand. fingerprint)
125
- results . addChanged ( matchHere)
133
+ addChanged ( matchHere)
126
134
reporter? . report ( " Fingerprint changed for \( matchHere) " )
127
135
}
128
136
return matchHere
@@ -143,10 +151,7 @@ extension ModuleDependencyGraph.Integrator {
143
151
. replace ( expat,
144
152
newDependencySource: sourceGraph. dependencySource,
145
153
newFingerprint: integrand. fingerprint)
146
- if destination. phase. isUpdating {
147
- reporter? . report ( " Discovered a definition for \( integratedNode) " )
148
- }
149
- results. addPatriated ( integratedNode)
154
+ addPatriated ( integratedNode)
150
155
return integratedNode
151
156
}
152
157
@@ -161,10 +166,7 @@ extension ModuleDependencyGraph.Integrator {
161
166
dependencySource: sourceGraph. dependencySource)
162
167
let oldNode = destination. nodeFinder. insert ( newNode)
163
168
assert ( oldNode == nil , " Should be new! " )
164
- if destination. phase. isUpdating {
165
- reporter? . report ( " New definition: \( newNode) " )
166
- }
167
- results. addNew ( newNode)
169
+ addNew ( newNode)
168
170
return newNode
169
171
}
170
172
@@ -180,7 +182,7 @@ extension ModuleDependencyGraph.Integrator {
180
182
use: moduleUseNode)
181
183
if let externalDependency = def. key. designator. externalDependency,
182
184
isNewUse {
183
- recordNodesInvalidatedByUsing (
185
+ collectNodesInvalidatedByUsing (
184
186
externalDependency: FingerprintedExternalDependency ( externalDependency, def. fingerprint) ,
185
187
moduleFileGraphUseNode: moduleUseNode)
186
188
}
@@ -193,41 +195,41 @@ extension ModuleDependencyGraph.Integrator {
193
195
// Remember the dependency for later processing in externalDependencies, and
194
196
// also return it in results.
195
197
// Also the use node has changed.
196
- private mutating func recordNodesInvalidatedByUsing (
198
+ private mutating func collectNodesInvalidatedByUsing (
197
199
externalDependency fingerprintedExternalDependency: FingerprintedExternalDependency ,
198
- moduleFileGraphUseNode moduleUseNode: Graph . Node ) {
199
-
200
+ moduleFileGraphUseNode moduleUseNode: Graph . Node
201
+ ) {
200
202
let invalidated = destination. collectNodesInvalidatedByProcessing (
201
203
fingerprintedExternalDependency: fingerprintedExternalDependency)
202
- results . addUsesOfSomeExternal ( invalidated)
204
+ collectUsesOfSomeExternal ( invalidated)
203
205
}
204
206
}
205
207
206
208
// MARK: - Results {
207
209
extension ModuleDependencyGraph . Integrator {
208
210
/*@_spi(Testing)*/
209
- public struct Results {
210
- typealias Node = ModuleDependencyGraph . Node
211
-
212
- private( set) var all = DirectlyInvalidatedNodes ( )
213
- private( set) var usesOfSomeExternal = DirectlyInvalidatedNodes ( )
214
-
215
- mutating func addUsesOfSomeExternal( _ invalidated: DirectlyInvalidatedNodes )
216
- {
217
- all. formUnion ( invalidated)
218
- usesOfSomeExternal. formUnion ( invalidated)
219
- }
220
- mutating func addDisappeared( _ node: Node ) {
221
- all. insert ( node)
222
- }
223
- mutating func addChanged( _ node: Node ) {
224
- all. insert ( node)
225
- }
226
- mutating func addPatriated( _ node: Node ) {
227
- all. insert ( node)
211
+ mutating func collectUsesOfSomeExternal( _ invalidated: DirectlyInvalidatedNodes )
212
+ {
213
+ invalidatedNodes. formUnion ( invalidated)
214
+ }
215
+ mutating func addDisappeared( _ node: Graph . Node ) {
216
+ assert ( isUpdating)
217
+ invalidatedNodes. insert ( node)
218
+ }
219
+ mutating func addChanged( _ node: Graph . Node ) {
220
+ assert ( isUpdating)
221
+ invalidatedNodes. insert ( node)
222
+ }
223
+ mutating func addPatriated( _ node: Graph . Node ) {
224
+ if isUpdating {
225
+ reporter? . report ( " Discovered a definition for \( node) " )
226
+ invalidatedNodes. insert ( node)
228
227
}
229
- mutating func addNew( _ node: Node ) {
230
- all. insert ( node)
228
+ }
229
+ mutating func addNew( _ node: Graph . Node ) {
230
+ if isUpdating {
231
+ reporter? . report ( " New definition: \( node) " )
232
+ invalidatedNodes. insert ( node)
231
233
}
232
234
}
233
235
}
0 commit comments