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

Side by Side Diff: pkg/analyzer/lib/src/context/context.dart

Issue 1448173002: Add ApplyChangesStatus to AnalysisContext.applyChanges() and use it in DAS. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
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.context.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/instrumentation/instrumentation.dart'; 10 import 'package:analyzer/instrumentation/instrumentation.dart';
(...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 if (level == AnalysisLevel.NONE) { 515 if (level == AnalysisLevel.NONE) {
516 changeSet.removedSource(source); 516 changeSet.removedSource(source);
517 } else { 517 } else {
518 changeSet.addedSource(source); 518 changeSet.addedSource(source);
519 } 519 }
520 }); 520 });
521 applyChanges(changeSet); 521 applyChanges(changeSet);
522 } 522 }
523 523
524 @override 524 @override
525 void applyChanges(ChangeSet changeSet) { 525 ApplyChangesStatus applyChanges(ChangeSet changeSet) {
526 if (changeSet.isEmpty) { 526 if (changeSet.isEmpty) {
527 return; 527 return new ApplyChangesStatus(false);
528 } 528 }
529 // 529 //
530 // First, compute the list of sources that have been removed. 530 // First, compute the list of sources that have been removed.
531 // 531 //
532 List<Source> removedSources = 532 List<Source> removedSources = changeSet.removedSources.toList();
533 new List<Source>.from(changeSet.removedSources);
534 for (SourceContainer container in changeSet.removedContainers) { 533 for (SourceContainer container in changeSet.removedContainers) {
535 _addSourcesInContainer(removedSources, container); 534 _addSourcesInContainer(removedSources, container);
536 } 535 }
537 // 536 //
538 // Then determine which cached results are no longer valid. 537 // Then determine which cached results are no longer valid.
539 // 538 //
540 for (Source source in changeSet.addedSources) { 539 for (Source source in changeSet.addedSources) {
541 _sourceAvailable(source); 540 _sourceAvailable(source);
542 } 541 }
543 for (Source source in changeSet.changedSources) { 542 // Exclude sources that are overridden in the content cache, so the change
544 if (_contentCache.getContents(source) != null) { 543 // will have no effect. Just ignore it to avoid wasting time doing
545 // This source is overridden in the content cache, so the change will 544 // re-analysis.
546 // have no effect. Just ignore it to avoid wasting time doing 545 List<Source> changedSources = changeSet.changedSources
547 // re-analysis. 546 .where((s) => _contentCache.getContents(s) == null)
548 continue; 547 .toList();
549 } 548 for (Source source in changedSources) {
Brian Wilkerson 2015/11/16 23:19:32 I don't see why this is better. It creates more ob
550 _sourceChanged(source); 549 _sourceChanged(source);
551 } 550 }
552 changeSet.changedContents.forEach((Source key, String value) { 551 changeSet.changedContents.forEach((Source key, String value) {
553 _contentsChanged(key, value, false); 552 _contentsChanged(key, value, false);
554 }); 553 });
555 changeSet.changedRanges 554 changeSet.changedRanges
556 .forEach((Source source, ChangeSet_ContentChange change) { 555 .forEach((Source source, ChangeSet_ContentChange change) {
557 _contentRangeChanged(source, change.contents, change.offset, 556 _contentRangeChanged(source, change.contents, change.offset,
558 change.oldLength, change.newLength); 557 change.oldLength, change.newLength);
559 }); 558 });
560 for (Source source in changeSet.deletedSources) { 559 for (Source source in changeSet.deletedSources) {
561 _sourceDeleted(source); 560 _sourceDeleted(source);
562 } 561 }
563 for (Source source in removedSources) { 562 for (Source source in removedSources) {
564 _sourceRemoved(source); 563 _sourceRemoved(source);
565 } 564 }
566 for (WorkManager workManager in workManagers) { 565 for (WorkManager workManager in workManagers) {
567 workManager.applyChange( 566 workManager.applyChange(
568 changeSet.addedSources, changeSet.changedSources, removedSources); 567 changeSet.addedSources, changedSources, removedSources);
569 } 568 }
570 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet)); 569 _onSourcesChangedController.add(new SourcesChangedEvent(changeSet));
570 return new ApplyChangesStatus(changeSet.addedSources.isNotEmpty ||
571 changeSet.changedContents.isNotEmpty ||
572 changeSet.deletedSources.isNotEmpty ||
573 changedSources.isNotEmpty ||
574 removedSources.isNotEmpty);
571 } 575 }
572 576
573 @override 577 @override
574 String computeDocumentationComment(Element element) { 578 String computeDocumentationComment(Element element) {
575 if (element == null) { 579 if (element == null) {
576 return null; 580 return null;
577 } 581 }
578 Source source = element.source; 582 Source source = element.source;
579 if (source == null) { 583 if (source == null) {
580 return null; 584 return null;
(...skipping 1560 matching lines...) Expand 10 before | Expand all | Expand 10 after
2141 DartSdk sdk = factory.dartSdk; 2145 DartSdk sdk = factory.dartSdk;
2142 if (sdk == null) { 2146 if (sdk == null) {
2143 throw new IllegalArgumentException( 2147 throw new IllegalArgumentException(
2144 "The source factory for an SDK analysis context must have a DartUriRes olver"); 2148 "The source factory for an SDK analysis context must have a DartUriRes olver");
2145 } 2149 }
2146 return new AnalysisCache(<CachePartition>[ 2150 return new AnalysisCache(<CachePartition>[
2147 AnalysisEngine.instance.partitionManager_new.forSdk(sdk) 2151 AnalysisEngine.instance.partitionManager_new.forSdk(sdk)
2148 ]); 2152 ]);
2149 } 2153 }
2150 } 2154 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698