| OLD | NEW |
| 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 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 /** | 176 /** |
| 177 * Initialize a newly created server to receive requests from and send | 177 * Initialize a newly created server to receive requests from and send |
| 178 * responses to the given [channel]. | 178 * responses to the given [channel]. |
| 179 * | 179 * |
| 180 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are | 180 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are |
| 181 * propagated up the call stack. The default is true to allow analysis | 181 * propagated up the call stack. The default is true to allow analysis |
| 182 * exceptions to show up in unit tests, but it should be set to false when | 182 * exceptions to show up in unit tests, but it should be set to false when |
| 183 * running a full analysis server. | 183 * running a full analysis server. |
| 184 */ | 184 */ |
| 185 AnalysisServer(this.channel, this.resourceProvider, | 185 AnalysisServer(this.channel, this.resourceProvider, |
| 186 PackageMapProvider packageMapProvider, this.index, this.defaultSdk, | 186 PackageMapProvider packageMapProvider, this.index, |
| 187 AnalysisServerOptions analysisServerOptions, this.defaultSdk, |
| 187 {this.rethrowExceptions: true}) { | 188 {this.rethrowExceptions: true}) { |
| 188 searchEngine = createSearchEngine(index); | 189 searchEngine = createSearchEngine(index); |
| 189 operationQueue = new ServerOperationQueue(this); | 190 operationQueue = new ServerOperationQueue(this); |
| 190 contextDirectoryManager = | 191 contextDirectoryManager = |
| 191 new ServerContextManager(this, resourceProvider, packageMapProvider); | 192 new ServerContextManager(this, resourceProvider, packageMapProvider); |
| 193 contextDirectoryManager.defaultOptions.incremental = |
| 194 analysisServerOptions.enableIncrementalResolution; |
| 192 AnalysisEngine.instance.logger = new AnalysisLogger(); | 195 AnalysisEngine.instance.logger = new AnalysisLogger(); |
| 193 _onAnalysisStartedController = new StreamController.broadcast(); | 196 _onAnalysisStartedController = new StreamController.broadcast(); |
| 194 _onAnalysisCompleteController = new StreamController.broadcast(); | 197 _onAnalysisCompleteController = new StreamController.broadcast(); |
| 195 _onFileAnalyzedController = new StreamController.broadcast(); | 198 _onFileAnalyzedController = new StreamController.broadcast(); |
| 196 _onPriorityChangeController = | 199 _onPriorityChangeController = |
| 197 new StreamController<PriorityChangeEvent>.broadcast(); | 200 new StreamController<PriorityChangeEvent>.broadcast(); |
| 198 running = true; | 201 running = true; |
| 199 Notification notification = new ServerConnectedParams().toNotification(); | 202 Notification notification = new ServerConnectedParams().toNotification(); |
| 200 channel.sendNotification(notification); | 203 channel.sendNotification(notification); |
| 201 channel.listen(handleRequest, onDone: done, onError: error); | 204 channel.listen(handleRequest, onDone: done, onError: error); |
| (...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 906 // send the notification | 909 // send the notification |
| 907 channel.sendNotification( | 910 channel.sendNotification( |
| 908 new ServerErrorParams( | 911 new ServerErrorParams( |
| 909 true, | 912 true, |
| 910 exceptionString, | 913 exceptionString, |
| 911 stackTraceString).toNotification()); | 914 stackTraceString).toNotification()); |
| 912 } | 915 } |
| 913 } | 916 } |
| 914 | 917 |
| 915 | 918 |
| 919 class AnalysisServerOptions { |
| 920 bool enableIncrementalResolution = false; |
| 921 } |
| 922 |
| 916 /** | 923 /** |
| 917 * A [ContextsChangedEvent] indicate what contexts were added or removed. | 924 * A [ContextsChangedEvent] indicate what contexts were added or removed. |
| 918 * | 925 * |
| 919 * No context should be added to the event more than once. It does not make | 926 * No context should be added to the event more than once. It does not make |
| 920 * sense, for example, for a context to be both added and removed. | 927 * sense, for example, for a context to be both added and removed. |
| 921 */ | 928 */ |
| 922 class ContextsChangedEvent { | 929 class ContextsChangedEvent { |
| 923 | 930 |
| 924 /** | 931 /** |
| 925 * The contexts that were added to the server. | 932 * The contexts that were added to the server. |
| (...skipping 16 matching lines...) Expand all Loading... |
| 942 | 949 |
| 943 /** | 950 /** |
| 944 * A [PriorityChangeEvent] indicates the set the priority files has changed. | 951 * A [PriorityChangeEvent] indicates the set the priority files has changed. |
| 945 */ | 952 */ |
| 946 class PriorityChangeEvent { | 953 class PriorityChangeEvent { |
| 947 final Source firstSource; | 954 final Source firstSource; |
| 948 | 955 |
| 949 PriorityChangeEvent(this.firstSource); | 956 PriorityChangeEvent(this.firstSource); |
| 950 } | 957 } |
| 951 | 958 |
| 959 |
| 952 class ServerContextManager extends ContextManager { | 960 class ServerContextManager extends ContextManager { |
| 953 final AnalysisServer analysisServer; | 961 final AnalysisServer analysisServer; |
| 954 | 962 |
| 955 /** | 963 /** |
| 956 * The default options used to create new analysis contexts. | 964 * The default options used to create new analysis contexts. |
| 957 */ | 965 */ |
| 958 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 966 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 959 | 967 |
| 960 /** | 968 /** |
| 961 * The controller for sending [ContextsChangedEvent]s. | 969 * The controller for sending [ContextsChangedEvent]s. |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 * [packageUriResolver]. | 1031 * [packageUriResolver]. |
| 1024 */ | 1032 */ |
| 1025 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { | 1033 SourceFactory _createSourceFactory(UriResolver packageUriResolver) { |
| 1026 List<UriResolver> resolvers = <UriResolver>[ | 1034 List<UriResolver> resolvers = <UriResolver>[ |
| 1027 new DartUriResolver(analysisServer.defaultSdk), | 1035 new DartUriResolver(analysisServer.defaultSdk), |
| 1028 new ResourceUriResolver(resourceProvider), | 1036 new ResourceUriResolver(resourceProvider), |
| 1029 packageUriResolver]; | 1037 packageUriResolver]; |
| 1030 return new SourceFactory(resolvers); | 1038 return new SourceFactory(resolvers); |
| 1031 } | 1039 } |
| 1032 } | 1040 } |
| OLD | NEW |