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

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

Issue 1432423004: Send any logError() information to the IDE. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
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 import 'dart:core' hide Resource; 9 import 'dart:core' hide Resource;
10 import 'dart:math' show max; 10 import 'dart:math' show max;
11 11
12 import 'package:analysis_server/plugin/analysis/analyzed_files.dart';
13 import 'package:analysis_server/plugin/analysis/resolver_provider.dart'; 12 import 'package:analysis_server/plugin/analysis/resolver_provider.dart';
14 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; 13 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element;
15 import 'package:analysis_server/src/analysis_logger.dart'; 14 import 'package:analysis_server/src/analysis_logger.dart';
16 import 'package:analysis_server/src/channel/channel.dart'; 15 import 'package:analysis_server/src/channel/channel.dart';
17 import 'package:analysis_server/src/context_manager.dart'; 16 import 'package:analysis_server/src/context_manager.dart';
18 import 'package:analysis_server/src/operation/operation.dart'; 17 import 'package:analysis_server/src/operation/operation.dart';
19 import 'package:analysis_server/src/operation/operation_analysis.dart'; 18 import 'package:analysis_server/src/operation/operation_analysis.dart';
20 import 'package:analysis_server/src/operation/operation_queue.dart'; 19 import 'package:analysis_server/src/operation/operation_queue.dart';
21 import 'package:analysis_server/src/plugin/server_plugin.dart'; 20 import 'package:analysis_server/src/plugin/server_plugin.dart';
22 import 'package:analysis_server/src/services/correction/namespace.dart'; 21 import 'package:analysis_server/src/services/correction/namespace.dart';
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
311 ServerContextManagerCallbacks contextManagerCallbacks = 310 ServerContextManagerCallbacks contextManagerCallbacks =
312 new ServerContextManagerCallbacks(this, resourceProvider); 311 new ServerContextManagerCallbacks(this, resourceProvider);
313 contextManager.callbacks = contextManagerCallbacks; 312 contextManager.callbacks = contextManagerCallbacks;
314 defaultContextOptions.incremental = true; 313 defaultContextOptions.incremental = true;
315 defaultContextOptions.incrementalApi = 314 defaultContextOptions.incrementalApi =
316 options.enableIncrementalResolutionApi; 315 options.enableIncrementalResolutionApi;
317 defaultContextOptions.incrementalValidation = 316 defaultContextOptions.incrementalValidation =
318 options.enableIncrementalResolutionValidation; 317 options.enableIncrementalResolutionValidation;
319 defaultContextOptions.generateImplicitErrors = false; 318 defaultContextOptions.generateImplicitErrors = false;
320 _noErrorNotification = options.noErrorNotification; 319 _noErrorNotification = options.noErrorNotification;
321 AnalysisEngine.instance.logger = new AnalysisLogger(); 320 AnalysisEngine.instance.logger = new AnalysisLogger(
321 onError: (String message, CaughtException exception) {
322 sendServerErrorNotification(message, exception, exception?.stackTrace,
323 fatal: false);
324 });
322 _onAnalysisStartedController = new StreamController.broadcast(); 325 _onAnalysisStartedController = new StreamController.broadcast();
323 _onFileAnalyzedController = new StreamController.broadcast(); 326 _onFileAnalyzedController = new StreamController.broadcast();
324 _onPriorityChangeController = 327 _onPriorityChangeController =
325 new StreamController<PriorityChangeEvent>.broadcast(); 328 new StreamController<PriorityChangeEvent>.broadcast();
326 running = true; 329 running = true;
327 onAnalysisStarted.first.then((_) { 330 onAnalysisStarted.first.then((_) {
328 onAnalysisComplete.then((_) { 331 onAnalysisComplete.then((_) {
329 performanceAfterStartup = new ServerPerformance(); 332 performanceAfterStartup = new ServerPerformance();
330 _performance = performanceAfterStartup; 333 _performance = performanceAfterStartup;
331 }); 334 });
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 error.stackTrace = stackTrace.toString(); 709 error.stackTrace = stackTrace.toString();
707 } 710 }
708 Response response = new Response(request.id, error: error); 711 Response response = new Response(request.id, error: error);
709 channel.sendResponse(response); 712 channel.sendResponse(response);
710 return; 713 return;
711 } 714 }
712 } 715 }
713 channel.sendResponse(new Response.unknownRequest(request)); 716 channel.sendResponse(new Response.unknownRequest(request));
714 }); 717 });
715 }, onError: (exception, stackTrace) { 718 }, onError: (exception, stackTrace) {
716 sendServerErrorNotification(exception, stackTrace, fatal: true); 719 sendServerErrorNotification(null, exception, stackTrace, fatal: true);
Brian Wilkerson 2015/11/12 14:52:51 I think we should always provide a message that id
scheglov 2015/11/12 16:15:56 Done.
717 }); 720 });
718 } 721 }
719 722
720 /** 723 /**
721 * Returns `true` if there is a subscription for the given [service] and 724 * Returns `true` if there is a subscription for the given [service] and
722 * [file]. 725 * [file].
723 */ 726 */
724 bool hasAnalysisSubscription(AnalysisService service, String file) { 727 bool hasAnalysisSubscription(AnalysisService service, String file) {
725 Set<String> files = analysisServices[service]; 728 Set<String> files = analysisServices[service];
726 return files != null && files.contains(file); 729 return files != null && files.contains(file);
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 // loop is in progress. No problem; we just need to exit the operation 790 // loop is in progress. No problem; we just need to exit the operation
788 // loop and wait for the next operation to be added. 791 // loop and wait for the next operation to be added.
789 ServerPerformanceStatistics.idle.makeCurrent(); 792 ServerPerformanceStatistics.idle.makeCurrent();
790 return; 793 return;
791 } 794 }
792 sendStatusNotification(operation); 795 sendStatusNotification(operation);
793 // perform the operation 796 // perform the operation
794 try { 797 try {
795 operation.perform(this); 798 operation.perform(this);
796 } catch (exception, stackTrace) { 799 } catch (exception, stackTrace) {
797 AnalysisEngine.instance.logger.logError("${exception}\n${stackTrace}"); 800 sendServerErrorNotification(null, exception, stackTrace, fatal: true);
798 if (rethrowExceptions) { 801 if (rethrowExceptions) {
799 throw new AnalysisException('Unexpected exception during analysis', 802 throw new AnalysisException('Unexpected exception during analysis',
800 new CaughtException(exception, stackTrace)); 803 new CaughtException(exception, stackTrace));
801 } 804 }
802 sendServerErrorNotification(exception, stackTrace, fatal: true);
803 shutdown(); 805 shutdown();
804 } finally { 806 } finally {
805 if (_test_onOperationPerformedCompleter != null) { 807 if (_test_onOperationPerformedCompleter != null) {
806 _test_onOperationPerformedCompleter.complete(operation); 808 _test_onOperationPerformedCompleter.complete(operation);
807 _test_onOperationPerformedCompleter = null; 809 _test_onOperationPerformedCompleter = null;
808 } 810 }
809 if (!operationQueue.isEmpty) { 811 if (!operationQueue.isEmpty) {
810 ServerPerformanceStatistics.intertask.makeCurrent(); 812 ServerPerformanceStatistics.intertask.makeCurrent();
811 _schedulePerformOperation(); 813 _schedulePerformOperation();
812 } else { 814 } else {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
882 /** 884 /**
883 * Send the given [response] to the client. 885 * Send the given [response] to the client.
884 */ 886 */
885 void sendResponse(Response response) { 887 void sendResponse(Response response) {
886 channel.sendResponse(response); 888 channel.sendResponse(response);
887 } 889 }
888 890
889 /** 891 /**
890 * Sends a `server.error` notification. 892 * Sends a `server.error` notification.
891 */ 893 */
892 void sendServerErrorNotification(exception, stackTrace, {bool fatal: false}) { 894 void sendServerErrorNotification(String msg, exception, stackTrace,
895 {bool fatal: false}) {
893 // prepare exception.toString() 896 // prepare exception.toString()
894 String exceptionString; 897 String exceptionString;
895 if (exception != null) { 898 if (exception != null) {
896 exceptionString = exception.toString(); 899 exceptionString = exception.toString();
897 } else { 900 } else {
898 exceptionString = 'null exception'; 901 exceptionString = 'null exception';
899 } 902 }
903 // prepare message
904 String message = msg != null ? '$msg\n$exceptionString' : exceptionString;
900 // prepare stackTrace.toString() 905 // prepare stackTrace.toString()
901 String stackTraceString; 906 String stackTraceString;
902 if (stackTrace != null) { 907 if (stackTrace != null) {
903 stackTraceString = stackTrace.toString(); 908 stackTraceString = stackTrace.toString();
904 } else { 909 } else {
905 try { 910 try {
906 throw 'ignored'; 911 throw 'ignored';
907 } catch (ignored, stackTrace) { 912 } catch (ignored, stackTrace) {
908 stackTraceString = stackTrace.toString(); 913 stackTraceString = stackTrace.toString();
909 } 914 }
910 if (stackTraceString == null) { 915 if (stackTraceString == null) {
911 // This code should be unreachable. 916 // This code should be unreachable.
912 stackTraceString = 'null stackTrace'; 917 stackTraceString = 'null stackTrace';
913 } 918 }
914 } 919 }
915 // send the notification 920 // send the notification
916 channel.sendNotification( 921 channel.sendNotification(
917 new ServerErrorParams(fatal, exceptionString, stackTraceString) 922 new ServerErrorParams(fatal, message, stackTraceString)
918 .toNotification()); 923 .toNotification());
919 } 924 }
920 925
921 /** 926 /**
922 * Send status notification to the client. The `operation` is the operation 927 * Send status notification to the client. The `operation` is the operation
923 * being performed or `null` if analysis is complete. 928 * being performed or `null` if analysis is complete.
924 */ 929 */
925 void sendStatusNotification(ServerOperation operation) { 930 void sendStatusNotification(ServerOperation operation) {
926 // Only send status when subscribed. 931 // Only send status when subscribed.
927 if (!serverServices.contains(ServerService.STATUS)) { 932 if (!serverServices.contains(ServerService.STATUS)) {
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
1633 /** 1638 /**
1634 * The [PerformanceTag] for time spent in server request handlers. 1639 * The [PerformanceTag] for time spent in server request handlers.
1635 */ 1640 */
1636 static PerformanceTag serverRequests = new PerformanceTag('serverRequests'); 1641 static PerformanceTag serverRequests = new PerformanceTag('serverRequests');
1637 1642
1638 /** 1643 /**
1639 * The [PerformanceTag] for time spent in split store microtasks. 1644 * The [PerformanceTag] for time spent in split store microtasks.
1640 */ 1645 */
1641 static PerformanceTag splitStore = new PerformanceTag('splitStore'); 1646 static PerformanceTag splitStore = new PerformanceTag('splitStore');
1642 } 1647 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698