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

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

Issue 2119713004: Add links to context information for SDK contexts (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 5 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 | « no previous file | 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) 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.src.status.get_handler; 5 library analysis_server.src.status.get_handler;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
393 } else if (path == OVERLAY_PATH) { 393 } else if (path == OVERLAY_PATH) {
394 _returnOverlayContents(request); 394 _returnOverlayContents(request);
395 } else if (path == OVERLAYS_PATH) { 395 } else if (path == OVERLAYS_PATH) {
396 _returnOverlaysInfo(request); 396 _returnOverlaysInfo(request);
397 } else { 397 } else {
398 _returnUnknownRequest(request); 398 _returnUnknownRequest(request);
399 } 399 }
400 } 400 }
401 401
402 /** 402 /**
403 * Produce an encoded version of the given [descriptor] that can be used to
404 * find the descriptor later.
405 */
406 String _encodeSdkDescriptor(SdkDescription descriptor) {
407 StringBuffer buffer = new StringBuffer();
408 buffer.write(descriptor.options.encodeCrossContextOptions());
409 for (String path in descriptor.paths) {
410 buffer.write('+');
411 buffer.write(path);
412 }
413 return buffer.toString();
414 }
415
416 /**
403 * Return the folder being managed by the given [analysisServer] that matches 417 * Return the folder being managed by the given [analysisServer] that matches
404 * the given [contextFilter], or `null` if there is none. 418 * the given [contextFilter], or `null` if there is none.
405 */ 419 */
406 Folder _findFolder(AnalysisServer analysisServer, String contextFilter) { 420 Folder _findFolder(AnalysisServer analysisServer, String contextFilter) {
407 return analysisServer.folderMap.keys.firstWhere( 421 return analysisServer.folderMap.keys.firstWhere(
408 (Folder folder) => folder.path == contextFilter, 422 (Folder folder) => folder.path == contextFilter,
409 orElse: () => null); 423 orElse: () => null);
410 } 424 }
411 425
412 /** 426 /**
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 results.add(INFERABLE_STATIC_VARIABLE_DEPENDENCIES); 569 results.add(INFERABLE_STATIC_VARIABLE_DEPENDENCIES);
556 results.add(INFERRED_STATIC_VARIABLE); 570 results.add(INFERRED_STATIC_VARIABLE);
557 } 571 }
558 } else if (target is AnalysisContextTarget) { 572 } else if (target is AnalysisContextTarget) {
559 results.add(TYPE_PROVIDER); 573 results.add(TYPE_PROVIDER);
560 } 574 }
561 return results.toList(); 575 return results.toList();
562 } 576 }
563 577
564 /** 578 /**
579 * Return the context for the SDK whose descriptor is encoded to be the same
580 * as the given [contextFilter]. The [analysisServer] is used to access the
581 * SDKs.
582 */
583 AnalysisContext _getSdkContext(
584 AnalysisServer analysisServer, String contextFilter) {
585 DartSdkManager manager = analysisServer.sdkManager;
586 List<SdkDescription> descriptors = manager.sdkDescriptors;
587 for (SdkDescription descriptor in descriptors) {
588 if (contextFilter == _encodeSdkDescriptor(descriptor)) {
589 return manager.getSdk(descriptor, () => null)?.context;
590 }
591 }
592 return null;
593 }
594
595 /**
565 * Return `true` if the given analysis [context] has at least one entry with 596 * Return `true` if the given analysis [context] has at least one entry with
566 * an exception. 597 * an exception.
567 */ 598 */
568 bool _hasException(InternalAnalysisContext context) { 599 bool _hasException(InternalAnalysisContext context) {
600 if (context == null) {
601 return false;
602 }
569 MapIterator<AnalysisTarget, CacheEntry> iterator = 603 MapIterator<AnalysisTarget, CacheEntry> iterator =
570 context.analysisCache.iterator(); 604 context.analysisCache.iterator();
571 while (iterator.moveNext()) { 605 while (iterator.moveNext()) {
572 CacheEntry entry = iterator.value; 606 CacheEntry entry = iterator.value;
573 if (entry == null || entry.exception != null) { 607 if (entry == null || entry.exception != null) {
574 return true; 608 return true;
575 } 609 }
576 } 610 }
577 return false; 611 return false;
578 } 612 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 void _returnCacheEntry(HttpRequest request) { 929 void _returnCacheEntry(HttpRequest request) {
896 AnalysisServer analysisServer = _server.analysisServer; 930 AnalysisServer analysisServer = _server.analysisServer;
897 if (analysisServer == null) { 931 if (analysisServer == null) {
898 return _returnFailure(request, 'Analysis server not running'); 932 return _returnFailure(request, 'Analysis server not running');
899 } 933 }
900 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM]; 934 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM];
901 if (contextFilter == null) { 935 if (contextFilter == null) {
902 return _returnFailure( 936 return _returnFailure(
903 request, 'Query parameter $CONTEXT_QUERY_PARAM required'); 937 request, 'Query parameter $CONTEXT_QUERY_PARAM required');
904 } 938 }
939 InternalAnalysisContext context = null;
905 Folder folder = _findFolder(analysisServer, contextFilter); 940 Folder folder = _findFolder(analysisServer, contextFilter);
906 if (folder == null) { 941 if (folder == null) {
907 return _returnFailure(request, 'Invalid context: $contextFilter'); 942 context = _getSdkContext(analysisServer, contextFilter);
943 if (context == null) {
944 return _returnFailure(request, 'Invalid context: $contextFilter');
945 }
946 return _returnFailure(request,
947 'Cannot view cache entries from an SDK context: $contextFilter');
948 } else {
949 context = analysisServer.folderMap[folder];
908 } 950 }
909 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; 951 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM];
910 if (sourceUri == null) { 952 if (sourceUri == null) {
911 return _returnFailure( 953 return _returnFailure(
912 request, 'Query parameter $SOURCE_QUERY_PARAM required'); 954 request, 'Query parameter $SOURCE_QUERY_PARAM required');
913 } 955 }
914 956
915 List<Folder> allContexts = <Folder>[]; 957 List<Folder> allContexts = <Folder>[];
916 Map<Folder, List<CacheEntry>> entryMap = 958 Map<Folder, List<CacheEntry>> entryMap =
917 new HashMap<Folder, List<CacheEntry>>(); 959 new HashMap<Folder, List<CacheEntry>>();
(...skipping 21 matching lines...) Expand all
939 invalidKeysBuffer.write(iterator.key.toString()); 981 invalidKeysBuffer.write(iterator.key.toString());
940 } else { 982 } else {
941 entries.add(value); 983 entries.add(value);
942 } 984 }
943 } 985 }
944 } 986 }
945 } 987 }
946 }); 988 });
947 allContexts.sort((Folder firstFolder, Folder secondFolder) => 989 allContexts.sort((Folder firstFolder, Folder secondFolder) =>
948 firstFolder.path.compareTo(secondFolder.path)); 990 firstFolder.path.compareTo(secondFolder.path));
949 InternalAnalysisContext context = analysisServer.folderMap[folder];
950 991
951 _writeResponse(request, (StringBuffer buffer) { 992 _writeResponse(request, (StringBuffer buffer) {
952 _writePage(buffer, 'Analysis Server - Cache Entry', 993 _writePage(buffer, 'Analysis Server - Cache Entry',
953 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) { 994 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) {
954 if (invalidKeysBuffer.isNotEmpty) { 995 if (invalidKeysBuffer.isNotEmpty) {
955 buffer.write('<h3>Targets with null Entries</h3><p>'); 996 buffer.write('<h3>Targets with null Entries</h3><p>');
956 buffer.write(invalidKeysBuffer.toString()); 997 buffer.write(invalidKeysBuffer.toString());
957 buffer.write('</p>'); 998 buffer.write('</p>');
958 } 999 }
959 List<CacheEntry> entries = entryMap[folder]; 1000 List<CacheEntry> entries = entryMap[folder];
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 } 1034 }
994 }); 1035 });
995 buffer.write('</p>'); 1036 buffer.write('</p>');
996 1037
997 if (entries == null) { 1038 if (entries == null) {
998 buffer.write('<p>Not being analyzed in this context.</p>'); 1039 buffer.write('<p>Not being analyzed in this context.</p>');
999 return; 1040 return;
1000 } 1041 }
1001 for (CacheEntry entry in entries) { 1042 for (CacheEntry entry in entries) {
1002 Map<String, String> linkParameters = <String, String>{ 1043 Map<String, String> linkParameters = <String, String>{
1003 CONTEXT_QUERY_PARAM: folder.path, 1044 CONTEXT_QUERY_PARAM: contextFilter,
1004 SOURCE_QUERY_PARAM: sourceUri 1045 SOURCE_QUERY_PARAM: sourceUri
1005 }; 1046 };
1006 List<ResultDescriptor> results = _getExpectedResults(entry); 1047 List<ResultDescriptor> results = _getExpectedResults(entry);
1007 results.sort(ResultDescriptor.SORT_BY_NAME); 1048 results.sort(ResultDescriptor.SORT_BY_NAME);
1008 1049
1009 buffer.write('<h3>'); 1050 buffer.write('<h3>');
1010 buffer.write(HTML_ESCAPE.convert(entry.target.toString())); 1051 buffer.write(HTML_ESCAPE.convert(entry.target.toString()));
1011 buffer.write('</h3>'); 1052 buffer.write('</h3>');
1012 buffer.write('<p>time</p><blockquote><p>Value</p><blockquote>'); 1053 buffer.write('<p>time</p><blockquote><p>Value</p><blockquote>');
1013 buffer.write(entry.modificationTime); 1054 buffer.write(entry.modificationTime);
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 void _returnContextDiagnostics(HttpRequest request) { 1251 void _returnContextDiagnostics(HttpRequest request) {
1211 AnalysisServer analysisServer = _server.analysisServer; 1252 AnalysisServer analysisServer = _server.analysisServer;
1212 if (analysisServer == null) { 1253 if (analysisServer == null) {
1213 return _returnFailure(request, 'Analysis server is not running'); 1254 return _returnFailure(request, 'Analysis server is not running');
1214 } 1255 }
1215 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM]; 1256 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM];
1216 if (contextFilter == null) { 1257 if (contextFilter == null) {
1217 return _returnFailure( 1258 return _returnFailure(
1218 request, 'Query parameter $CONTEXT_QUERY_PARAM required'); 1259 request, 'Query parameter $CONTEXT_QUERY_PARAM required');
1219 } 1260 }
1261 InternalAnalysisContext context = null;
1220 Folder folder = _findFolder(analysisServer, contextFilter); 1262 Folder folder = _findFolder(analysisServer, contextFilter);
1221 if (folder == null) { 1263 if (folder == null) {
1222 return _returnFailure(request, 'Invalid context: $contextFilter'); 1264 context = _getSdkContext(analysisServer, contextFilter);
1265 if (context == null) {
1266 return _returnFailure(request, 'Invalid context: $contextFilter');
1267 }
1268 } else {
1269 context = analysisServer.folderMap[folder];
1223 } 1270 }
1224 1271
1225 InternalAnalysisContext context = analysisServer.folderMap[folder];
1226
1227 _writeResponse(request, (StringBuffer buffer) { 1272 _writeResponse(request, (StringBuffer buffer) {
1228 _writePage(buffer, 'Analysis Server - Context Diagnostics', 1273 _writePage(buffer, 'Analysis Server - Context Diagnostics',
1229 ['Context: $contextFilter'], (StringBuffer buffer) { 1274 ['Context: $contextFilter'], (StringBuffer buffer) {
1230 _writeContextDiagnostics(buffer, context); 1275 _writeContextDiagnostics(buffer, context, contextFilter);
1231 }); 1276 });
1232 }); 1277 });
1233 } 1278 }
1234 1279
1235 /** 1280 /**
1236 * Return a response containing information about a single source file in the 1281 * Return a response containing information about a single source file in the
1237 * cache. 1282 * cache.
1238 */ 1283 */
1239 void _returnContextInfo(HttpRequest request) { 1284 void _returnContextInfo(HttpRequest request) {
1240 AnalysisServer analysisServer = _server.analysisServer; 1285 AnalysisServer analysisServer = _server.analysisServer;
1241 if (analysisServer == null) { 1286 if (analysisServer == null) {
1242 return _returnFailure(request, 'Analysis server not running'); 1287 return _returnFailure(request, 'Analysis server not running');
1243 } 1288 }
1244 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM]; 1289 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM];
1245 if (contextFilter == null) { 1290 if (contextFilter == null) {
1246 return _returnFailure( 1291 return _returnFailure(
1247 request, 'Query parameter $CONTEXT_QUERY_PARAM required'); 1292 request, 'Query parameter $CONTEXT_QUERY_PARAM required');
1248 } 1293 }
1294 InternalAnalysisContext context = null;
1249 Folder folder = _findFolder(analysisServer, contextFilter); 1295 Folder folder = _findFolder(analysisServer, contextFilter);
1250 if (folder == null) { 1296 if (folder == null) {
1251 return _returnFailure(request, 'Invalid context: $contextFilter'); 1297 context = _getSdkContext(analysisServer, contextFilter);
1298 if (context == null) {
1299 return _returnFailure(request, 'Invalid context: $contextFilter');
1300 }
1301 } else {
1302 context = analysisServer.folderMap[folder];
1252 } 1303 }
1253 1304
1254 List<String> priorityNames = <String>[]; 1305 List<String> priorityNames = <String>[];
1255 List<String> explicitNames = <String>[]; 1306 List<String> explicitNames = <String>[];
1256 List<String> implicitNames = <String>[]; 1307 List<String> implicitNames = <String>[];
1257 Map<String, String> links = new HashMap<String, String>(); 1308 Map<String, String> links = new HashMap<String, String>();
1258 List<CaughtException> exceptions = <CaughtException>[]; 1309 List<CaughtException> exceptions = <CaughtException>[];
1259 InternalAnalysisContext context = analysisServer.folderMap[folder];
1260 context.prioritySources.forEach((Source source) { 1310 context.prioritySources.forEach((Source source) {
1261 priorityNames.add(source.fullName); 1311 priorityNames.add(source.fullName);
1262 }); 1312 });
1263 MapIterator<AnalysisTarget, CacheEntry> iterator = 1313 MapIterator<AnalysisTarget, CacheEntry> iterator =
1264 context.analysisCache.iterator(context: context); 1314 context.analysisCache.iterator(context: context);
1265 while (iterator.moveNext()) { 1315 while (iterator.moveNext()) {
1266 AnalysisTarget target = iterator.key; 1316 AnalysisTarget target = iterator.key;
1267 if (target is Source) { 1317 if (target is Source) {
1268 CacheEntry entry = iterator.value; 1318 CacheEntry entry = iterator.value;
1269 String sourceName = target.fullName; 1319 String sourceName = target.fullName;
1270 if (!links.containsKey(sourceName)) { 1320 if (!links.containsKey(sourceName)) {
1271 CaughtException exception = entry.exception; 1321 CaughtException exception = entry.exception;
1272 if (exception != null) { 1322 if (exception != null) {
1273 exceptions.add(exception); 1323 exceptions.add(exception);
1274 } 1324 }
1275 String link = makeLink( 1325 String link = makeLink(
1276 CACHE_ENTRY_PATH, 1326 CACHE_ENTRY_PATH,
1277 { 1327 {
1278 CONTEXT_QUERY_PARAM: folder.path, 1328 CONTEXT_QUERY_PARAM: contextFilter,
1279 SOURCE_QUERY_PARAM: target.uri.toString() 1329 SOURCE_QUERY_PARAM: target.uri.toString()
1280 }, 1330 },
1281 sourceName, 1331 sourceName,
1282 exception != null); 1332 exception != null);
1283 if (entry.explicitlyAdded) { 1333 if (entry.explicitlyAdded) {
1284 explicitNames.add(sourceName); 1334 explicitNames.add(sourceName);
1285 } else { 1335 } else {
1286 implicitNames.add(sourceName); 1336 implicitNames.add(sourceName);
1287 } 1337 }
1288 links[sourceName] = link; 1338 links[sourceName] = link;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1326 buffer.write('<p>'); 1376 buffer.write('<p>');
1327 _writeOption( 1377 _writeOption(
1328 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); 1378 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies);
1329 _writeOption(buffer, 'Cache size', options.cacheSize); 1379 _writeOption(buffer, 'Cache size', options.cacheSize);
1330 _writeOption(buffer, 'Enable async support', options.enableAsync); 1380 _writeOption(buffer, 'Enable async support', options.enableAsync);
1331 _writeOption( 1381 _writeOption(
1332 buffer, 'Enable generic methods', options.enableGenericMethods); 1382 buffer, 'Enable generic methods', options.enableGenericMethods);
1333 _writeOption( 1383 _writeOption(
1334 buffer, 'Enable strict call checks', options.enableStrictCallChecks); 1384 buffer, 'Enable strict call checks', options.enableStrictCallChecks);
1335 _writeOption(buffer, 'Enable super mixins', options.enableSuperMixins); 1385 _writeOption(buffer, 'Enable super mixins', options.enableSuperMixins);
1336 _writeOption(buffer, 'Enable trailing commas', options.enableTrailingComma s); 1386 _writeOption(
1387 buffer, 'Enable trailing commas', options.enableTrailingCommas);
1337 _writeOption(buffer, 'Generate dart2js hints', options.dart2jsHint); 1388 _writeOption(buffer, 'Generate dart2js hints', options.dart2jsHint);
1338 _writeOption(buffer, 'Generate errors in implicit files', 1389 _writeOption(buffer, 'Generate errors in implicit files',
1339 options.generateImplicitErrors); 1390 options.generateImplicitErrors);
1340 _writeOption( 1391 _writeOption(
1341 buffer, 'Generate errors in SDK files', options.generateSdkErrors); 1392 buffer, 'Generate errors in SDK files', options.generateSdkErrors);
1342 _writeOption(buffer, 'Generate hints', options.hint); 1393 _writeOption(buffer, 'Generate hints', options.hint);
1343 _writeOption(buffer, 'Incremental resolution', options.incremental); 1394 _writeOption(buffer, 'Incremental resolution', options.incremental);
1344 _writeOption(buffer, 'Incremental resolution with API changes', 1395 _writeOption(buffer, 'Incremental resolution with API changes',
1345 options.incrementalApi); 1396 options.incrementalApi);
1346 _writeOption(buffer, 'Preserve comments', options.preserveComments); 1397 _writeOption(buffer, 'Preserve comments', options.preserveComments);
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 void _returnContextValidationDiagnostics(HttpRequest request) { 1523 void _returnContextValidationDiagnostics(HttpRequest request) {
1473 AnalysisServer analysisServer = _server.analysisServer; 1524 AnalysisServer analysisServer = _server.analysisServer;
1474 if (analysisServer == null) { 1525 if (analysisServer == null) {
1475 return _returnFailure(request, 'Analysis server is not running'); 1526 return _returnFailure(request, 'Analysis server is not running');
1476 } 1527 }
1477 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM]; 1528 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM];
1478 if (contextFilter == null) { 1529 if (contextFilter == null) {
1479 return _returnFailure( 1530 return _returnFailure(
1480 request, 'Query parameter $CONTEXT_QUERY_PARAM required'); 1531 request, 'Query parameter $CONTEXT_QUERY_PARAM required');
1481 } 1532 }
1533 InternalAnalysisContext context = null;
1482 Folder folder = _findFolder(analysisServer, contextFilter); 1534 Folder folder = _findFolder(analysisServer, contextFilter);
1483 if (folder == null) { 1535 if (folder == null) {
1484 return _returnFailure(request, 'Invalid context: $contextFilter'); 1536 context = _getSdkContext(analysisServer, contextFilter);
1537 if (context == null) {
1538 return _returnFailure(request, 'Invalid context: $contextFilter');
1539 }
1540 } else {
1541 context = analysisServer.folderMap[folder];
1485 } 1542 }
1486 1543
1487 InternalAnalysisContext context = analysisServer.folderMap[folder];
1488
1489 _writeResponse(request, (StringBuffer buffer) { 1544 _writeResponse(request, (StringBuffer buffer) {
1490 _writePage(buffer, 'Analysis Server - Context Validation Diagnostics', 1545 _writePage(buffer, 'Analysis Server - Context Validation Diagnostics',
1491 ['Context: $contextFilter'], (StringBuffer buffer) { 1546 ['Context: $contextFilter'], (StringBuffer buffer) {
1492 _writeContextValidationDiagnostics(buffer, context); 1547 _writeContextValidationDiagnostics(buffer, context);
1493 }); 1548 });
1494 }); 1549 });
1495 } 1550 }
1496 1551
1497 /** 1552 /**
1498 * Return a response displaying diagnostic information. 1553 * Return a response displaying diagnostic information.
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
1715 {CONTEXT_QUERY_PARAM: folder.path}, 'diagnostics')); 1770 {CONTEXT_QUERY_PARAM: folder.path}, 'diagnostics'));
1716 buffer.write(']</b></small>'); 1771 buffer.write(']</b></small>');
1717 if (!folder.getChild('.packages').exists) { 1772 if (!folder.getChild('.packages').exists) {
1718 buffer.write(' <small>[no .packages file]</small>'); 1773 buffer.write(' <small>[no .packages file]</small>');
1719 } 1774 }
1720 }); 1775 });
1721 buffer.write('</p>'); 1776 buffer.write('</p>');
1722 buffer.write('<p><b>SDK Contexts</b></p>'); 1777 buffer.write('<p><b>SDK Contexts</b></p>');
1723 buffer.write('<p>'); 1778 buffer.write('<p>');
1724 first = true; 1779 first = true;
1725 List<String> descriptors = analysisServer.sdkManager.sdkDescriptors 1780 DartSdkManager manager = analysisServer.sdkManager;
1726 .map((SdkDescription descriptor) => descriptor.toString()) 1781 List<SdkDescription> descriptors = manager.sdkDescriptors;
1727 .toList();
1728 if (descriptors.isEmpty) { 1782 if (descriptors.isEmpty) {
1729 buffer.write('none'); 1783 buffer.write('none');
1730 } else { 1784 } else {
1731 descriptors.sort(); 1785 Map<String, SdkDescription> sdkMap = <String, SdkDescription>{};
1732 for (String descriptor in descriptors) { 1786 for (SdkDescription descriptor in descriptors) {
1787 sdkMap[descriptor.toString()] = descriptor;
1788 }
1789 List<String> descriptorNames = sdkMap.keys.toList();
1790 descriptorNames.sort();
1791 for (String name in descriptorNames) {
1733 if (first) { 1792 if (first) {
1734 first = false; 1793 first = false;
1735 } else { 1794 } else {
1736 buffer.write('<br>'); 1795 buffer.write('<br>');
1737 } 1796 }
1738 // TODO(brianwilkerson) Add a link to information about the contexts. 1797 SdkDescription descriptor = sdkMap[name];
1739 buffer.write(descriptor); 1798 String contextId = _encodeSdkDescriptor(descriptor);
1799 buffer.write(makeLink(
1800 CONTEXT_PATH,
1801 {CONTEXT_QUERY_PARAM: contextId},
1802 name,
1803 _hasException(manager.getSdk(descriptor, () => null)?.context)));
1804 buffer.write(' <small><b>[');
1805 buffer.write(makeLink(CONTEXT_DIAGNOSTICS_PATH,
1806 {CONTEXT_QUERY_PARAM: contextId}, 'diagnostics'));
1807 buffer.write(']</b></small>');
1740 } 1808 }
1741 } 1809 }
1742 buffer.write('</p>'); 1810 buffer.write('</p>');
1743 1811
1744 int freq = AnalysisServer.performOperationDelayFrequency; 1812 int freq = AnalysisServer.performOperationDelayFrequency;
1745 String delay = freq > 0 ? '1 ms every $freq ms' : 'off'; 1813 String delay = freq > 0 ? '1 ms every $freq ms' : 'off';
1746 1814
1747 buffer.write('<p><b>Performance Data</b></p>'); 1815 buffer.write('<p><b>Performance Data</b></p>');
1748 buffer.write('<p>Perform operation delay: $delay</p>'); 1816 buffer.write('<p>Perform operation delay: $delay</p>');
1749 buffer.write('<p>'); 1817 buffer.write('<p>');
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 sent to the client in the first notification, followed by a comma, 1939 sent to the client in the first notification, followed by a comma,
1872 followed by the number of suggestions send to the client 1940 followed by the number of suggestions send to the client
1873 in the last notification. If there is only one notification, 1941 in the last notification. If there is only one notification,
1874 then there will be only one number in this column.'''); 1942 then there will be only one number in this column.''');
1875 } 1943 }
1876 1944
1877 /** 1945 /**
1878 * Write diagnostic information about the given [context] to the given 1946 * Write diagnostic information about the given [context] to the given
1879 * [buffer]. 1947 * [buffer].
1880 */ 1948 */
1881 void _writeContextDiagnostics( 1949 void _writeContextDiagnostics(StringBuffer buffer,
1882 StringBuffer buffer, InternalAnalysisContext context) { 1950 InternalAnalysisContext context, String contextFilter) {
1883 AnalysisDriver driver = (context as AnalysisContextImpl).driver; 1951 AnalysisDriver driver = (context as AnalysisContextImpl).driver;
1884 List<WorkItem> workItems = driver.currentWorkOrder?.workItems; 1952 List<WorkItem> workItems = driver.currentWorkOrder?.workItems;
1885 1953
1886 buffer.write('<p>'); 1954 buffer.write('<p>');
1887 buffer.write(makeLink(CONTEXT_VALIDATION_DIAGNOSTICS_PATH, 1955 buffer.write(makeLink(CONTEXT_VALIDATION_DIAGNOSTICS_PATH,
1888 {CONTEXT_QUERY_PARAM: context.name}, 'Run validation')); 1956 {CONTEXT_QUERY_PARAM: contextFilter}, 'Run validation'));
1889 buffer.write('</p>'); 1957 buffer.write('</p>');
1890 1958
1891 buffer.write('<h3>Most Recently Perfomed Tasks</h3>'); 1959 buffer.write('<h3>Most Recently Perfomed Tasks</h3>');
1892 AnalysisTask.LAST_TASKS.forEach((String description) { 1960 AnalysisTask.LAST_TASKS.forEach((String description) {
1893 buffer.write('<p>'); 1961 buffer.write('<p>');
1894 buffer.write(description); 1962 buffer.write(description);
1895 buffer.write('</p>'); 1963 buffer.write('</p>');
1896 }); 1964 });
1897 1965
1898 void writeWorkItem(StringBuffer buffer, WorkItem item) { 1966 void writeWorkItem(StringBuffer buffer, WorkItem item) {
(...skipping 656 matching lines...) Expand 10 before | Expand all | Expand 10 after
2555 */ 2623 */
2556 static String makeLink( 2624 static String makeLink(
2557 String path, Map<String, String> params, String innerHtml, 2625 String path, Map<String, String> params, String innerHtml,
2558 [bool hasError = false]) { 2626 [bool hasError = false]) {
2559 Uri uri = new Uri(path: path, queryParameters: params); 2627 Uri uri = new Uri(path: path, queryParameters: params);
2560 String href = HTML_ESCAPE.convert(uri.toString()); 2628 String href = HTML_ESCAPE.convert(uri.toString());
2561 String classAttribute = hasError ? ' class="error"' : ''; 2629 String classAttribute = hasError ? ' class="error"' : '';
2562 return '<a href="$href"$classAttribute>$innerHtml</a>'; 2630 return '<a href="$href"$classAttribute>$innerHtml</a>';
2563 } 2631 }
2564 } 2632 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698