Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(55)

Side by Side Diff: pkg/analyzer/lib/src/task/dart_work_manager.dart

Issue 1842363004: More strong mode fixes for analyzer (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Backout options changes Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 import 'package:analyzer/task/dart.dart'; 23 import 'package:analyzer/task/dart.dart';
24 import 'package:analyzer/task/model.dart'; 24 import 'package:analyzer/task/model.dart';
25 25
26 /** 26 /**
27 * The manager for Dart specific analysis. 27 * The manager for Dart specific analysis.
28 */ 28 */
29 class DartWorkManager implements WorkManager { 29 class DartWorkManager implements WorkManager {
30 /** 30 /**
31 * The list of errors that are reported for raw Dart [Source]s. 31 * The list of errors that are reported for raw Dart [Source]s.
32 */ 32 */
33 static final List<ResultDescriptor> _SOURCE_ERRORS = <ResultDescriptor>[ 33 static final List<ResultDescriptor<List<AnalysisError>>> _SOURCE_ERRORS =
34 <ResultDescriptor<List<AnalysisError>>>[
34 BUILD_DIRECTIVES_ERRORS, 35 BUILD_DIRECTIVES_ERRORS,
35 BUILD_LIBRARY_ERRORS, 36 BUILD_LIBRARY_ERRORS,
36 PARSE_ERRORS, 37 PARSE_ERRORS,
37 SCAN_ERRORS 38 SCAN_ERRORS
38 ]; 39 ];
39 40
40 /** 41 /**
41 * 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.
42 */ 43 */
43 static final List<ResultDescriptor> _UNIT_ERRORS = <ResultDescriptor>[ 44 static final List<ResultDescriptor<List<AnalysisError>>> _UNIT_ERRORS =
45 <ResultDescriptor<List<AnalysisError>>>[
44 HINTS, 46 HINTS,
45 LINTS, 47 LINTS,
46 LIBRARY_UNIT_ERRORS, 48 LIBRARY_UNIT_ERRORS,
47 RESOLVE_TYPE_NAMES_ERRORS, 49 RESOLVE_TYPE_NAMES_ERRORS,
48 RESOLVE_UNIT_ERRORS, 50 RESOLVE_UNIT_ERRORS,
49 STRONG_MODE_ERRORS, 51 STRONG_MODE_ERRORS,
50 VARIABLE_REFERENCE_ERRORS, 52 VARIABLE_REFERENCE_ERRORS,
51 VERIFY_ERRORS 53 VERIFY_ERRORS
52 ]; 54 ];
53 55
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 List<AnalysisError> getErrors(Source source) { 173 List<AnalysisError> getErrors(Source source) {
172 if (!_isDartSource(source) && source is! DartScript) { 174 if (!_isDartSource(source) && source is! DartScript) {
173 return AnalysisError.NO_ERRORS; 175 return AnalysisError.NO_ERRORS;
174 } 176 }
175 // If analysis is finished, use all the errors. 177 // If analysis is finished, use all the errors.
176 if (analysisCache.getState(source, DART_ERRORS) == CacheState.VALID) { 178 if (analysisCache.getState(source, DART_ERRORS) == CacheState.VALID) {
177 return analysisCache.getValue(source, DART_ERRORS); 179 return analysisCache.getValue(source, DART_ERRORS);
178 } 180 }
179 // If analysis is in progress, combine all known partial results. 181 // If analysis is in progress, combine all known partial results.
180 List<AnalysisError> errors = <AnalysisError>[]; 182 List<AnalysisError> errors = <AnalysisError>[];
181 for (ResultDescriptor descriptor in _SOURCE_ERRORS) { 183 for (ResultDescriptor<List<AnalysisError>> descriptor in _SOURCE_ERRORS) {
182 errors.addAll(analysisCache.getValue(source, descriptor)); 184 errors.addAll(analysisCache.getValue(source, descriptor));
183 } 185 }
184 for (Source library in context.getLibrariesContaining(source)) { 186 for (Source library in context.getLibrariesContaining(source)) {
185 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source); 187 LibrarySpecificUnit unit = new LibrarySpecificUnit(library, source);
186 for (ResultDescriptor descriptor in _UNIT_ERRORS) { 188 for (ResultDescriptor<List<AnalysisError>> descriptor in _UNIT_ERRORS) {
187 errors.addAll(analysisCache.getValue(unit, descriptor)); 189 errors.addAll(analysisCache.getValue(unit, descriptor));
188 } 190 }
189 } 191 }
190 return errors; 192 return errors;
191 } 193 }
192 194
193 /** 195 /**
194 * Returns libraries containing the given [part]. 196 * Returns libraries containing the given [part].
195 * Maybe empty, but not null. 197 * Maybe empty, but not null.
196 */ 198 */
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 if (needErrors) { 299 if (needErrors) {
298 librarySourceQueue.add(target); 300 librarySourceQueue.add(target);
299 } 301 }
300 } 302 }
301 } 303 }
302 } 304 }
303 } 305 }
304 // Update parts in libraries. 306 // Update parts in libraries.
305 if (isDartLibrarySource) { 307 if (isDartLibrarySource) {
306 Source library = target; 308 Source library = target;
307 List<Source> includedParts = outputs[INCLUDED_PARTS]; 309 List<Source> includedParts = outputs[INCLUDED_PARTS] as List<Source>;
308 if (includedParts != null) { 310 if (includedParts != null) {
309 libraryPartsMap[library] = includedParts; 311 libraryPartsMap[library] = includedParts;
310 for (Source part in includedParts) { 312 for (Source part in includedParts) {
311 List<Source> libraries = 313 List<Source> libraries =
312 partLibrariesMap.putIfAbsent(part, () => <Source>[]); 314 partLibrariesMap.putIfAbsent(part, () => <Source>[]);
313 if (!libraries.contains(library)) { 315 if (!libraries.contains(library)) {
314 libraries.add(library); 316 libraries.add(library);
315 _invalidateContainingLibraries(part); 317 _invalidateContainingLibraries(part);
316 } 318 }
317 } 319 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 } 475 }
474 } 476 }
475 477
476 bool _shouldErrorsBeComputed(Source source) => 478 bool _shouldErrorsBeComputed(Source source) =>
477 context.shouldErrorsBeAnalyzed(source); 479 context.shouldErrorsBeAnalyzed(source);
478 480
479 static bool _isDartSource(AnalysisTarget target) { 481 static bool _isDartSource(AnalysisTarget target) {
480 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 482 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
481 } 483 }
482 } 484 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/task/dart.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698