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

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 847663005: Send notifications using separate server operations. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/computer/computer_outline.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) 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 analysis.server; 5 library analysis.server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/analysis_logger.dart'; 10 import 'package:analysis_server/src/analysis_logger.dart';
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are 191 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are
192 * propagated up the call stack. The default is true to allow analysis 192 * propagated up the call stack. The default is true to allow analysis
193 * exceptions to show up in unit tests, but it should be set to false when 193 * exceptions to show up in unit tests, but it should be set to false when
194 * running a full analysis server. 194 * running a full analysis server.
195 */ 195 */
196 AnalysisServer(this.channel, this.resourceProvider, 196 AnalysisServer(this.channel, this.resourceProvider,
197 PackageMapProvider packageMapProvider, this.index, 197 PackageMapProvider packageMapProvider, this.index,
198 AnalysisServerOptions analysisServerOptions, this.defaultSdk, 198 AnalysisServerOptions analysisServerOptions, this.defaultSdk,
199 this.instrumentationService, {this.rethrowExceptions: true}) { 199 this.instrumentationService, {this.rethrowExceptions: true}) {
200 searchEngine = createSearchEngine(index); 200 searchEngine = createSearchEngine(index);
201 operationQueue = new ServerOperationQueue(this); 201 operationQueue = new ServerOperationQueue();
202 contextDirectoryManager = 202 contextDirectoryManager =
203 new ServerContextManager(this, resourceProvider, packageMapProvider); 203 new ServerContextManager(this, resourceProvider, packageMapProvider);
204 contextDirectoryManager.defaultOptions.incremental = true; 204 contextDirectoryManager.defaultOptions.incremental = true;
205 contextDirectoryManager.defaultOptions.incrementalApi = 205 contextDirectoryManager.defaultOptions.incrementalApi =
206 analysisServerOptions.enableIncrementalResolutionApi; 206 analysisServerOptions.enableIncrementalResolutionApi;
207 contextDirectoryManager.defaultOptions.incrementalValidation = 207 contextDirectoryManager.defaultOptions.incrementalValidation =
208 analysisServerOptions.enableIncrementalResolutionValidation; 208 analysisServerOptions.enableIncrementalResolutionValidation;
209 _noErrorNotification = analysisServerOptions.noErrorNotification; 209 _noErrorNotification = analysisServerOptions.noErrorNotification;
210 AnalysisEngine.instance.logger = new AnalysisLogger(); 210 AnalysisEngine.instance.logger = new AnalysisLogger();
211 _onAnalysisStartedController = new StreamController.broadcast(); 211 _onAnalysisStartedController = new StreamController.broadcast();
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
532 } 532 }
533 533
534 /** 534 /**
535 * Return `true` if analysis is complete. 535 * Return `true` if analysis is complete.
536 */ 536 */
537 bool isAnalysisComplete() { 537 bool isAnalysisComplete() {
538 return operationQueue.isEmpty; 538 return operationQueue.isEmpty;
539 } 539 }
540 540
541 /** 541 /**
542 * Returns `true` if the given [AnalysisContext] is a priority one.
543 */
544 bool isPriorityContext(AnalysisContext context) {
545 // TODO(scheglov) implement support for priority sources/contexts
546 return false;
547 }
548
549 /**
550 * Returns a [Future] completing when [file] has been completely analyzed, in 542 * Returns a [Future] completing when [file] has been completely analyzed, in
551 * particular, all its errors have been computed. The future is completed 543 * particular, all its errors have been computed. The future is completed
552 * with an [AnalysisDoneReason] indicating what caused the file's analysis to 544 * with an [AnalysisDoneReason] indicating what caused the file's analysis to
553 * be considered complete. 545 * be considered complete.
554 * 546 *
555 * If the given file doesn't belong to any context, null is returned. 547 * If the given file doesn't belong to any context, null is returned.
556 * 548 *
557 * TODO(scheglov) this method should be improved. 549 * TODO(scheglov) this method should be improved.
558 * 550 *
559 * 1. The analysis context should be told to analyze this particular file ASAP . 551 * 1. The analysis context should be told to analyze this particular file ASAP .
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
642 if (!performOperationPending) { 634 if (!performOperationPending) {
643 _schedulePerformOperation(); 635 _schedulePerformOperation();
644 } 636 }
645 } 637 }
646 638
647 /** 639 /**
648 * Schedules analysis of the given context. 640 * Schedules analysis of the given context.
649 */ 641 */
650 void schedulePerformAnalysisOperation(AnalysisContext context) { 642 void schedulePerformAnalysisOperation(AnalysisContext context) {
651 _onAnalysisStartedController.add(context); 643 _onAnalysisStartedController.add(context);
652 scheduleOperation(new PerformAnalysisOperation(context, false)); 644 bool isPriority = _isPriorityContext(context);
645 scheduleOperation(new PerformAnalysisOperation(context, isPriority, false));
653 } 646 }
654 647
655 /** 648 /**
656 * This method is called when analysis of the given [AnalysisContext] is 649 * This method is called when analysis of the given [AnalysisContext] is
657 * done. 650 * done.
658 */ 651 */
659 void sendContextAnalysisDoneNotifications(AnalysisContext context, 652 void sendContextAnalysisDoneNotifications(AnalysisContext context,
660 AnalysisDoneReason reason) { 653 AnalysisDoneReason reason) {
661 Completer<AnalysisDoneReason> completer = 654 Completer<AnalysisDoneReason> completer =
662 contextAnalysisDoneCompleters.remove(context); 655 contextAnalysisDoneCompleters.remove(context);
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 break; 771 break;
779 case AnalysisService.NAVIGATION: 772 case AnalysisService.NAVIGATION:
780 // TODO(scheglov) consider support for one unit in 2+ libraries 773 // TODO(scheglov) consider support for one unit in 2+ libraries
781 sendAnalysisNotificationNavigation(this, file, dartUnit); 774 sendAnalysisNotificationNavigation(this, file, dartUnit);
782 break; 775 break;
783 case AnalysisService.OCCURRENCES: 776 case AnalysisService.OCCURRENCES:
784 sendAnalysisNotificationOccurrences(this, file, dartUnit); 777 sendAnalysisNotificationOccurrences(this, file, dartUnit);
785 break; 778 break;
786 case AnalysisService.OUTLINE: 779 case AnalysisService.OUTLINE:
787 LineInfo lineInfo = context.getLineInfo(source); 780 LineInfo lineInfo = context.getLineInfo(source);
788 sendAnalysisNotificationOutline( 781 sendAnalysisNotificationOutline(this, file, lineInfo, dartUnit);
789 this,
790 source,
791 lineInfo,
792 dartUnit);
793 break; 782 break;
794 case AnalysisService.OVERRIDES: 783 case AnalysisService.OVERRIDES:
795 sendAnalysisNotificationOverrides(this, file, dartUnit); 784 sendAnalysisNotificationOverrides(this, file, dartUnit);
796 break; 785 break;
797 } 786 }
798 } 787 }
799 } 788 }
800 } 789 }
801 }); 790 });
802 // remember new subscriptions 791 // remember new subscriptions
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
927 // 916 //
928 // Update the defaults used to create new contexts. 917 // Update the defaults used to create new contexts.
929 // 918 //
930 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions; 919 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions;
931 optionUpdaters.forEach((OptionUpdater optionUpdater) { 920 optionUpdaters.forEach((OptionUpdater optionUpdater) {
932 optionUpdater(options); 921 optionUpdater(options);
933 }); 922 });
934 } 923 }
935 924
936 /** 925 /**
926 * Returns `true` if the given [AnalysisContext] is a priority one.
927 */
928 bool _isPriorityContext(AnalysisContext context) {
929 // TODO(scheglov) implement support for priority sources/contexts
930 return false;
931 }
932
933 /**
937 * Schedules [performOperation] exection. 934 * Schedules [performOperation] exection.
938 */ 935 */
939 void _schedulePerformOperation() { 936 void _schedulePerformOperation() {
940 assert(!performOperationPending); 937 assert(!performOperationPending);
941 new Future(performOperation); 938 new Future(performOperation);
942 performOperationPending = true; 939 performOperationPending = true;
943 } 940 }
944 } 941 }
945 942
946 943
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1080 * [packageUriResolver]. 1077 * [packageUriResolver].
1081 */ 1078 */
1082 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { 1079 SourceFactory _createSourceFactory(UriResolver packageUriResolver) {
1083 List<UriResolver> resolvers = <UriResolver>[ 1080 List<UriResolver> resolvers = <UriResolver>[
1084 new DartUriResolver(analysisServer.defaultSdk), 1081 new DartUriResolver(analysisServer.defaultSdk),
1085 new ResourceUriResolver(resourceProvider), 1082 new ResourceUriResolver(resourceProvider),
1086 packageUriResolver]; 1083 packageUriResolver];
1087 return new SourceFactory(resolvers); 1084 return new SourceFactory(resolvers);
1088 } 1085 }
1089 } 1086 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/computer/computer_outline.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698