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 11 matching lines...) Expand all Loading... |
22 */ | 22 */ |
23 class DartWorkManager implements WorkManager { | 23 class DartWorkManager implements WorkManager { |
24 /** | 24 /** |
25 * The list of errors that are reported for raw Dart [Source]s. | 25 * The list of errors that are reported for raw Dart [Source]s. |
26 */ | 26 */ |
27 static final List<ResultDescriptor<List<AnalysisError>>> _SOURCE_ERRORS = | 27 static final List<ResultDescriptor<List<AnalysisError>>> _SOURCE_ERRORS = |
28 <ResultDescriptor<List<AnalysisError>>>[ | 28 <ResultDescriptor<List<AnalysisError>>>[ |
29 BUILD_DIRECTIVES_ERRORS, | 29 BUILD_DIRECTIVES_ERRORS, |
30 BUILD_LIBRARY_ERRORS, | 30 BUILD_LIBRARY_ERRORS, |
31 PARSE_ERRORS, | 31 PARSE_ERRORS, |
| 32 RESOLVE_DIRECTIVES_ERRORS, |
32 SCAN_ERRORS | 33 SCAN_ERRORS |
33 ]; | 34 ]; |
34 | 35 |
35 /** | 36 /** |
36 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. | 37 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. |
37 */ | 38 */ |
38 static final List<ResultDescriptor<List<AnalysisError>>> _UNIT_ERRORS = | 39 static final List<ResultDescriptor<List<AnalysisError>>> _UNIT_ERRORS = |
39 <ResultDescriptor<List<AnalysisError>>>[ | 40 <ResultDescriptor<List<AnalysisError>>>[ |
40 HINTS, | 41 HINTS, |
41 LINTS, | 42 LINTS, |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
296 } else { | 297 } else { |
297 bool needErrors = _shouldErrorsBeComputed(source); | 298 bool needErrors = _shouldErrorsBeComputed(source); |
298 if (needErrors) { | 299 if (needErrors) { |
299 librarySourceQueue.add(target); | 300 librarySourceQueue.add(target); |
300 } | 301 } |
301 } | 302 } |
302 } | 303 } |
303 } | 304 } |
304 } | 305 } |
305 // Update parts in libraries. | 306 // Update parts in libraries. |
306 if (isDartLibrarySource) { | 307 { |
307 Source library = target; | |
308 List<Source> includedParts = outputs[INCLUDED_PARTS] as List<Source>; | 308 List<Source> includedParts = outputs[INCLUDED_PARTS] as List<Source>; |
309 if (includedParts != null) { | 309 if (includedParts != null && !includedParts.isEmpty) { |
| 310 Source library = target; |
310 libraryPartsMap[library] = includedParts; | 311 libraryPartsMap[library] = includedParts; |
311 for (Source part in includedParts) { | 312 for (Source part in includedParts) { |
312 List<Source> libraries = | 313 List<Source> libraries = |
313 partLibrariesMap.putIfAbsent(part, () => <Source>[]); | 314 partLibrariesMap.putIfAbsent(part, () => <Source>[]); |
314 if (!libraries.contains(library)) { | 315 if (!libraries.contains(library)) { |
315 libraries.add(library); | 316 libraries.add(library); |
316 _invalidateContainingLibraries(part); | 317 _invalidateContainingLibraries(part); |
317 } | 318 } |
318 } | 319 } |
319 } | 320 } |
320 } | 321 } |
321 // Update notice. | 322 // Update notice. |
322 if (isDartSource) { | 323 if (isDartSource) { |
323 bool shouldSetErrors = false; | 324 bool shouldSetErrors = false; |
324 outputs.forEach((ResultDescriptor descriptor, value) { | 325 outputs.forEach((ResultDescriptor descriptor, value) { |
325 if (descriptor == PARSED_UNIT && value != null) { | 326 if (descriptor == PARSED_UNIT1 && value != null) { |
326 context.getNotice(target).parsedDartUnit = value; | 327 context.getNotice(target).parsedDartUnit = value; |
327 shouldSetErrors = true; | 328 shouldSetErrors = true; |
328 } | 329 } |
329 if (descriptor == DART_ERRORS) { | 330 if (descriptor == DART_ERRORS) { |
330 shouldSetErrors = true; | 331 shouldSetErrors = true; |
331 } | 332 } |
332 }); | 333 }); |
333 if (shouldSetErrors) { | 334 if (shouldSetErrors) { |
334 AnalysisErrorInfo info = context.getErrors(target); | 335 AnalysisErrorInfo info = context.getErrors(target); |
335 context.getNotice(target).setErrors(info.errors, info.lineInfo); | 336 context.getNotice(target).setErrors(info.errors, info.lineInfo); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 } | 419 } |
419 } | 420 } |
420 } | 421 } |
421 // Invalidate targets and values. | 422 // Invalidate targets and values. |
422 unitTargets.forEach(partition.remove); | 423 unitTargets.forEach(partition.remove); |
423 for (Source dartSource in dartSources) { | 424 for (Source dartSource in dartSources) { |
424 CacheEntry entry = partition.get(dartSource); | 425 CacheEntry entry = partition.get(dartSource); |
425 if (entry != null) { | 426 if (entry != null) { |
426 // TODO(scheglov) we invalidate too much. | 427 // TODO(scheglov) we invalidate too much. |
427 // Would be nice to invalidate just URLs resolution. | 428 // Would be nice to invalidate just URLs resolution. |
| 429 entry.setState(PARSED_UNIT1, CacheState.INVALID); |
428 entry.setState(PARSED_UNIT, CacheState.INVALID); | 430 entry.setState(PARSED_UNIT, CacheState.INVALID); |
429 entry.setState(IMPORTED_LIBRARIES, CacheState.INVALID); | 431 entry.setState(IMPORTED_LIBRARIES, CacheState.INVALID); |
430 entry.setState(EXPLICITLY_IMPORTED_LIBRARIES, CacheState.INVALID); | 432 entry.setState(EXPLICITLY_IMPORTED_LIBRARIES, CacheState.INVALID); |
431 entry.setState(EXPORTED_LIBRARIES, CacheState.INVALID); | 433 entry.setState(EXPORTED_LIBRARIES, CacheState.INVALID); |
432 entry.setState(INCLUDED_PARTS, CacheState.INVALID); | 434 entry.setState(INCLUDED_PARTS, CacheState.INVALID); |
433 entry.setState(LIBRARY_SPECIFIC_UNITS, CacheState.INVALID); | 435 entry.setState(LIBRARY_SPECIFIC_UNITS, CacheState.INVALID); |
434 entry.setState(UNITS, CacheState.INVALID); | 436 entry.setState(UNITS, CacheState.INVALID); |
435 } | 437 } |
436 } | 438 } |
437 } | 439 } |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 493 } |
492 } | 494 } |
493 | 495 |
494 bool _shouldErrorsBeComputed(Source source) => | 496 bool _shouldErrorsBeComputed(Source source) => |
495 context.shouldErrorsBeAnalyzed(source); | 497 context.shouldErrorsBeAnalyzed(source); |
496 | 498 |
497 static bool _isDartSource(AnalysisTarget target) { | 499 static bool _isDartSource(AnalysisTarget target) { |
498 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 500 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
499 } | 501 } |
500 } | 502 } |
OLD | NEW |