| 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 import 'dart:math' show max; | 9 import 'dart:math' show max; |
| 10 | 10 |
| 11 import 'package:analysis_server/src/analysis_logger.dart'; | 11 import 'package:analysis_server/src/analysis_logger.dart'; |
| 12 import 'package:analysis_server/src/channel/channel.dart'; | 12 import 'package:analysis_server/src/channel/channel.dart'; |
| 13 import 'package:analysis_server/src/context_manager.dart'; | 13 import 'package:analysis_server/src/context_manager.dart'; |
| 14 import 'package:analysis_server/src/operation/operation.dart'; | 14 import 'package:analysis_server/src/operation/operation.dart'; |
| 15 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 15 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
| 16 import 'package:analysis_server/src/operation/operation_queue.dart'; | 16 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| 17 import 'package:analysis_server/src/protocol.dart' hide Element; | 17 import 'package:analysis_server/src/protocol.dart' hide Element; |
| 18 import 'package:analysis_server/src/services/correction/namespace.dart'; | 18 import 'package:analysis_server/src/services/correction/namespace.dart'; |
| 19 import 'package:analysis_server/src/services/index/index.dart'; | 19 import 'package:analysis_server/src/services/index/index.dart'; |
| 20 import 'package:analysis_server/src/services/search/search_engine.dart'; | 20 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 21 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d
art'; |
| 21 import 'package:analyzer/file_system/file_system.dart'; | 22 import 'package:analyzer/file_system/file_system.dart'; |
| 22 import 'package:analyzer/instrumentation/instrumentation.dart'; | 23 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 23 import 'package:analyzer/plugin/plugin.dart'; | 24 import 'package:analyzer/plugin/plugin.dart'; |
| 24 import 'package:analyzer/source/package_map_provider.dart'; | |
| 25 import 'package:analyzer/src/generated/ast.dart'; | 25 import 'package:analyzer/src/generated/ast.dart'; |
| 26 import 'package:analyzer/src/generated/element.dart'; | 26 import 'package:analyzer/src/generated/element.dart'; |
| 27 import 'package:analyzer/src/generated/engine.dart'; | 27 import 'package:analyzer/src/generated/engine.dart'; |
| 28 import 'package:analyzer/src/generated/java_engine.dart'; | 28 import 'package:analyzer/src/generated/java_engine.dart'; |
| 29 import 'package:analyzer/src/generated/sdk.dart'; | 29 import 'package:analyzer/src/generated/sdk.dart'; |
| 30 import 'package:analyzer/src/generated/source.dart'; | 30 import 'package:analyzer/src/generated/source.dart'; |
| 31 import 'package:analyzer/src/generated/source_io.dart'; | 31 import 'package:analyzer/src/generated/source_io.dart'; |
| 32 import 'package:analyzer/src/generated/utilities_general.dart'; | 32 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 33 | 33 |
| 34 typedef void OptionUpdater(AnalysisOptionsImpl options); | 34 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 /** | 242 /** |
| 243 * Initialize a newly created server to receive requests from and send | 243 * Initialize a newly created server to receive requests from and send |
| 244 * responses to the given [channel]. | 244 * responses to the given [channel]. |
| 245 * | 245 * |
| 246 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are | 246 * If [rethrowExceptions] is true, then any exceptions thrown by analysis are |
| 247 * propagated up the call stack. The default is true to allow analysis | 247 * propagated up the call stack. The default is true to allow analysis |
| 248 * exceptions to show up in unit tests, but it should be set to false when | 248 * exceptions to show up in unit tests, but it should be set to false when |
| 249 * running a full analysis server. | 249 * running a full analysis server. |
| 250 */ | 250 */ |
| 251 AnalysisServer(this.channel, this.resourceProvider, | 251 AnalysisServer(this.channel, this.resourceProvider, |
| 252 PackageMapProvider packageMapProvider, Index _index, | 252 OptimizingPubPackageMapProvider packageMapProvider, Index _index, |
| 253 AnalysisServerOptions analysisServerOptions, this.defaultSdk, | 253 AnalysisServerOptions analysisServerOptions, this.defaultSdk, |
| 254 this.instrumentationService, {this.rethrowExceptions: true}) | 254 this.instrumentationService, {this.rethrowExceptions: true}) |
| 255 : index = _index, | 255 : index = _index, |
| 256 searchEngine = _index != null ? createSearchEngine(_index) : null { | 256 searchEngine = _index != null ? createSearchEngine(_index) : null { |
| 257 _performance = performanceDuringStartup; | 257 _performance = performanceDuringStartup; |
| 258 operationQueue = new ServerOperationQueue(); | 258 operationQueue = new ServerOperationQueue(); |
| 259 contextDirectoryManager = new ServerContextManager( | 259 contextDirectoryManager = new ServerContextManager( |
| 260 this, resourceProvider, packageMapProvider, instrumentationService); | 260 this, resourceProvider, packageMapProvider, instrumentationService); |
| 261 contextDirectoryManager.defaultOptions.incremental = true; | 261 contextDirectoryManager.defaultOptions.incremental = true; |
| 262 contextDirectoryManager.defaultOptions.incrementalApi = | 262 contextDirectoryManager.defaultOptions.incrementalApi = |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1154 } | 1154 } |
| 1155 | 1155 |
| 1156 /** | 1156 /** |
| 1157 * Return a set of contexts containing all of the resources in the given list | 1157 * Return a set of contexts containing all of the resources in the given list |
| 1158 * of [resources]. | 1158 * of [resources]. |
| 1159 */ | 1159 */ |
| 1160 Set<AnalysisContext> _getContexts(List<Resource> resources) { | 1160 Set<AnalysisContext> _getContexts(List<Resource> resources) { |
| 1161 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); | 1161 Set<AnalysisContext> contexts = new HashSet<AnalysisContext>(); |
| 1162 resources.forEach((Resource resource) { | 1162 resources.forEach((Resource resource) { |
| 1163 if (resource is Folder) { | 1163 if (resource is Folder) { |
| 1164 contexts.addAll(contextDirectoryManager.contextsInAnalysisRoot(resource)
); | 1164 contexts |
| 1165 .addAll(contextDirectoryManager.contextsInAnalysisRoot(resource)); |
| 1165 } | 1166 } |
| 1166 }); | 1167 }); |
| 1167 return contexts; | 1168 return contexts; |
| 1168 } | 1169 } |
| 1169 | 1170 |
| 1170 /** | 1171 /** |
| 1171 * Returns the [CompilationUnit] of the Dart file with the given [source] that | 1172 * Returns the [CompilationUnit] of the Dart file with the given [source] that |
| 1172 * should be used to resend notifications for already resolved unit. | 1173 * should be used to resend notifications for already resolved unit. |
| 1173 * Returns `null` if the file is not a part of any context, library has not | 1174 * Returns `null` if the file is not a part of any context, library has not |
| 1174 * been yet resolved, or any problem happened. | 1175 * been yet resolved, or any problem happened. |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1292 * The default options used to create new analysis contexts. | 1293 * The default options used to create new analysis contexts. |
| 1293 */ | 1294 */ |
| 1294 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); | 1295 AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl(); |
| 1295 | 1296 |
| 1296 /** | 1297 /** |
| 1297 * The controller for sending [ContextsChangedEvent]s. | 1298 * The controller for sending [ContextsChangedEvent]s. |
| 1298 */ | 1299 */ |
| 1299 StreamController<ContextsChangedEvent> _onContextsChangedController; | 1300 StreamController<ContextsChangedEvent> _onContextsChangedController; |
| 1300 | 1301 |
| 1301 ServerContextManager(this.analysisServer, ResourceProvider resourceProvider, | 1302 ServerContextManager(this.analysisServer, ResourceProvider resourceProvider, |
| 1302 PackageMapProvider packageMapProvider, InstrumentationService service) | 1303 OptimizingPubPackageMapProvider packageMapProvider, |
| 1304 InstrumentationService service) |
| 1303 : super(resourceProvider, packageMapProvider, service) { | 1305 : super(resourceProvider, packageMapProvider, service) { |
| 1304 _onContextsChangedController = | 1306 _onContextsChangedController = |
| 1305 new StreamController<ContextsChangedEvent>.broadcast(); | 1307 new StreamController<ContextsChangedEvent>.broadcast(); |
| 1306 } | 1308 } |
| 1307 | 1309 |
| 1308 /** | 1310 /** |
| 1309 * The stream that is notified when contexts are added or removed. | 1311 * The stream that is notified when contexts are added or removed. |
| 1310 */ | 1312 */ |
| 1311 Stream<ContextsChangedEvent> get onContextsChanged => | 1313 Stream<ContextsChangedEvent> get onContextsChanged => |
| 1312 _onContextsChangedController.stream; | 1314 _onContextsChangedController.stream; |
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1497 /** | 1499 /** |
| 1498 * The [PerformanceTag] for time spent in server request handlers. | 1500 * The [PerformanceTag] for time spent in server request handlers. |
| 1499 */ | 1501 */ |
| 1500 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); | 1502 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); |
| 1501 | 1503 |
| 1502 /** | 1504 /** |
| 1503 * The [PerformanceTag] for time spent in split store microtasks. | 1505 * The [PerformanceTag] for time spent in split store microtasks. |
| 1504 */ | 1506 */ |
| 1505 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1507 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
| 1506 } | 1508 } |
| OLD | NEW |