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

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

Issue 2904983003: Update status pages to show package map and plugins (Closed)
Patch Set: Created 3 years, 7 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
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/plugin_manager.dart ('k') | no next file » | 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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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:convert'; 5 import 'dart:convert';
6 import 'dart:io'; 6 import 'dart:io';
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'package:analysis_server/protocol/protocol.dart'; 9 import 'package:analysis_server/protocol/protocol.dart';
10 import 'package:analysis_server/protocol/protocol_generated.dart'; 10 import 'package:analysis_server/protocol/protocol_generated.dart';
11 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/analysis_server.dart';
12 import 'package:analysis_server/src/domain_completion.dart'; 12 import 'package:analysis_server/src/domain_completion.dart';
13 import 'package:analysis_server/src/domain_diagnostic.dart'; 13 import 'package:analysis_server/src/domain_diagnostic.dart';
14 import 'package:analysis_server/src/domain_execution.dart'; 14 import 'package:analysis_server/src/domain_execution.dart';
15 import 'package:analysis_server/src/plugin/plugin_manager.dart';
15 import 'package:analysis_server/src/services/completion/completion_performance.d art'; 16 import 'package:analysis_server/src/services/completion/completion_performance.d art';
16 import 'package:analysis_server/src/socket_server.dart'; 17 import 'package:analysis_server/src/socket_server.dart';
17 import 'package:analysis_server/src/status/get_handler.dart'; 18 import 'package:analysis_server/src/status/get_handler.dart';
18 import 'package:analyzer/exception/exception.dart'; 19 import 'package:analyzer/exception/exception.dart';
19 import 'package:analyzer/file_system/file_system.dart'; 20 import 'package:analyzer/file_system/file_system.dart';
20 import 'package:analyzer/instrumentation/instrumentation.dart'; 21 import 'package:analyzer/instrumentation/instrumentation.dart';
21 import 'package:analyzer/source/error_processor.dart'; 22 import 'package:analyzer/source/error_processor.dart';
23 import 'package:analyzer/source/package_map_resolver.dart';
22 import 'package:analyzer/source/sdk_ext.dart'; 24 import 'package:analyzer/source/sdk_ext.dart';
23 import 'package:analyzer/src/context/source.dart'; 25 import 'package:analyzer/src/context/source.dart';
24 import 'package:analyzer/src/dart/analysis/driver.dart'; 26 import 'package:analyzer/src/dart/analysis/driver.dart';
25 import 'package:analyzer/src/dart/sdk/sdk.dart'; 27 import 'package:analyzer/src/dart/sdk/sdk.dart';
26 import 'package:analyzer/src/generated/engine.dart'; 28 import 'package:analyzer/src/generated/engine.dart';
27 import 'package:analyzer/src/generated/sdk.dart'; 29 import 'package:analyzer/src/generated/sdk.dart';
28 import 'package:analyzer/src/generated/source.dart'; 30 import 'package:analyzer/src/generated/source.dart';
29 import 'package:analyzer/src/generated/utilities_general.dart'; 31 import 'package:analyzer/src/generated/utilities_general.dart';
30 import 'package:analyzer/src/services/lint.dart'; 32 import 'package:analyzer/src/services/lint.dart';
31 import 'package:analyzer/task/model.dart'; 33 import 'package:analyzer/task/model.dart';
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after
511 if (resolver is DartUriResolver) { 513 if (resolver is DartUriResolver) {
512 DartSdk sdk = resolver.dartSdk; 514 DartSdk sdk = resolver.dartSdk;
513 buffer.write(' (sdk = '); 515 buffer.write(' (sdk = ');
514 buffer.write(sdk.runtimeType); 516 buffer.write(sdk.runtimeType);
515 if (sdk is FolderBasedDartSdk) { 517 if (sdk is FolderBasedDartSdk) {
516 buffer.write(' (path = '); 518 buffer.write(' (path = ');
517 buffer.write(sdk.directory.path); 519 buffer.write(sdk.directory.path);
518 buffer.write(')'); 520 buffer.write(')');
519 } else if (sdk is EmbedderSdk) { 521 } else if (sdk is EmbedderSdk) {
520 buffer.write(' (map = '); 522 buffer.write(' (map = ');
521 _writeMapOfStringToString(buffer, sdk.urlMappings); 523 _writeMap(buffer, sdk.urlMappings);
522 buffer.write(')'); 524 buffer.write(')');
523 } 525 }
524 buffer.write(')'); 526 buffer.write(')');
525 } else if (resolver is SdkExtUriResolver) { 527 } else if (resolver is SdkExtUriResolver) {
526 buffer.write(' (map = '); 528 buffer.write(' (map = ');
527 _writeMapOfStringToString(buffer, resolver.urlMappings); 529 _writeMap(buffer, resolver.urlMappings);
528 buffer.write(')'); 530 buffer.write(')');
531 } else if (resolver is PackageMapUriResolver) {
532 _writeMap(buffer, resolver.packageMap, valueWriter: _writeList);
529 } 533 }
530 buffer.write('</p>'); 534 buffer.write('</p>');
531 } 535 }
532 } 536 }
533 537
534 _writeFiles( 538 _writeFiles(
535 buffer, 'Priority Files (${priorityFiles.length})', priorityFiles); 539 buffer, 'Priority Files (${priorityFiles.length})', priorityFiles);
536 _writeFiles(buffer, 'Added Files (${addedFiles.length})', addedFiles); 540 _writeFiles(buffer, 'Added Files (${addedFiles.length})', addedFiles);
537 _writeFiles( 541 _writeFiles(
538 buffer, 542 buffer,
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
886 buffer.write('<h3>Execution Domain</h3>'); 890 buffer.write('<h3>Execution Domain</h3>');
887 _writeTwoColumns(buffer, (StringBuffer buffer) { 891 _writeTwoColumns(buffer, (StringBuffer buffer) {
888 buffer.write('<br>'); 892 buffer.write('<br>');
889 }, (StringBuffer buffer) { 893 }, (StringBuffer buffer) {
890 _writeSubscriptionList(buffer, ExecutionService.VALUES, services); 894 _writeSubscriptionList(buffer, ExecutionService.VALUES, services);
891 }); 895 });
892 } 896 }
893 } 897 }
894 898
895 /** 899 /**
896 * Write to the given [buffer] a representation of the given [map] of strings 900 * Write to the given [buffer] a representation of the given [list].
897 * to strings.
898 */ 901 */
899 void _writeMapOfStringToString(StringBuffer buffer, Map<String, String> map) { 902 void _writeList<E>(StringBuffer buffer, List<E> list,
903 {void elementWriter(StringBuffer buffer, E element)}) {
904 buffer.write('[');
905 for (int i = 0; i < list.length; i++) {
906 if (i > 0) {
907 buffer.write(', ');
908 }
909 if (elementWriter == null) {
910 buffer.write(list[i]);
911 } else {
912 elementWriter(buffer, list[i]);
913 }
914 }
915 buffer.write(']');
916 }
917
918 /**
919 * Write to the given [buffer] a representation of the given [map].
920 */
921 void _writeMap<V>(StringBuffer buffer, Map<String, V> map,
922 {void valueWriter(StringBuffer buffer, V value)}) {
900 List<String> keys = map.keys.toList(); 923 List<String> keys = map.keys.toList();
901 keys.sort(); 924 keys.sort();
902 int length = keys.length; 925 int length = keys.length;
903 buffer.write('{'); 926 buffer.write('{');
904 for (int i = 0; i < length; i++) { 927 for (int i = 0; i < length; i++) {
905 buffer.write('<br>'); 928 buffer.write('<br>');
906 String key = keys[i]; 929 String key = keys[i];
930 V value = map[key];
907 if (i > 0) { 931 if (i > 0) {
908 buffer.write(', '); 932 buffer.write(', ');
909 } 933 }
910 buffer.write(key); 934 buffer.write(key);
911 buffer.write(' = '); 935 buffer.write(' = ');
912 buffer.write(map[key]); 936 if (valueWriter == null) {
937 buffer.write(value);
938 } else {
939 valueWriter(buffer, value);
940 }
913 } 941 }
914 buffer.write('<br>}'); 942 buffer.write('<br>}');
915 } 943 }
916 944
917 /** 945 /**
918 * Write a representation of an analysis option with the given [name] and 946 * Write a representation of an analysis option with the given [name] and
919 * [value] to the given [buffer]. The option should be separated from other 947 * [value] to the given [buffer]. The option should be separated from other
920 * options unless the [last] flag is true, indicating that this is the last 948 * options unless the [last] flag is true, indicating that this is the last
921 * option in the list of options. 949 * option in the list of options.
922 */ 950 */
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1135 description = description.replaceAllMapped(urlRegExp, (Match match) { 1163 description = description.replaceAllMapped(urlRegExp, (Match match) {
1136 return '<a href="${match.group(0)}">${match.group(1)}</a>'; 1164 return '<a href="${match.group(0)}">${match.group(1)}</a>';
1137 }); 1165 });
1138 buffer.write(description.replaceAll('\n', '<br>')); 1166 buffer.write(description.replaceAll('\n', '<br>'));
1139 } 1167 }
1140 }, (StringBuffer buffer) { 1168 }, (StringBuffer buffer) {
1141 _writeSubscriptionList(buffer, ServerService.VALUES, services); 1169 _writeSubscriptionList(buffer, ServerService.VALUES, services);
1142 buffer.write('<p><b>Versions</b></p>'); 1170 buffer.write('<p><b>Versions</b></p>');
1143 buffer.write('Dart SDK: ${Platform.version}<br>'); 1171 buffer.write('Dart SDK: ${Platform.version}<br>');
1144 buffer.write('Analysis server version: ${AnalysisServer.VERSION}<br>'); 1172 buffer.write('Analysis server version: ${AnalysisServer.VERSION}<br>');
1173 buffer.write('<p><b>Plugins</b></p>');
1174 List<PluginInfo> plugins = analysisServer.pluginManager.plugins;
1175 if (plugins.isEmpty) {
1176 buffer.write('none<br>');
1177 } else {
1178 plugins.sort(
1179 (first, second) => first.data.name.compareTo(second.data.name));
1180 for (PluginInfo plugin in plugins) {
1181 buffer.write(plugin.data.name);
1182 buffer.write(' (');
1183 buffer.write(plugin.data.pluginId);
1184 buffer.write(', ');
1185 buffer.write(plugin.data.version);
1186 buffer.write(')<br>');
1187 }
1188 }
1145 }); 1189 });
1146 return analysisServer != null; 1190 return analysisServer != null;
1147 } 1191 }
1148 1192
1149 /** 1193 /**
1150 * Write a representation of the given [stackTrace] to the given [buffer]. 1194 * Write a representation of the given [stackTrace] to the given [buffer].
1151 */ 1195 */
1152 void _writeStackTrace(StringBuffer buffer, StackTrace stackTrace) { 1196 void _writeStackTrace(StringBuffer buffer, StackTrace stackTrace) {
1153 if (stackTrace != null) { 1197 if (stackTrace != null) {
1154 String trace = stackTrace.toString().replaceAll('#', '<br>#'); 1198 String trace = stackTrace.toString().replaceAll('#', '<br>#');
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
1250 String path, Map<String, String> params, String innerHtml, 1294 String path, Map<String, String> params, String innerHtml,
1251 [bool hasError = false]) { 1295 [bool hasError = false]) {
1252 Uri uri = params.isEmpty 1296 Uri uri = params.isEmpty
1253 ? new Uri(path: path) 1297 ? new Uri(path: path)
1254 : new Uri(path: path, queryParameters: params); 1298 : new Uri(path: path, queryParameters: params);
1255 String href = HTML_ESCAPE.convert(uri.toString()); 1299 String href = HTML_ESCAPE.convert(uri.toString());
1256 String classAttribute = hasError ? ' class="error"' : ''; 1300 String classAttribute = hasError ? ' class="error"' : '';
1257 return '<a href="$href" $classAttribute>$innerHtml</a>'; 1301 return '<a href="$href" $classAttribute>$innerHtml</a>';
1258 } 1302 }
1259 } 1303 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/plugin/plugin_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698