| 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 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 /** | 258 /** |
| 259 * Notifies the manager about [SourceFactory] changes. | 259 * Notifies the manager about [SourceFactory] changes. |
| 260 */ | 260 */ |
| 261 void onSourceFactoryChanged() { | 261 void onSourceFactoryChanged() { |
| 262 _invalidateAllLocalResolutionInformation(true); | 262 _invalidateAllLocalResolutionInformation(true); |
| 263 } | 263 } |
| 264 | 264 |
| 265 @override | 265 @override |
| 266 void resultsComputed( | 266 void resultsComputed( |
| 267 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { | 267 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { |
| 268 bool isDartSource = _isDartSource(target); |
| 268 // Organize sources. | 269 // Organize sources. |
| 269 if (_isDartSource(target)) { | 270 bool isDartLibrarySource = false; |
| 271 if (isDartSource) { |
| 270 Source source = target; | 272 Source source = target; |
| 271 SourceKind kind = outputs[SOURCE_KIND]; | 273 SourceKind kind = outputs[SOURCE_KIND]; |
| 272 if (kind != null) { | 274 if (kind != null) { |
| 273 unknownSourceQueue.remove(source); | 275 unknownSourceQueue.remove(source); |
| 274 if (kind == SourceKind.LIBRARY) { | 276 if (kind == SourceKind.LIBRARY) { |
| 277 isDartLibrarySource = true; |
| 275 if (context.prioritySources.contains(source)) { | 278 if (context.prioritySources.contains(source)) { |
| 276 _schedulePriorityLibrarySourceAnalysis(source); | 279 _schedulePriorityLibrarySourceAnalysis(source); |
| 277 } else { | 280 } else { |
| 278 bool needErrors = _shouldErrorsBeComputed(source); | 281 bool needErrors = _shouldErrorsBeComputed(source); |
| 279 if (needErrors) { | 282 if (needErrors) { |
| 280 librarySourceQueue.add(target); | 283 librarySourceQueue.add(target); |
| 281 } | 284 } |
| 282 } | 285 } |
| 283 } | 286 } |
| 284 } | 287 } |
| 285 } | 288 } |
| 286 // Update parts in libraries. | 289 // Update parts in libraries. |
| 287 if (_isDartSource(target)) { | 290 if (isDartLibrarySource) { |
| 288 Source library = target; | 291 Source library = target; |
| 289 List<Source> includedParts = outputs[INCLUDED_PARTS]; | 292 List<Source> includedParts = outputs[INCLUDED_PARTS]; |
| 290 if (includedParts != null) { | 293 if (includedParts != null) { |
| 291 libraryPartsMap[library] = includedParts; | 294 libraryPartsMap[library] = includedParts; |
| 292 for (Source part in includedParts) { | 295 for (Source part in includedParts) { |
| 293 List<Source> libraries = | 296 List<Source> libraries = |
| 294 partLibrariesMap.putIfAbsent(part, () => <Source>[]); | 297 partLibrariesMap.putIfAbsent(part, () => <Source>[]); |
| 295 if (!libraries.contains(library)) { | 298 if (!libraries.contains(library)) { |
| 296 libraries.add(library); | 299 libraries.add(library); |
| 297 _invalidateContainingLibraries(part); | 300 _invalidateContainingLibraries(part); |
| 298 } | 301 } |
| 299 } | 302 } |
| 300 } | 303 } |
| 301 } | 304 } |
| 302 // Update notice. | 305 // Update notice. |
| 303 if (_isDartSource(target)) { | 306 if (isDartSource) { |
| 304 bool shouldSetErrors = false; | 307 bool shouldSetErrors = false; |
| 305 outputs.forEach((ResultDescriptor descriptor, value) { | 308 outputs.forEach((ResultDescriptor descriptor, value) { |
| 306 if (descriptor == PARSED_UNIT && value != null) { | 309 if (descriptor == PARSED_UNIT && value != null) { |
| 307 context.getNotice(target).parsedDartUnit = value; | 310 context.getNotice(target).parsedDartUnit = value; |
| 308 shouldSetErrors = true; | 311 shouldSetErrors = true; |
| 309 } | 312 } |
| 310 if (descriptor == DART_ERRORS) { | 313 if (descriptor == DART_ERRORS) { |
| 311 shouldSetErrors = true; | 314 shouldSetErrors = true; |
| 312 } | 315 } |
| 313 }); | 316 }); |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 } | 437 } |
| 435 } | 438 } |
| 436 | 439 |
| 437 bool _shouldErrorsBeComputed(Source source) => | 440 bool _shouldErrorsBeComputed(Source source) => |
| 438 context.shouldErrorsBeAnalyzed(source, null); | 441 context.shouldErrorsBeAnalyzed(source, null); |
| 439 | 442 |
| 440 static bool _isDartSource(AnalysisTarget target) { | 443 static bool _isDartSource(AnalysisTarget target) { |
| 441 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 444 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
| 442 } | 445 } |
| 443 } | 446 } |
| OLD | NEW |