| 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:analyzer/file_system/file_system.dart'; | 10 import 'package:analyzer/file_system/file_system.dart'; |
| 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.dart'; | 12 import 'package:analysis_server/src/channel.dart'; |
| 13 import 'package:analysis_server/src/constants.dart'; | 13 import 'package:analysis_server/src/constants.dart'; |
| 14 import 'package:analysis_server/src/context_manager.dart'; | 14 import 'package:analysis_server/src/context_manager.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.dart'; | 16 import 'package:analysis_server/src/operation/operation.dart'; |
| 17 import 'package:analysis_server/src/operation/operation_queue.dart'; | 17 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| 18 import 'package:analysis_server/src/package_map_provider.dart'; | 18 import 'package:analysis_server/src/package_map_provider.dart'; |
| 19 import 'package:analysis_server/src/protocol.dart'; | 19 import 'package:analysis_server/src/protocol.dart'; |
| 20 import 'package:analysis_server/src/protocol2.dart' show AnalysisService, | 20 import 'package:analysis_server/src/protocol2.dart' show AddContentOverlay, |
| 21 ServerService, AddContentOverlay, ChangeContentOverlay, | 21 AnalysisService, AnalysisStatus, ChangeContentOverlay, |
| 22 RemoveContentOverlay, SourceEdit; | 22 RemoveContentOverlay, ServerErrorParams, ServerService, ServerStatusParams, |
| 23 SourceEdit; |
| 23 import 'package:analyzer/source/package_map_resolver.dart'; | 24 import 'package:analyzer/source/package_map_resolver.dart'; |
| 24 import 'package:analyzer/src/generated/ast.dart'; | 25 import 'package:analyzer/src/generated/ast.dart'; |
| 25 import 'package:analyzer/src/generated/engine.dart'; | 26 import 'package:analyzer/src/generated/engine.dart'; |
| 26 import 'package:analyzer/src/generated/source.dart'; | 27 import 'package:analyzer/src/generated/source.dart'; |
| 27 import 'package:analyzer/src/generated/sdk.dart'; | 28 import 'package:analyzer/src/generated/sdk.dart'; |
| 28 import 'package:analyzer/src/generated/source_io.dart'; | 29 import 'package:analyzer/src/generated/source_io.dart'; |
| 29 import 'package:analyzer/src/generated/java_engine.dart'; | 30 import 'package:analyzer/src/generated/java_engine.dart'; |
| 30 import 'package:analysis_server/src/services/index/index.dart'; | 31 import 'package:analysis_server/src/services/index/index.dart'; |
| 31 import 'package:analysis_server/src/services/search/search_engine.dart'; | 32 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 32 import 'package:analyzer/src/generated/element.dart'; | 33 import 'package:analyzer/src/generated/element.dart'; |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 // Only send status when subscribed. | 437 // Only send status when subscribed. |
| 437 if (!serverServices.contains(ServerService.STATUS)) { | 438 if (!serverServices.contains(ServerService.STATUS)) { |
| 438 return; | 439 return; |
| 439 } | 440 } |
| 440 // Only send status when it changes | 441 // Only send status when it changes |
| 441 bool isAnalyzing = operation != null; | 442 bool isAnalyzing = operation != null; |
| 442 if (statusAnalyzing == isAnalyzing) { | 443 if (statusAnalyzing == isAnalyzing) { |
| 443 return; | 444 return; |
| 444 } | 445 } |
| 445 statusAnalyzing = isAnalyzing; | 446 statusAnalyzing = isAnalyzing; |
| 446 Notification notification = new Notification(SERVER_STATUS); | 447 AnalysisStatus analysis = new AnalysisStatus(isAnalyzing); |
| 447 Map<String, Object> analysis = new HashMap(); | 448 channel.sendNotification(new ServerStatusParams( |
| 448 analysis['analyzing'] = isAnalyzing; | 449 analysis: analysis).toNotification()); |
| 449 notification.params['analysis'] = analysis; | |
| 450 channel.sendNotification(notification); | |
| 451 } | 450 } |
| 452 | 451 |
| 453 /** | 452 /** |
| 454 * Implementation for `analysis.setAnalysisRoots`. | 453 * Implementation for `analysis.setAnalysisRoots`. |
| 455 * | 454 * |
| 456 * TODO(scheglov) implement complete projects/contexts semantics. | 455 * TODO(scheglov) implement complete projects/contexts semantics. |
| 457 * | 456 * |
| 458 * The current implementation is intentionally simplified and expected | 457 * The current implementation is intentionally simplified and expected |
| 459 * that only folders are given each given folder corresponds to the exactly | 458 * that only folders are given each given folder corresponds to the exactly |
| 460 * one context. | 459 * one context. |
| (...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 exceptionString = 'null exception'; | 796 exceptionString = 'null exception'; |
| 798 } | 797 } |
| 799 // prepare stackTrace.toString() | 798 // prepare stackTrace.toString() |
| 800 String stackTraceString; | 799 String stackTraceString; |
| 801 if (stackTrace != null) { | 800 if (stackTrace != null) { |
| 802 stackTraceString = stackTrace.toString(); | 801 stackTraceString = stackTrace.toString(); |
| 803 } else { | 802 } else { |
| 804 stackTraceString = 'null stackTrace'; | 803 stackTraceString = 'null stackTrace'; |
| 805 } | 804 } |
| 806 // send the notification | 805 // send the notification |
| 807 Notification notification = new Notification(SERVER_ERROR); | 806 channel.sendNotification(new ServerErrorParams(true, exceptionString, |
| 808 notification.setParameter(FATAL, true); | 807 stackTraceString).toNotification()); |
| 809 notification.setParameter(MESSAGE, exceptionString); | |
| 810 notification.setParameter(STACK_TRACE, stackTraceString); | |
| 811 channel.sendNotification(notification); | |
| 812 } | 808 } |
| 813 } | 809 } |
| 814 | 810 |
| 815 | 811 |
| 816 typedef void OptionUpdater(AnalysisOptionsImpl options); | 812 typedef void OptionUpdater(AnalysisOptionsImpl options); |
| OLD | NEW |