OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 library analyzer.src.task.dart_work_manager; | 5 library analyzer.src.task.dart_work_manager; |
6 | 6 |
7 import 'dart:collection'; | 7 import 'dart:collection'; |
8 | 8 |
9 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
10 import 'package:analyzer/src/generated/engine.dart' | 10 import 'package:analyzer/src/generated/engine.dart' |
(...skipping 28 matching lines...) Expand all Loading... |
39 | 39 |
40 /** | 40 /** |
41 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. | 41 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. |
42 */ | 42 */ |
43 static final List<ResultDescriptor> _UNIT_ERRORS = <ResultDescriptor>[ | 43 static final List<ResultDescriptor> _UNIT_ERRORS = <ResultDescriptor>[ |
44 HINTS, | 44 HINTS, |
45 LINTS, | 45 LINTS, |
46 LIBRARY_UNIT_ERRORS, | 46 LIBRARY_UNIT_ERRORS, |
47 RESOLVE_TYPE_NAMES_ERRORS, | 47 RESOLVE_TYPE_NAMES_ERRORS, |
48 RESOLVE_UNIT_ERRORS, | 48 RESOLVE_UNIT_ERRORS, |
| 49 STRONG_MODE_ERRORS, |
49 VARIABLE_REFERENCE_ERRORS, | 50 VARIABLE_REFERENCE_ERRORS, |
50 VERIFY_ERRORS | 51 VERIFY_ERRORS |
51 ]; | 52 ]; |
52 | 53 |
53 final InternalAnalysisContext context; | 54 final InternalAnalysisContext context; |
54 | 55 |
55 /** | 56 /** |
56 * The [TargetedResult]s that should be computed with priority. | 57 * The [TargetedResult]s that should be computed with priority. |
57 */ | 58 */ |
58 final LinkedHashSet<TargetedResult> priorityResultQueue = | 59 final LinkedHashSet<TargetedResult> priorityResultQueue = |
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 } | 187 } |
187 } | 188 } |
188 return errors; | 189 return errors; |
189 } | 190 } |
190 | 191 |
191 /** | 192 /** |
192 * Returns libraries containing the given [part]. | 193 * Returns libraries containing the given [part]. |
193 * Maybe empty, but not null. | 194 * Maybe empty, but not null. |
194 */ | 195 */ |
195 List<Source> getLibrariesContainingPart(Source part) { | 196 List<Source> getLibrariesContainingPart(Source part) { |
| 197 if (part.isInSystemLibrary) { |
| 198 DartWorkManager sdkDartWorkManager = _getSdkDartWorkManager(); |
| 199 if (sdkDartWorkManager != this) { |
| 200 return sdkDartWorkManager.getLibrariesContainingPart(part); |
| 201 } |
| 202 } |
196 List<Source> libraries = partLibrariesMap[part]; | 203 List<Source> libraries = partLibrariesMap[part]; |
197 return libraries != null ? libraries : Source.EMPTY_LIST; | 204 return libraries != null ? libraries : Source.EMPTY_LIST; |
198 } | 205 } |
199 | 206 |
200 @override | 207 @override |
201 TargetedResult getNextResult() { | 208 TargetedResult getNextResult() { |
202 // Try to find a priority result to compute. | 209 // Try to find a priority result to compute. |
203 while (priorityResultQueue.isNotEmpty) { | 210 while (priorityResultQueue.isNotEmpty) { |
204 TargetedResult result = priorityResultQueue.first; | 211 TargetedResult result = priorityResultQueue.first; |
205 if (!_needsComputing(result.target, result.result)) { | 212 if (!_needsComputing(result.target, result.result)) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 * Notifies the manager about [SourceFactory] changes. | 265 * Notifies the manager about [SourceFactory] changes. |
259 */ | 266 */ |
260 void onSourceFactoryChanged() { | 267 void onSourceFactoryChanged() { |
261 _invalidateAllLocalResolutionInformation(true); | 268 _invalidateAllLocalResolutionInformation(true); |
262 } | 269 } |
263 | 270 |
264 @override | 271 @override |
265 void resultsComputed( | 272 void resultsComputed( |
266 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { | 273 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { |
267 bool isDartSource = _isDartSource(target); | 274 bool isDartSource = _isDartSource(target); |
| 275 // Route SDK outputs to the SDK WorkManager. |
| 276 if (isDartSource && target.source.isInSystemLibrary) { |
| 277 DartWorkManager sdkWorkManager = _getSdkDartWorkManager(); |
| 278 if (sdkWorkManager != this) { |
| 279 sdkWorkManager.resultsComputed(target, outputs); |
| 280 return; |
| 281 } |
| 282 } |
268 // Organize sources. | 283 // Organize sources. |
269 bool isDartLibrarySource = false; | 284 bool isDartLibrarySource = false; |
270 if (isDartSource) { | 285 if (isDartSource) { |
271 Source source = target; | 286 Source source = target; |
272 SourceKind kind = outputs[SOURCE_KIND]; | 287 SourceKind kind = outputs[SOURCE_KIND]; |
273 if (kind != null) { | 288 if (kind != null) { |
274 unknownSourceQueue.remove(source); | 289 unknownSourceQueue.remove(source); |
275 if (kind == SourceKind.LIBRARY) { | 290 if (kind == SourceKind.LIBRARY) { |
276 isDartLibrarySource = true; | 291 isDartLibrarySource = true; |
277 if (context.prioritySources.contains(source)) { | 292 if (context.prioritySources.contains(source)) { |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 context.getNotice(source).setErrors(info.errors, info.lineInfo); | 347 context.getNotice(source).setErrors(info.errors, info.lineInfo); |
333 } | 348 } |
334 } | 349 } |
335 } | 350 } |
336 | 351 |
337 void unitIncrementallyResolved(Source librarySource, Source unitSource) { | 352 void unitIncrementallyResolved(Source librarySource, Source unitSource) { |
338 librarySourceQueue.add(librarySource); | 353 librarySourceQueue.add(librarySource); |
339 } | 354 } |
340 | 355 |
341 /** | 356 /** |
| 357 * Return the SDK [DartWorkManager] or this one. |
| 358 */ |
| 359 DartWorkManager _getSdkDartWorkManager() { |
| 360 SourceFactory sourceFactory = context.sourceFactory; |
| 361 InternalAnalysisContext sdkContext = sourceFactory.dartSdk.context; |
| 362 if (sdkContext != context) { |
| 363 for (WorkManager workManager in sdkContext.workManagers) { |
| 364 if (workManager is DartWorkManager) { |
| 365 return workManager; |
| 366 } |
| 367 } |
| 368 } |
| 369 return this; |
| 370 } |
| 371 |
| 372 /** |
342 * Invalidate all of the resolution results computed by this context. The flag | 373 * Invalidate all of the resolution results computed by this context. The flag |
343 * [invalidateUris] should be `true` if the cached results of converting URIs | 374 * [invalidateUris] should be `true` if the cached results of converting URIs |
344 * to source files should also be invalidated. | 375 * to source files should also be invalidated. |
345 */ | 376 */ |
346 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { | 377 void _invalidateAllLocalResolutionInformation(bool invalidateUris) { |
347 CachePartition partition = privateAnalysisCachePartition; | 378 CachePartition partition = privateAnalysisCachePartition; |
348 // Prepare targets and values to invalidate. | 379 // Prepare targets and values to invalidate. |
349 List<Source> dartSources = <Source>[]; | 380 List<Source> dartSources = <Source>[]; |
350 List<LibrarySpecificUnit> unitTargets = <LibrarySpecificUnit>[]; | 381 List<LibrarySpecificUnit> unitTargets = <LibrarySpecificUnit>[]; |
351 MapIterator<AnalysisTarget, CacheEntry> iterator = partition.iterator(); | 382 MapIterator<AnalysisTarget, CacheEntry> iterator = partition.iterator(); |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 } | 467 } |
437 } | 468 } |
438 | 469 |
439 bool _shouldErrorsBeComputed(Source source) => | 470 bool _shouldErrorsBeComputed(Source source) => |
440 context.shouldErrorsBeAnalyzed(source, null); | 471 context.shouldErrorsBeAnalyzed(source, null); |
441 | 472 |
442 static bool _isDartSource(AnalysisTarget target) { | 473 static bool _isDartSource(AnalysisTarget target) { |
443 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 474 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
444 } | 475 } |
445 } | 476 } |
OLD | NEW |