| 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 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * An instance of [DirectoryBasedDartSdk] that is shared between | 31 * An instance of [DirectoryBasedDartSdk] that is shared between |
| 32 * [AnalysisServer] instances to improve performance. | 32 * [AnalysisServer] instances to improve performance. |
| 33 */ | 33 */ |
| 34 final DirectoryBasedDartSdk SHARED_SDK = DirectoryBasedDartSdk.defaultSdk; | 34 final DirectoryBasedDartSdk SHARED_SDK = DirectoryBasedDartSdk.defaultSdk; |
| 35 | 35 |
| 36 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { | 36 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { |
| 37 final AnalysisServer analysisServer; | 37 final AnalysisServer analysisServer; |
| 38 | 38 |
| 39 /** |
| 40 * The default options used to create new analysis contexts. |
| 41 */ |
| 42 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 43 |
| 39 AnalysisServerContextDirectoryManager(this.analysisServer, ResourceProvider re
sourceProvider) | 44 AnalysisServerContextDirectoryManager(this.analysisServer, ResourceProvider re
sourceProvider) |
| 40 : super(resourceProvider); | 45 : super(resourceProvider); |
| 41 | 46 |
| 42 @override | 47 @override |
| 43 void addContext(Folder folder, File pubspecFile) { | 48 void addContext(Folder folder, File pubspecFile) { |
| 44 ContextDirectory contextDirectory = new ContextDirectory( | 49 ContextDirectory contextDirectory = new ContextDirectory( |
| 45 analysisServer.defaultSdk, folder, pubspecFile); | 50 analysisServer.defaultSdk, folder, pubspecFile); |
| 46 analysisServer.folderMap[folder] = contextDirectory; | 51 analysisServer.folderMap[folder] = contextDirectory; |
| 47 analysisServer.schedulePerformAnalysisOperation(contextDirectory.context); | 52 AnalysisContext context = contextDirectory.context; |
| 53 context.analysisOptions = new AnalysisOptionsImpl.con1(defaultOptions); |
| 54 analysisServer.schedulePerformAnalysisOperation(context); |
| 48 } | 55 } |
| 49 | 56 |
| 50 @override | 57 @override |
| 51 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { | 58 void applyChangesToContext(Folder contextFolder, ChangeSet changeSet) { |
| 52 AnalysisContext context = analysisServer.folderMap[contextFolder].context; | 59 AnalysisContext context = analysisServer.folderMap[contextFolder].context; |
| 53 context.applyChanges(changeSet); | 60 context.applyChanges(changeSet); |
| 54 analysisServer.schedulePerformAnalysisOperation(context); | 61 analysisServer.schedulePerformAnalysisOperation(context); |
| 55 } | 62 } |
| 56 | 63 |
| 57 @override | 64 @override |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 AnalysisContext context = directory.context; | 210 AnalysisContext context = directory.context; |
| 204 List<Source> sourceList = sourceMap[context]; | 211 List<Source> sourceList = sourceMap[context]; |
| 205 if (sourceList == null) { | 212 if (sourceList == null) { |
| 206 sourceList = Source.EMPTY_ARRAY; | 213 sourceList = Source.EMPTY_ARRAY; |
| 207 } | 214 } |
| 208 context.analysisPriorityOrder = sourceList; | 215 context.analysisPriorityOrder = sourceList; |
| 209 }); | 216 }); |
| 210 } | 217 } |
| 211 | 218 |
| 212 /** | 219 /** |
| 220 * Use the given updaters to update the values of the options in every |
| 221 * existing analysis context. |
| 222 */ |
| 223 void updateOptions(List<OptionUpdater> optionUpdaters) { |
| 224 // |
| 225 // Update existing contexts. |
| 226 // |
| 227 folderMap.forEach((Folder folder, ContextDirectory directory) { |
| 228 AnalysisContext context = directory.context; |
| 229 AnalysisOptionsImpl options = new AnalysisOptionsImpl.con1(context.analysi
sOptions); |
| 230 optionUpdaters.forEach((OptionUpdater optionUpdater) { |
| 231 optionUpdater(options); |
| 232 }); |
| 233 context.analysisOptions = options; |
| 234 }); |
| 235 // |
| 236 // Update the defaults used to create new contexts. |
| 237 // |
| 238 AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions; |
| 239 optionUpdaters.forEach((OptionUpdater optionUpdater) { |
| 240 optionUpdater(options); |
| 241 }); |
| 242 } |
| 243 |
| 244 /** |
| 213 * Adds the given [ServerOperation] to the queue, but does not schedule | 245 * Adds the given [ServerOperation] to the queue, but does not schedule |
| 214 * operations execution. | 246 * operations execution. |
| 215 */ | 247 */ |
| 216 void addOperation(ServerOperation operation) { | 248 void addOperation(ServerOperation operation) { |
| 217 operationQueue.add(operation); | 249 operationQueue.add(operation); |
| 218 } | 250 } |
| 219 | 251 |
| 220 /** | 252 /** |
| 221 * The socket from which requests are being read has been closed. | 253 * The socket from which requests are being read has been closed. |
| 222 */ | 254 */ |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 // new PackageUriResolver(), | 565 // new PackageUriResolver(), |
| 534 ]); | 566 ]); |
| 535 } | 567 } |
| 536 | 568 |
| 537 /** | 569 /** |
| 538 * Return the [AnalysisContext] of this folder. | 570 * Return the [AnalysisContext] of this folder. |
| 539 */ | 571 */ |
| 540 AnalysisContext get context => _context; | 572 AnalysisContext get context => _context; |
| 541 } | 573 } |
| 542 | 574 |
| 575 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| 543 | 576 |
| 544 /** | 577 /** |
| 545 * An enumeration of the services provided by the server domain. | 578 * An enumeration of the services provided by the server domain. |
| 546 */ | 579 */ |
| 547 class ServerService extends Enum2<ServerService> { | 580 class ServerService extends Enum2<ServerService> { |
| 548 static const ServerService STATUS = const ServerService('STATUS', 0); | 581 static const ServerService STATUS = const ServerService('STATUS', 0); |
| 549 | 582 |
| 550 static const List<ServerService> VALUES = const [STATUS]; | 583 static const List<ServerService> VALUES = const [STATUS]; |
| 551 | 584 |
| 552 const ServerService(String name, int ordinal) : super(name, ordinal); | 585 const ServerService(String name, int ordinal) : super(name, ordinal); |
| 553 } | 586 } |
| OLD | NEW |