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:collection'; | 6 import 'dart:collection'; |
7 import 'dart:core'; | 7 import 'dart:core'; |
8 import 'dart:io' as io; | 8 import 'dart:io' as io; |
9 import 'dart:math' show max; | 9 import 'dart:math' show max; |
10 | 10 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 import 'package:analyzer/src/generated/sdk.dart'; | 54 import 'package:analyzer/src/generated/sdk.dart'; |
55 import 'package:analyzer/src/generated/source.dart'; | 55 import 'package:analyzer/src/generated/source.dart'; |
56 import 'package:analyzer/src/generated/source_io.dart'; | 56 import 'package:analyzer/src/generated/source_io.dart'; |
57 import 'package:analyzer/src/generated/utilities_general.dart'; | 57 import 'package:analyzer/src/generated/utilities_general.dart'; |
58 import 'package:analyzer/src/util/glob.dart'; | 58 import 'package:analyzer/src/util/glob.dart'; |
59 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element; | 59 import 'package:analyzer_plugin/protocol/protocol_common.dart' hide Element; |
60 import 'package:front_end/src/base/performace_logger.dart'; | 60 import 'package:front_end/src/base/performace_logger.dart'; |
61 import 'package:front_end/src/incremental/byte_store.dart'; | 61 import 'package:front_end/src/incremental/byte_store.dart'; |
62 import 'package:front_end/src/incremental/file_byte_store.dart'; | 62 import 'package:front_end/src/incremental/file_byte_store.dart'; |
63 import 'package:plugin/plugin.dart'; | 63 import 'package:plugin/plugin.dart'; |
| 64 import 'package:telemetry/crash_reporting.dart'; |
| 65 import 'package:telemetry/telemetry.dart' as telemetry; |
64 import 'package:watcher/watcher.dart'; | 66 import 'package:watcher/watcher.dart'; |
65 | 67 |
66 typedef void OptionUpdater(AnalysisOptionsImpl options); | 68 typedef void OptionUpdater(AnalysisOptionsImpl options); |
67 | 69 |
68 /** | 70 /** |
69 * Enum representing reasons why analysis might be done for a given file. | 71 * Enum representing reasons why analysis might be done for a given file. |
70 */ | 72 */ |
71 class AnalysisDoneReason { | 73 class AnalysisDoneReason { |
72 /** | 74 /** |
73 * Analysis of the file completed successfully. | 75 * Analysis of the file completed successfully. |
(...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
771 stackTrace = StackTrace.current; | 773 stackTrace = StackTrace.current; |
772 buffer.writeln(); | 774 buffer.writeln(); |
773 buffer.write(stackTrace); | 775 buffer.write(stackTrace); |
774 } | 776 } |
775 | 777 |
776 // send the notification | 778 // send the notification |
777 channel.sendNotification( | 779 channel.sendNotification( |
778 new ServerErrorParams(fatal, message, buffer.toString()) | 780 new ServerErrorParams(fatal, message, buffer.toString()) |
779 .toNotification()); | 781 .toNotification()); |
780 | 782 |
| 783 // send to crash reporting |
| 784 options.crashReportSender?.sendReport(exception, stackTrace: stackTrace); |
| 785 |
781 // remember the last few exceptions | 786 // remember the last few exceptions |
782 if (exception is CaughtException) { | 787 if (exception is CaughtException) { |
783 stackTrace ??= exception.stackTrace; | 788 stackTrace ??= exception.stackTrace; |
784 } | 789 } |
785 exceptions.add(new ServerException(message, exception, stackTrace, fatal)); | 790 exceptions.add(new ServerException(message, exception, stackTrace, fatal)); |
786 } | 791 } |
787 | 792 |
788 /** | 793 /** |
789 * Send status notification to the client. The state of analysis is given by | 794 * Send status notification to the client. The state of analysis is given by |
790 * the [status] information. | 795 * the [status] information. |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
897 } | 902 } |
898 | 903 |
899 /** | 904 /** |
900 * Returns `true` if errors should be reported for [file] with the given | 905 * Returns `true` if errors should be reported for [file] with the given |
901 * absolute path. | 906 * absolute path. |
902 */ | 907 */ |
903 bool shouldSendErrorsNotificationFor(String file) { | 908 bool shouldSendErrorsNotificationFor(String file) { |
904 return contextManager.isInAnalysisRoot(file); | 909 return contextManager.isInAnalysisRoot(file); |
905 } | 910 } |
906 | 911 |
907 void shutdown() { | 912 Future<Null> shutdown() async { |
908 running = false; | 913 running = false; |
| 914 |
| 915 await options.analytics |
| 916 ?.waitForLastPing(timeout: new Duration(milliseconds: 200)); |
| 917 options.analytics?.close(); |
| 918 |
909 // Defer closing the channel and shutting down the instrumentation server so | 919 // Defer closing the channel and shutting down the instrumentation server so |
910 // that the shutdown response can be sent and logged. | 920 // that the shutdown response can be sent and logged. |
911 new Future(() { | 921 new Future(() { |
912 instrumentationService.shutdown(); | 922 instrumentationService.shutdown(); |
913 channel.close(); | 923 channel.close(); |
914 }); | 924 }); |
915 } | 925 } |
916 | 926 |
917 /** | 927 /** |
918 * Implementation for `analysis.updateContent`. | 928 * Implementation for `analysis.updateContent`. |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1036 } | 1046 } |
1037 | 1047 |
1038 _scheduleAnalysisImplementedNotification() async { | 1048 _scheduleAnalysisImplementedNotification() async { |
1039 Set<String> files = analysisServices[AnalysisService.IMPLEMENTED]; | 1049 Set<String> files = analysisServices[AnalysisService.IMPLEMENTED]; |
1040 if (files != null) { | 1050 if (files != null) { |
1041 scheduleImplementedNotification(this, files); | 1051 scheduleImplementedNotification(this, files); |
1042 } | 1052 } |
1043 } | 1053 } |
1044 } | 1054 } |
1045 | 1055 |
| 1056 /** |
| 1057 * Various IDE options. |
| 1058 */ |
1046 class AnalysisServerOptions { | 1059 class AnalysisServerOptions { |
1047 bool useAnalysisHighlight2 = false; | 1060 bool useAnalysisHighlight2 = false; |
| 1061 bool enableVerboseFlutterCompletions = false; |
| 1062 |
1048 String fileReadMode = 'as-is'; | 1063 String fileReadMode = 'as-is'; |
1049 String newAnalysisDriverLog; | 1064 String newAnalysisDriverLog; |
1050 | 1065 |
1051 String clientId; | 1066 String clientId; |
1052 String clientVersion; | 1067 String clientVersion; |
1053 | 1068 |
1054 // IDE options | 1069 /** |
1055 bool enableVerboseFlutterCompletions = false; | 1070 * The analytics instance; note, this object can be `null`, and should be |
| 1071 * accessed via a null-aware operator. |
| 1072 */ |
| 1073 telemetry.Analytics analytics; |
| 1074 |
| 1075 /** |
| 1076 * The crash report sender instance; note, this object can be `null`, and |
| 1077 * should be accessed via a null-aware operator. |
| 1078 */ |
| 1079 CrashReportSender crashReportSender; |
1056 } | 1080 } |
1057 | 1081 |
1058 /** | 1082 /** |
1059 * A [PriorityChangeEvent] indicates the set the priority files has changed. | 1083 * A [PriorityChangeEvent] indicates the set the priority files has changed. |
1060 */ | 1084 */ |
1061 class PriorityChangeEvent { | 1085 class PriorityChangeEvent { |
1062 final Source firstSource; | 1086 final Source firstSource; |
1063 | 1087 |
1064 PriorityChangeEvent(this.firstSource); | 1088 PriorityChangeEvent(this.firstSource); |
1065 } | 1089 } |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1465 /** | 1489 /** |
1466 * The [PerformanceTag] for time spent in server request handlers. | 1490 * The [PerformanceTag] for time spent in server request handlers. |
1467 */ | 1491 */ |
1468 static PerformanceTag serverRequests = server.createChild('requests'); | 1492 static PerformanceTag serverRequests = server.createChild('requests'); |
1469 | 1493 |
1470 /** | 1494 /** |
1471 * The [PerformanceTag] for time spent in split store microtasks. | 1495 * The [PerformanceTag] for time spent in split store microtasks. |
1472 */ | 1496 */ |
1473 static PerformanceTag splitStore = new PerformanceTag('splitStore'); | 1497 static PerformanceTag splitStore = new PerformanceTag('splitStore'); |
1474 } | 1498 } |
OLD | NEW |