| 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:core'; | 6 import 'dart:core'; |
| 7 | 7 |
| 8 import 'package:analysis_server/plugin/analysis/analysis_domain.dart'; | |
| 9 import 'package:analysis_server/protocol/protocol_constants.dart'; | 8 import 'package:analysis_server/protocol/protocol_constants.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
| 11 import 'package:analysis_server/src/computer/computer_hover.dart'; | 10 import 'package:analysis_server/src/computer/computer_hover.dart'; |
| 12 import 'package:analysis_server/src/computer/imported_elements_computer.dart'; | 11 import 'package:analysis_server/src/computer/imported_elements_computer.dart'; |
| 13 import 'package:analysis_server/src/domain_abstract.dart'; | 12 import 'package:analysis_server/src/domain_abstract.dart'; |
| 14 import 'package:analysis_server/src/domains/analysis/navigation.dart'; | 13 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
| 15 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart'; | 14 import 'package:analysis_server/src/domains/analysis/navigation_dart.dart'; |
| 16 import 'package:analysis_server/src/plugin/plugin_manager.dart'; | 15 import 'package:analysis_server/src/plugin/plugin_manager.dart'; |
| 17 import 'package:analysis_server/src/plugin/request_converter.dart'; | 16 import 'package:analysis_server/src/plugin/request_converter.dart'; |
| 18 import 'package:analysis_server/src/plugin/result_merger.dart'; | 17 import 'package:analysis_server/src/plugin/result_merger.dart'; |
| 19 import 'package:analysis_server/src/protocol/protocol_internal.dart'; | 18 import 'package:analysis_server/src/protocol/protocol_internal.dart'; |
| 20 import 'package:analysis_server/src/protocol_server.dart'; | 19 import 'package:analysis_server/src/protocol_server.dart'; |
| 21 import 'package:analyzer/dart/ast/ast.dart'; | 20 import 'package:analyzer/dart/ast/ast.dart'; |
| 22 import 'package:analyzer/error/error.dart' as engine; | 21 import 'package:analyzer/error/error.dart' as engine; |
| 23 import 'package:analyzer/exception/exception.dart'; | |
| 24 import 'package:analyzer/file_system/file_system.dart'; | 22 import 'package:analyzer/file_system/file_system.dart'; |
| 25 import 'package:analyzer/src/dart/analysis/driver.dart'; | 23 import 'package:analyzer/src/dart/analysis/driver.dart'; |
| 26 import 'package:analyzer/src/generated/engine.dart' as engine; | 24 import 'package:analyzer/src/generated/engine.dart' as engine; |
| 27 import 'package:analyzer/src/generated/source.dart'; | 25 import 'package:analyzer/src/generated/source.dart'; |
| 28 import 'package:analyzer/task/model.dart' show ResultDescriptor; | |
| 29 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; | 26 import 'package:analyzer_plugin/protocol/protocol.dart' as plugin; |
| 30 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 27 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 31 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; | 28 import 'package:analyzer_plugin/protocol/protocol_constants.dart' as plugin; |
| 32 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; | 29 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; |
| 33 | 30 |
| 34 /** | 31 /** |
| 35 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] | 32 * Instances of the class [AnalysisDomainHandler] implement a [RequestHandler] |
| 36 * that handles requests in the `analysis` domain. | 33 * that handles requests in the `analysis` domain. |
| 37 */ | 34 */ |
| 38 class AnalysisDomainHandler extends AbstractRequestHandler { | 35 class AnalysisDomainHandler extends AbstractRequestHandler { |
| 39 /** | 36 /** |
| 40 * Initialize a newly created handler to handle requests for the given [server
]. | 37 * Initialize a newly created handler to handle requests for the given [server
]. |
| 41 */ | 38 */ |
| 42 AnalysisDomainHandler(AnalysisServer server) : super(server) { | 39 AnalysisDomainHandler(AnalysisServer server) : super(server); |
| 43 _callAnalysisDomainReceivers(); | |
| 44 } | |
| 45 | 40 |
| 46 /** | 41 /** |
| 47 * Implement the `analysis.getErrors` request. | 42 * Implement the `analysis.getErrors` request. |
| 48 */ | 43 */ |
| 49 Future<Null> getErrors(Request request) async { | 44 Future<Null> getErrors(Request request) async { |
| 50 String file = new AnalysisGetErrorsParams.fromRequest(request).file; | 45 String file = new AnalysisGetErrorsParams.fromRequest(request).file; |
| 51 | 46 |
| 52 void send(engine.AnalysisOptions analysisOptions, LineInfo lineInfo, | 47 void send(engine.AnalysisOptions analysisOptions, LineInfo lineInfo, |
| 53 List<engine.AnalysisError> errors) { | 48 List<engine.AnalysisError> errors) { |
| 54 if (lineInfo == null) { | 49 if (lineInfo == null) { |
| (...skipping 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 }); | 422 }); |
| 428 } | 423 } |
| 429 if (newOptions.enableSuperMixins != null) { | 424 if (newOptions.enableSuperMixins != null) { |
| 430 updaters.add((engine.AnalysisOptionsImpl options) { | 425 updaters.add((engine.AnalysisOptionsImpl options) { |
| 431 options.enableSuperMixins = newOptions.enableSuperMixins; | 426 options.enableSuperMixins = newOptions.enableSuperMixins; |
| 432 }); | 427 }); |
| 433 } | 428 } |
| 434 server.updateOptions(updaters); | 429 server.updateOptions(updaters); |
| 435 return new AnalysisUpdateOptionsResult().toResponse(request.id); | 430 return new AnalysisUpdateOptionsResult().toResponse(request.id); |
| 436 } | 431 } |
| 437 | |
| 438 /** | |
| 439 * Call all the registered [SetAnalysisDomain] functions. | |
| 440 */ | |
| 441 void _callAnalysisDomainReceivers() { | |
| 442 AnalysisDomain analysisDomain = new AnalysisDomainImpl(server); | |
| 443 for (SetAnalysisDomain function | |
| 444 in server.serverPlugin.setAnalysisDomainFunctions) { | |
| 445 try { | |
| 446 function(analysisDomain); | |
| 447 } catch (exception, stackTrace) { | |
| 448 engine.AnalysisEngine.instance.logger.logError( | |
| 449 'Exception from analysis domain receiver: ${function.runtimeType}', | |
| 450 new CaughtException(exception, stackTrace)); | |
| 451 } | |
| 452 } | |
| 453 } | |
| 454 } | 432 } |
| 455 | |
| 456 /** | |
| 457 * An implementation of [AnalysisDomain] for [AnalysisServer]. | |
| 458 */ | |
| 459 class AnalysisDomainImpl implements AnalysisDomain { | |
| 460 final AnalysisServer server; | |
| 461 | |
| 462 final Map<ResultDescriptor, StreamController<engine.ResultChangedEvent>> | |
| 463 controllers = | |
| 464 <ResultDescriptor, StreamController<engine.ResultChangedEvent>>{}; | |
| 465 | |
| 466 AnalysisDomainImpl(this.server) { | |
| 467 // TODO(brianwilkerson) The onContextsChanged stream is no longer written to
. | |
| 468 // Figure out whether this code still needs to be here and convert it to use | |
| 469 // the analysis driver if it does. | |
| 470 // server.onContextsChanged.listen((ContextsChangedEvent event) { | |
| 471 // event.added.forEach(_subscribeForContext); | |
| 472 // }); | |
| 473 } | |
| 474 } | |
| OLD | NEW |