@@ -96,14 +96,16 @@ class AnalysisDriverModel {
96
96
withDriverResource, {
97
97
required bool transitive,
98
98
}) async {
99
- for (final entrypoint in entrypoints) {
100
- await _performResolve (
101
- buildStep as BuildStepImpl ,
102
- entrypoint,
103
- withDriverResource,
104
- transitive: transitive,
105
- );
106
- }
99
+ await _log.attributeAsync (Attribution .resolve, () async {
100
+ for (final entrypoint in entrypoints) {
101
+ await _performResolve (
102
+ buildStep as BuildStepImpl ,
103
+ entrypoint,
104
+ withDriverResource,
105
+ transitive: transitive,
106
+ );
107
+ }
108
+ });
107
109
}
108
110
109
111
Future <void > _performResolve (
@@ -115,68 +117,63 @@ class AnalysisDriverModel {
115
117
withDriverResource, {
116
118
required bool transitive,
117
119
}) async {
118
- await _log.attributeAsync (Attribution .resolve, () async {
119
- Iterable <AssetId > idsToSyncOntoFilesystem;
120
-
121
- // If requested, find transitive imports.
122
- if (transitive) {
123
- // Note: `transitiveDepsOf` can cause loads that cause builds that cause a
124
- // recursive `_performResolve` on this same `AnalysisDriver` instance.
125
- final nodeLoader = AssetDepsLoader (buildStep.phasedReader);
126
- buildStep.inputTracker.addResolverEntrypoint (entrypoint);
127
- idsToSyncOntoFilesystem = await _graphLoader.transitiveDepsOf (
128
- nodeLoader,
129
- entrypoint,
130
- );
131
- } else {
132
- // Notify [buildStep] of its inputs.
133
- buildStep.inputTracker.add (entrypoint);
134
- idsToSyncOntoFilesystem = [entrypoint];
135
- }
120
+ Iterable <AssetId > idsToSyncOntoFilesystem;
121
+
122
+ // If requested, find transitive imports.
123
+ if (transitive) {
124
+ // Note: `transitiveDepsOf` can cause loads that cause builds that cause a
125
+ // recursive `_performResolve` on this same `AnalysisDriver` instance.
126
+ final nodeLoader = AssetDepsLoader (buildStep.phasedReader);
127
+ buildStep.inputTracker.addResolverEntrypoint (entrypoint);
128
+ idsToSyncOntoFilesystem = await _graphLoader.transitiveDepsOf (
129
+ nodeLoader,
130
+ entrypoint,
131
+ );
132
+ } else {
133
+ // Notify [buildStep] of its inputs.
134
+ buildStep.inputTracker.add (entrypoint);
135
+ idsToSyncOntoFilesystem = [entrypoint];
136
+ }
136
137
137
- await withDriverResource ((driver) async {
138
- // Sync changes onto the "URI resolver", the in-memory filesystem.
139
- final phase = buildStep.phasedReader.phase;
140
- for (final id in idsToSyncOntoFilesystem) {
141
- final wasSyncedAt = _syncedOntoFilesystemAtPhase[id];
142
- if (wasSyncedAt != null ) {
143
- // Skip if already synced at this phase.
144
- if (wasSyncedAt == phase) {
145
- continue ;
146
- }
147
- // Skip if synced at an equivalent other phase.
148
- if (! buildStep.phasedReader.hasChanged (
149
- id,
150
- comparedToPhase: wasSyncedAt,
151
- )) {
152
- continue ;
153
- }
138
+ await withDriverResource ((driver) async {
139
+ // Sync changes onto the "URI resolver", the in-memory filesystem.
140
+ final phase = buildStep.phasedReader.phase;
141
+ for (final id in idsToSyncOntoFilesystem) {
142
+ final wasSyncedAt = _syncedOntoFilesystemAtPhase[id];
143
+ if (wasSyncedAt != null ) {
144
+ // Skip if already synced at this phase.
145
+ if (wasSyncedAt == phase) {
146
+ continue ;
154
147
}
155
-
156
- _syncedOntoFilesystemAtPhase[id] = phase;
157
-
158
- // Tracking has already been done by calling `inputTracker` directly.
159
- // Use `phasedReader` for the read instead of the `buildStep` methods
160
- // `canRead` and `readAsString`, which would call `inputTracker`.
161
- final content = await buildStep.phasedReader.readAtPhase (id);
162
- if (content == null ) {
163
- filesystem.deleteFile (id.asPath);
164
- } else {
165
- filesystem.writeFile (id.asPath, content);
148
+ // Skip if synced at an equivalent other phase.
149
+ if (! buildStep.phasedReader.hasChanged (
150
+ id,
151
+ comparedToPhase: wasSyncedAt,
152
+ )) {
153
+ continue ;
166
154
}
167
155
}
168
156
169
- // Notify the analyzer of changes and wait for it to update its internal
170
- // state.
171
- for (final path in filesystem.changedPaths) {
172
- driver.changeFile (path);
157
+ _syncedOntoFilesystemAtPhase[id] = phase;
158
+
159
+ // Tracking has already been done by calling `inputTracker` directly.
160
+ // Use `phasedReader` for the read instead of the `buildStep` methods
161
+ // `canRead` and `readAsString`, which would call `inputTracker`.
162
+ final content = await buildStep.phasedReader.readAtPhase (id);
163
+ if (content == null ) {
164
+ filesystem.deleteFile (id.asPath);
165
+ } else {
166
+ filesystem.writeFile (id.asPath, content);
173
167
}
174
- filesystem.clearChangedPaths ();
175
- await _log.attributeAsync (
176
- Attribution .analyze,
177
- driver.applyPendingFileChanges,
178
- );
179
- });
168
+ }
169
+
170
+ // Notify the analyzer of changes and wait for it to update its internal
171
+ // state.
172
+ for (final path in filesystem.changedPaths) {
173
+ driver.changeFile (path);
174
+ }
175
+ filesystem.clearChangedPaths ();
176
+ await driver.applyPendingFileChanges ();
180
177
});
181
178
}
182
179
}
0 commit comments