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 /** | 41 /** |
42 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. | 42 * The list of errors that are reported for raw Dart [LibrarySpecificUnit]s. |
43 */ | 43 */ |
44 static final List<ResultDescriptor> _UNIT_ERRORS = <ResultDescriptor>[ | 44 static final List<ResultDescriptor> _UNIT_ERRORS = <ResultDescriptor>[ |
45 BUILD_FUNCTION_TYPE_ALIASES_ERRORS, | 45 BUILD_FUNCTION_TYPE_ALIASES_ERRORS, |
46 HINTS, | 46 HINTS, |
47 RESOLVE_REFERENCES_ERRORS, | 47 RESOLVE_REFERENCES_ERRORS, |
48 RESOLVE_TYPE_NAMES_ERRORS, | 48 RESOLVE_TYPE_NAMES_ERRORS, |
| 49 VARIABLE_REFERENCE_ERRORS, |
49 VERIFY_ERRORS | 50 VERIFY_ERRORS |
50 ]; | 51 ]; |
51 | 52 |
52 final InternalAnalysisContext context; | 53 final InternalAnalysisContext context; |
53 | 54 |
54 /** | 55 /** |
55 * The [TargetedResult]s that should be computed with priority. | 56 * The [TargetedResult]s that should be computed with priority. |
56 */ | 57 */ |
57 final LinkedHashSet<TargetedResult> priorityResultQueue = | 58 final LinkedHashSet<TargetedResult> priorityResultQueue = |
58 new LinkedHashSet<TargetedResult>(); | 59 new LinkedHashSet<TargetedResult>(); |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 } | 173 } |
173 } | 174 } |
174 | 175 |
175 /** | 176 /** |
176 * Return an [AnalysisErrorInfo] containing the list of all of the errors and | 177 * Return an [AnalysisErrorInfo] containing the list of all of the errors and |
177 * the line info associated with the given [source]. The list of errors will | 178 * the line info associated with the given [source]. The list of errors will |
178 * be empty if the source is not known to the context or if there are no | 179 * be empty if the source is not known to the context or if there are no |
179 * errors in the source. The errors contained in the list can be incomplete. | 180 * errors in the source. The errors contained in the list can be incomplete. |
180 */ | 181 */ |
181 AnalysisErrorInfo getErrors(Source source) { | 182 AnalysisErrorInfo getErrors(Source source) { |
| 183 if (analysisCache.getState(source, DART_ERRORS) == CacheState.VALID) { |
| 184 List<AnalysisError> errors = analysisCache.getValue(source, DART_ERRORS); |
| 185 LineInfo lineInfo = analysisCache.getValue(source, LINE_INFO); |
| 186 return new AnalysisErrorInfoImpl(errors, lineInfo); |
| 187 } |
182 List<AnalysisError> errors = <AnalysisError>[]; | 188 List<AnalysisError> errors = <AnalysisError>[]; |
183 for (ResultDescriptor descriptor in _SOURCE_ERRORS) { | 189 for (ResultDescriptor descriptor in _SOURCE_ERRORS) { |
184 errors.addAll(analysisCache.getValue(source, descriptor)); | 190 errors.addAll(analysisCache.getValue(source, descriptor)); |
185 } | 191 } |
186 for (Source library in context.getLibrariesContaining(source)) { | 192 for (Source library in context.getLibrariesContaining(source)) { |
187 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); | 193 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); |
188 for (ResultDescriptor descriptor in _UNIT_ERRORS) { | 194 for (ResultDescriptor descriptor in _UNIT_ERRORS) { |
189 errors.addAll(analysisCache.getValue(unit, descriptor)); | 195 errors.addAll(analysisCache.getValue(unit, descriptor)); |
190 } | 196 } |
191 } | 197 } |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 } | 444 } |
439 } | 445 } |
440 | 446 |
441 bool _shouldErrorsBeComputed(Source source) => | 447 bool _shouldErrorsBeComputed(Source source) => |
442 context.shouldErrorsBeAnalyzed(source, null); | 448 context.shouldErrorsBeAnalyzed(source, null); |
443 | 449 |
444 static bool _isDartSource(AnalysisTarget target) { | 450 static bool _isDartSource(AnalysisTarget target) { |
445 return target is Source && AnalysisEngine.isDartFileName(target.fullName); | 451 return target is Source && AnalysisEngine.isDartFileName(target.fullName); |
446 } | 452 } |
447 } | 453 } |
OLD | NEW |