OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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.generated.engine; | 5 library analyzer.src.generated.engine; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 import 'dart:collection'; | 8 import 'dart:collection'; |
9 | 9 |
10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
11 import 'package:analyzer/dart/ast/visitor.dart'; | 11 import 'package:analyzer/dart/ast/visitor.dart'; |
12 import 'package:analyzer/dart/element/element.dart'; | 12 import 'package:analyzer/dart/element/element.dart'; |
| 13 import 'package:analyzer/error/error.dart'; |
13 import 'package:analyzer/exception/exception.dart'; | 14 import 'package:analyzer/exception/exception.dart'; |
14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 15 import 'package:analyzer/instrumentation/instrumentation.dart'; |
15 import 'package:analyzer/plugin/resolver_provider.dart'; | 16 import 'package:analyzer/plugin/resolver_provider.dart'; |
16 import 'package:analyzer/src/cancelable_future.dart'; | 17 import 'package:analyzer/src/cancelable_future.dart'; |
17 import 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator; | 18 import 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator; |
18 import 'package:analyzer/src/context/cache.dart'; | 19 import 'package:analyzer/src/context/cache.dart'; |
19 import 'package:analyzer/src/context/context.dart'; | 20 import 'package:analyzer/src/context/context.dart'; |
20 import 'package:analyzer/src/generated/constant.dart'; | 21 import 'package:analyzer/src/generated/constant.dart'; |
21 import 'package:analyzer/src/generated/error.dart'; | |
22 import 'package:analyzer/src/generated/java_core.dart'; | 22 import 'package:analyzer/src/generated/java_core.dart'; |
23 import 'package:analyzer/src/generated/java_engine.dart'; | 23 import 'package:analyzer/src/generated/java_engine.dart'; |
24 import 'package:analyzer/src/generated/resolver.dart'; | 24 import 'package:analyzer/src/generated/resolver.dart'; |
25 import 'package:analyzer/src/generated/source.dart'; | 25 import 'package:analyzer/src/generated/source.dart'; |
26 import 'package:analyzer/src/generated/utilities_general.dart'; | 26 import 'package:analyzer/src/generated/utilities_general.dart'; |
27 import 'package:analyzer/src/plugin/command_line_plugin.dart'; | 27 import 'package:analyzer/src/plugin/command_line_plugin.dart'; |
28 import 'package:analyzer/src/plugin/engine_plugin.dart'; | 28 import 'package:analyzer/src/plugin/engine_plugin.dart'; |
29 import 'package:analyzer/src/plugin/options_plugin.dart'; | 29 import 'package:analyzer/src/plugin/options_plugin.dart'; |
30 import 'package:analyzer/src/task/manager.dart'; | 30 import 'package:analyzer/src/task/manager.dart'; |
31 import 'package:analyzer/task/dart.dart'; | 31 import 'package:analyzer/task/dart.dart'; |
32 import 'package:analyzer/task/model.dart'; | 32 import 'package:analyzer/task/model.dart'; |
33 import 'package:html/dom.dart' show Document; | 33 import 'package:html/dom.dart' show Document; |
34 import 'package:path/path.dart' as pathos; | 34 import 'package:path/path.dart' as pathos; |
35 import 'package:plugin/manager.dart'; | 35 import 'package:plugin/manager.dart'; |
36 import 'package:plugin/plugin.dart'; | 36 import 'package:plugin/plugin.dart'; |
37 | 37 |
| 38 export 'package:analyzer/error/listener.dart' show RecordingErrorListener; |
| 39 |
38 /** | 40 /** |
39 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some | 41 * Used by [AnalysisOptions] to allow function bodies to be analyzed in some |
40 * sources but not others. | 42 * sources but not others. |
41 */ | 43 */ |
42 typedef bool AnalyzeFunctionBodiesPredicate(Source source); | 44 typedef bool AnalyzeFunctionBodiesPredicate(Source source); |
43 | 45 |
44 /** | 46 /** |
45 * A context in which a single analysis can be performed and incrementally | 47 * A context in which a single analysis can be performed and incrementally |
46 * maintained. The context includes such information as the version of the SDK | 48 * maintained. The context includes such information as the version of the SDK |
47 * being analyzed against as well as the package-root used to resolve 'package:' | 49 * being analyzed against as well as the package-root used to resolve 'package:' |
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2356 | 2358 |
2357 /** | 2359 /** |
2358 * Statistics about cache consistency validation. | 2360 * Statistics about cache consistency validation. |
2359 */ | 2361 */ |
2360 static final CacheConsistencyValidationStatistics | 2362 static final CacheConsistencyValidationStatistics |
2361 cacheConsistencyValidationStatistics = | 2363 cacheConsistencyValidationStatistics = |
2362 new CacheConsistencyValidationStatistics(); | 2364 new CacheConsistencyValidationStatistics(); |
2363 } | 2365 } |
2364 | 2366 |
2365 /** | 2367 /** |
2366 * An error listener that will record the errors that are reported to it in a | |
2367 * way that is appropriate for caching those errors within an analysis context. | |
2368 */ | |
2369 class RecordingErrorListener implements AnalysisErrorListener { | |
2370 /** | |
2371 * A map of sets containing the errors that were collected, keyed by each | |
2372 * source. | |
2373 */ | |
2374 Map<Source, HashSet<AnalysisError>> _errors = | |
2375 new HashMap<Source, HashSet<AnalysisError>>(); | |
2376 | |
2377 /** | |
2378 * Return the errors collected by the listener. | |
2379 */ | |
2380 List<AnalysisError> get errors { | |
2381 int numEntries = _errors.length; | |
2382 if (numEntries == 0) { | |
2383 return AnalysisError.NO_ERRORS; | |
2384 } | |
2385 List<AnalysisError> resultList = new List<AnalysisError>(); | |
2386 for (HashSet<AnalysisError> errors in _errors.values) { | |
2387 resultList.addAll(errors); | |
2388 } | |
2389 return resultList; | |
2390 } | |
2391 | |
2392 /** | |
2393 * Add all of the errors recorded by the given [listener] to this listener. | |
2394 */ | |
2395 void addAll(RecordingErrorListener listener) { | |
2396 for (AnalysisError error in listener.errors) { | |
2397 onError(error); | |
2398 } | |
2399 } | |
2400 | |
2401 /** | |
2402 * Return the errors collected by the listener for the given [source]. | |
2403 */ | |
2404 List<AnalysisError> getErrorsForSource(Source source) { | |
2405 HashSet<AnalysisError> errorsForSource = _errors[source]; | |
2406 if (errorsForSource == null) { | |
2407 return AnalysisError.NO_ERRORS; | |
2408 } else { | |
2409 return new List.from(errorsForSource); | |
2410 } | |
2411 } | |
2412 | |
2413 @override | |
2414 void onError(AnalysisError error) { | |
2415 Source source = error.source; | |
2416 HashSet<AnalysisError> errorsForSource = _errors[source]; | |
2417 if (_errors[source] == null) { | |
2418 errorsForSource = new HashSet<AnalysisError>(); | |
2419 _errors[source] = errorsForSource; | |
2420 } | |
2421 errorsForSource.add(error); | |
2422 } | |
2423 } | |
2424 | |
2425 /** | |
2426 * An visitor that removes any resolution information from an AST structure when | 2368 * An visitor that removes any resolution information from an AST structure when |
2427 * used to visit that structure. | 2369 * used to visit that structure. |
2428 */ | 2370 */ |
2429 class ResolutionEraser extends GeneralizingAstVisitor<Object> { | 2371 class ResolutionEraser extends GeneralizingAstVisitor<Object> { |
2430 /** | 2372 /** |
2431 * A flag indicating whether the elements associated with declarations should | 2373 * A flag indicating whether the elements associated with declarations should |
2432 * be erased. | 2374 * be erased. |
2433 */ | 2375 */ |
2434 bool eraseDeclarations = true; | 2376 bool eraseDeclarations = true; |
2435 | 2377 |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2692 * The data that was created from the source. | 2634 * The data that was created from the source. |
2693 */ | 2635 */ |
2694 final E data; | 2636 final E data; |
2695 | 2637 |
2696 /** | 2638 /** |
2697 * Initialize a newly created holder to associate the given [data] with the | 2639 * Initialize a newly created holder to associate the given [data] with the |
2698 * given [modificationTime]. | 2640 * given [modificationTime]. |
2699 */ | 2641 */ |
2700 TimestampedData(this.modificationTime, this.data); | 2642 TimestampedData(this.modificationTime, this.data); |
2701 } | 2643 } |
OLD | NEW |