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

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

Issue 1179173005: Schedule unknown priority source analysis. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | pkg/analyzer/test/src/task/dart_work_manager_test.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 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 for (TargetedResult result in priorityResultQueue) { 151 for (TargetedResult result in priorityResultQueue) {
152 if (result.result == LIBRARY_ERRORS_READY) { 152 if (result.result == LIBRARY_ERRORS_READY) {
153 resultsToUnschedule.add(result); 153 resultsToUnschedule.add(result);
154 } 154 }
155 } 155 }
156 priorityResultQueue.removeAll(resultsToUnschedule); 156 priorityResultQueue.removeAll(resultsToUnschedule);
157 // Schedule new targets. 157 // Schedule new targets.
158 for (AnalysisTarget target in targets) { 158 for (AnalysisTarget target in targets) {
159 if (_isDartSource(target)) { 159 if (_isDartSource(target)) {
160 SourceKind sourceKind = analysisCache.getValue(target, SOURCE_KIND); 160 SourceKind sourceKind = analysisCache.getValue(target, SOURCE_KIND);
161 if (sourceKind == SourceKind.LIBRARY) { 161 if (sourceKind == SourceKind.UNKNOWN) {
162 addPriorityResult(target, LIBRARY_ERRORS_READY); 162 addPriorityResult(target, SOURCE_KIND);
163 } else if (sourceKind == SourceKind.LIBRARY) {
164 _schedulePriorityLibrarySourceAnalysis(target);
163 } else if (sourceKind == SourceKind.PART) { 165 } else if (sourceKind == SourceKind.PART) {
164 List<Source> libraries = context.getLibrariesContaining(target); 166 List<Source> libraries = context.getLibrariesContaining(target);
165 for (Source library in libraries) { 167 for (Source library in libraries) {
166 addPriorityResult(library, LIBRARY_ERRORS_READY); 168 addPriorityResult(library, LIBRARY_ERRORS_READY);
167 } 169 }
168 } 170 }
169 } 171 }
170 } 172 }
171 } 173 }
172 174
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 */ 264 */
263 void onSourceFactoryChanged() { 265 void onSourceFactoryChanged() {
264 _invalidateAllLocalResolutionInformation(true); 266 _invalidateAllLocalResolutionInformation(true);
265 } 267 }
266 268
267 @override 269 @override
268 void resultsComputed( 270 void resultsComputed(
269 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) { 271 AnalysisTarget target, Map<ResultDescriptor, dynamic> outputs) {
270 // Organize sources. 272 // Organize sources.
271 if (_isDartSource(target)) { 273 if (_isDartSource(target)) {
274 Source source = target;
272 SourceKind kind = outputs[SOURCE_KIND]; 275 SourceKind kind = outputs[SOURCE_KIND];
273 if (kind != null) { 276 if (kind != null) {
274 unknownSourceQueue.remove(target); 277 unknownSourceQueue.remove(source);
275 if (kind == SourceKind.LIBRARY && 278 if (kind == SourceKind.LIBRARY) {
276 context.shouldErrorsBeAnalyzed(target, null)) { 279 if (context.prioritySources.contains(source)) {
277 librarySourceQueue.add(target); 280 _schedulePriorityLibrarySourceAnalysis(source);
281 } else {
282 bool needErrors = _shouldErrorsBeComputed(source);
283 if (needErrors) {
284 librarySourceQueue.add(target);
285 }
286 }
278 } 287 }
279 } 288 }
280 } 289 }
281 // Update parts in libraries. 290 // Update parts in libraries.
282 if (_isDartSource(target)) { 291 if (_isDartSource(target)) {
283 Source library = target; 292 Source library = target;
284 List<Source> includedParts = outputs[INCLUDED_PARTS]; 293 List<Source> includedParts = outputs[INCLUDED_PARTS];
285 if (includedParts != null) { 294 if (includedParts != null) {
286 libraryPartsMap[library] = includedParts; 295 libraryPartsMap[library] = includedParts;
287 for (Source part in includedParts) { 296 for (Source part in includedParts) {
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 List<Source> libraries = partLibrariesMap[part]; 416 List<Source> libraries = partLibrariesMap[part];
408 if (libraries != null) { 417 if (libraries != null) {
409 libraries.remove(library); 418 libraries.remove(library);
410 _invalidateContainingLibraries(part); 419 _invalidateContainingLibraries(part);
411 } 420 }
412 } 421 }
413 } 422 }
414 _invalidateContainingLibraries(library); 423 _invalidateContainingLibraries(library);
415 } 424 }
416 425
426 /**
427 * Schedule computing [RESOLVED_UNIT] for the given [librarySource].
428 * If errors should be computed, then schedule [LIBRARY_ERRORS_READY] instead,
429 * it also computes [RESOLVED_UNIT] in process.
430 */
431 void _schedulePriorityLibrarySourceAnalysis(Source librarySource) {
432 bool needErrors = _shouldErrorsBeComputed(librarySource);
433 if (needErrors) {
434 addPriorityResult(librarySource, LIBRARY_ERRORS_READY);
435 } else {
436 var target = new LibrarySpecificUnit(librarySource, librarySource);
437 addPriorityResult(target, RESOLVED_UNIT);
438 }
439 }
440
441 bool _shouldErrorsBeComputed(Source source) =>
442 context.shouldErrorsBeAnalyzed(source, null);
443
417 static bool _isDartSource(AnalysisTarget target) { 444 static bool _isDartSource(AnalysisTarget target) {
418 return target is Source && AnalysisEngine.isDartFileName(target.fullName); 445 return target is Source && AnalysisEngine.isDartFileName(target.fullName);
419 } 446 }
420 } 447 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/test/src/task/dart_work_manager_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698