Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 419833004: Send 'server.error' notification in case of an exception during performing an operation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/protocol.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_directory_manager.dart'; 14 import 'package:analysis_server/src/context_directory_manager.dart';
15 import 'package:analysis_server/src/domain_analysis.dart'; 15 import 'package:analysis_server/src/domain_analysis.dart';
16 import 'package:analysis_server/src/operation/operation_analysis.dart'; 16 import 'package:analysis_server/src/operation/operation_analysis.dart';
17 import 'package:analysis_server/src/operation/operation.dart'; 17 import 'package:analysis_server/src/operation/operation.dart';
18 import 'package:analysis_server/src/operation/operation_queue.dart'; 18 import 'package:analysis_server/src/operation/operation_queue.dart';
19 import 'package:analysis_server/src/package_map_provider.dart'; 19 import 'package:analysis_server/src/package_map_provider.dart';
20 import 'package:analysis_server/src/protocol.dart'; 20 import 'package:analysis_server/src/protocol.dart';
21 import 'package:analyzer/source/package_map_resolver.dart'; 21 import 'package:analyzer/source/package_map_resolver.dart';
22 import 'package:analyzer/src/generated/ast.dart'; 22 import 'package:analyzer/src/generated/ast.dart';
23 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
24 import 'package:analyzer/src/generated/error.dart'; 24 import 'package:analyzer/src/generated/error.dart';
25 import 'package:analyzer/src/generated/source.dart'; 25 import 'package:analyzer/src/generated/source.dart';
26 import 'package:analyzer/src/generated/sdk.dart'; 26 import 'package:analyzer/src/generated/sdk.dart';
27 import 'package:analyzer/src/generated/source_io.dart'; 27 import 'package:analyzer/src/generated/source_io.dart';
28 import 'package:analyzer/src/generated/java_engine.dart'; 28 import 'package:analyzer/src/generated/java_engine.dart';
29 import 'package:analysis_services/constants.dart';
29 import 'package:analysis_services/index/index.dart'; 30 import 'package:analysis_services/index/index.dart';
30 import 'package:analysis_services/search/search_engine.dart'; 31 import 'package:analysis_services/search/search_engine.dart';
31 import 'package:analyzer/src/generated/element.dart'; 32 import 'package:analyzer/src/generated/element.dart';
32 33
33 34
34 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager { 35 class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
35 final AnalysisServer analysisServer; 36 final AnalysisServer analysisServer;
36 37
37 /** 38 /**
38 * The default options used to create new analysis contexts. 39 * The default options used to create new analysis contexts.
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 // perform the operation 395 // perform the operation
395 try { 396 try {
396 operation.perform(this); 397 operation.perform(this);
397 } catch (exception, stackTrace) { 398 } catch (exception, stackTrace) {
398 AnalysisEngine.instance.logger.logError("${exception}\n${stackTrace}"); 399 AnalysisEngine.instance.logger.logError("${exception}\n${stackTrace}");
399 if (rethrowExceptions) { 400 if (rethrowExceptions) {
400 throw new AnalysisException( 401 throw new AnalysisException(
401 'Unexpected exception during analysis', 402 'Unexpected exception during analysis',
402 new CaughtException(exception, stackTrace)); 403 new CaughtException(exception, stackTrace));
403 } 404 }
405 _sendServerErrorNotification(exception, stackTrace);
404 } finally { 406 } finally {
405 if (!operationQueue.isEmpty) { 407 if (!operationQueue.isEmpty) {
406 _schedulePerformOperation(); 408 _schedulePerformOperation();
407 } else { 409 } else {
408 sendStatusNotification(null); 410 sendStatusNotification(null);
409 } 411 }
410 } 412 }
411 } 413 }
412 414
413 /** 415 /**
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
727 bool test_areOperationsFinished() { 729 bool test_areOperationsFinished() {
728 return operationQueue.isEmpty; 730 return operationQueue.isEmpty;
729 } 731 }
730 732
731 /** 733 /**
732 * Schedules [performOperation] exection. 734 * Schedules [performOperation] exection.
733 */ 735 */
734 void _schedulePerformOperation() { 736 void _schedulePerformOperation() {
735 new Future(performOperation); 737 new Future(performOperation);
736 } 738 }
739
740 /**
741 * Sends a non-fatal `server.error` notification.
742 */
743 void _sendServerErrorNotification(exception, stackTrace) {
744 // prepare exception.toString()
745 String exceptionString;
746 if (exception != null) {
747 exceptionString = exception.toString();
748 } else {
749 exceptionString = 'null exception';
750 }
751 // prepare stackTrace.toString()
752 String stackTraceString;
753 if (stackTrace != null) {
754 stackTraceString = stackTrace.toString();
755 } else {
756 stackTraceString = 'null stackTrace';
757 }
758 // send the notification
759 Notification notification = new Notification(SERVER_ERROR);
760 notification.setParameter(FATAL, false);
761 notification.setParameter(MESSAGE, exceptionString);
762 notification.setParameter(STACK_TRACE, stackTraceString);
763 channel.sendNotification(notification);
764 }
737 } 765 }
738 766
739 767
740 /** 768 /**
741 * An enumeration of the services provided by the analysis domain. 769 * An enumeration of the services provided by the analysis domain.
742 */ 770 */
743 class AnalysisService extends Enum2<AnalysisService> { 771 class AnalysisService extends Enum2<AnalysisService> {
744 static const ERRORS = const AnalysisService('ERRORS', 0); 772 static const ERRORS = const AnalysisService('ERRORS', 0);
745 static const HIGHLIGHTS = const AnalysisService('HIGHLIGHTS', 1); 773 static const HIGHLIGHTS = const AnalysisService('HIGHLIGHTS', 1);
746 static const NAVIGATION = const AnalysisService('NAVIGATION', 2); 774 static const NAVIGATION = const AnalysisService('NAVIGATION', 2);
(...skipping 13 matching lines...) Expand all
760 /** 788 /**
761 * An enumeration of the services provided by the server domain. 789 * An enumeration of the services provided by the server domain.
762 */ 790 */
763 class ServerService extends Enum2<ServerService> { 791 class ServerService extends Enum2<ServerService> {
764 static const ServerService STATUS = const ServerService('STATUS', 0); 792 static const ServerService STATUS = const ServerService('STATUS', 0);
765 793
766 static const List<ServerService> VALUES = const [STATUS]; 794 static const List<ServerService> VALUES = const [STATUS];
767 795
768 const ServerService(String name, int ordinal) : super(name, ordinal); 796 const ServerService(String name, int ordinal) : super(name, ordinal);
769 } 797 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/protocol.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698