| 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 library analysis_server.src.get_handler; | 5 library analysis_server.src.get_handler; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 import 'dart:convert'; | 9 import 'dart:convert'; |
| 10 import 'dart:io'; | 10 import 'dart:io'; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 /** | 167 /** |
| 168 * Return the active [CompletionDomainHandler] | 168 * Return the active [CompletionDomainHandler] |
| 169 * or `null` if either analysis server is not running | 169 * or `null` if either analysis server is not running |
| 170 * or there is no completion domain handler. | 170 * or there is no completion domain handler. |
| 171 */ | 171 */ |
| 172 CompletionDomainHandler get _completionDomainHandler { | 172 CompletionDomainHandler get _completionDomainHandler { |
| 173 AnalysisServer analysisServer = _server.analysisServer; | 173 AnalysisServer analysisServer = _server.analysisServer; |
| 174 if (analysisServer == null) { | 174 if (analysisServer == null) { |
| 175 return null; | 175 return null; |
| 176 } | 176 } |
| 177 return analysisServer.handlers.firstWhere( | 177 return analysisServer.handlers |
| 178 (h) => h is CompletionDomainHandler, orElse: () => null); | 178 .firstWhere((h) => h is CompletionDomainHandler, orElse: () => null); |
| 179 } | 179 } |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * Handle a GET request received by the HTTP server. | 182 * Handle a GET request received by the HTTP server. |
| 183 */ | 183 */ |
| 184 void handleGetRequest(HttpRequest request) { | 184 void handleGetRequest(HttpRequest request) { |
| 185 String path = request.uri.path; | 185 String path = request.uri.path; |
| 186 if (path == STATUS_PATH) { | 186 if (path == STATUS_PATH) { |
| 187 _returnServerStatus(request); | 187 _returnServerStatus(request); |
| 188 } else if (path == ANALYSIS_PERFORMANCE_PATH) { | 188 } else if (path == ANALYSIS_PERFORMANCE_PATH) { |
| (...skipping 22 matching lines...) Expand all Loading... |
| 211 _returnUnknownRequest(request); | 211 _returnUnknownRequest(request); |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * Return the folder being managed by the given [analysisServer] that matches | 216 * Return the folder being managed by the given [analysisServer] that matches |
| 217 * the given [contextFilter], or `null` if there is none. | 217 * the given [contextFilter], or `null` if there is none. |
| 218 */ | 218 */ |
| 219 Folder _findFolder(AnalysisServer analysisServer, String contextFilter) { | 219 Folder _findFolder(AnalysisServer analysisServer, String contextFilter) { |
| 220 return analysisServer.folderMap.keys.firstWhere( | 220 return analysisServer.folderMap.keys.firstWhere( |
| 221 (Folder folder) => folder.path == contextFilter, orElse: () => null); | 221 (Folder folder) => folder.path == contextFilter, |
| 222 orElse: () => null); |
| 222 } | 223 } |
| 223 | 224 |
| 224 /** | 225 /** |
| 225 * Return `true` if the given analysis [context] has at least one entry with | 226 * Return `true` if the given analysis [context] has at least one entry with |
| 226 * an exception. | 227 * an exception. |
| 227 */ | 228 */ |
| 228 bool _hasException(AnalysisContextImpl context) { | 229 bool _hasException(AnalysisContextImpl context) { |
| 229 bool hasException = false; | 230 bool hasException = false; |
| 230 context.visitCacheItems((Source source, SourceEntry sourceEntry, | 231 context.visitCacheItems((Source source, SourceEntry sourceEntry, |
| 231 DataDescriptor rowDesc, CacheState state) { | 232 DataDescriptor rowDesc, CacheState state) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 buffer.write('</table>'); | 293 buffer.write('</table>'); |
| 293 } | 294 } |
| 294 | 295 |
| 295 // | 296 // |
| 296 // Write new task model timing information. | 297 // Write new task model timing information. |
| 297 // | 298 // |
| 298 if (AnalysisEngine.instance.useTaskModel) { | 299 if (AnalysisEngine.instance.useTaskModel) { |
| 299 buffer.write('<p><b>Task performace data</b></p>'); | 300 buffer.write('<p><b>Task performace data</b></p>'); |
| 300 buffer.write( | 301 buffer.write( |
| 301 '<table style="border-collapse: separate; border-spacing: 10px 5px
;">'); | 302 '<table style="border-collapse: separate; border-spacing: 10px 5px
;">'); |
| 302 _writeRow(buffer, [ | 303 _writeRow( |
| 303 'Task Name', | 304 buffer, |
| 304 'Count', | 305 [ |
| 305 'Total Time (in ms)', | 306 'Task Name', |
| 306 'Average Time (in ms)' | 307 'Count', |
| 307 ], header: true); | 308 'Total Time (in ms)', |
| 309 'Average Time (in ms)' |
| 310 ], |
| 311 header: true); |
| 308 | 312 |
| 309 Map<Type, int> countMap = newTask.AnalysisTask.countMap; | 313 Map<Type, int> countMap = newTask.AnalysisTask.countMap; |
| 310 Map<Type, Stopwatch> stopwatchMap = newTask.AnalysisTask.stopwatchMap; | 314 Map<Type, Stopwatch> stopwatchMap = newTask.AnalysisTask.stopwatchMap; |
| 311 List<Type> taskClasses = stopwatchMap.keys.toList(); | 315 List<Type> taskClasses = stopwatchMap.keys.toList(); |
| 312 taskClasses.sort((Type first, Type second) => | 316 taskClasses.sort((Type first, Type second) => |
| 313 first.toString().compareTo(second.toString())); | 317 first.toString().compareTo(second.toString())); |
| 314 int totalTime = 0; | 318 int totalTime = 0; |
| 315 taskClasses.forEach((Type taskClass) { | 319 taskClasses.forEach((Type taskClass) { |
| 316 int count = countMap[taskClass]; | 320 int count = countMap[taskClass]; |
| 317 if (count == null) { | 321 if (count == null) { |
| 318 count = 0; | 322 count = 0; |
| 319 } | 323 } |
| 320 int taskTime = stopwatchMap[taskClass].elapsedMilliseconds; | 324 int taskTime = stopwatchMap[taskClass].elapsedMilliseconds; |
| 321 totalTime += taskTime; | 325 totalTime += taskTime; |
| 322 _writeRow(buffer, [ | 326 _writeRow(buffer, [ |
| 323 taskClass.toString(), | 327 taskClass.toString(), |
| 324 count, | 328 count, |
| 325 taskTime, | 329 taskTime, |
| 326 count <= 0 ? '-' : (taskTime / count).toStringAsFixed(3) | 330 count <= 0 ? '-' : (taskTime / count).toStringAsFixed(3) |
| 327 ], classes: [null, "right", "right", "right"]); | 331 ], classes: [ |
| 332 null, |
| 333 "right", |
| 334 "right", |
| 335 "right" |
| 336 ]); |
| 328 }); | 337 }); |
| 329 _writeRow(buffer, ['Total', '-', totalTime, '-'], | 338 _writeRow(buffer, ['Total', '-', totalTime, '-'], |
| 330 classes: [null, "right", "right", "right"]); | 339 classes: [null, "right", "right", "right"]); |
| 331 buffer.write('</table>'); | 340 buffer.write('</table>'); |
| 332 } | 341 } |
| 333 | 342 |
| 334 // | 343 // |
| 335 // Write old task model transition information. | 344 // Write old task model transition information. |
| 336 // | 345 // |
| 337 { | 346 { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 } | 394 } |
| 386 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; | 395 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; |
| 387 if (sourceUri == null) { | 396 if (sourceUri == null) { |
| 388 return _returnFailure( | 397 return _returnFailure( |
| 389 request, 'Query parameter $SOURCE_QUERY_PARAM required'); | 398 request, 'Query parameter $SOURCE_QUERY_PARAM required'); |
| 390 } | 399 } |
| 391 | 400 |
| 392 AnalysisContextImpl context = analysisServer.folderMap[folder]; | 401 AnalysisContextImpl context = analysisServer.folderMap[folder]; |
| 393 | 402 |
| 394 _writeResponse(request, (StringBuffer buffer) { | 403 _writeResponse(request, (StringBuffer buffer) { |
| 395 _writePage(buffer, 'Analysis Server - AST Structure', [ | 404 _writePage(buffer, 'Analysis Server - AST Structure', |
| 396 'Context: $contextFilter', | 405 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) { |
| 397 'File: $sourceUri' | |
| 398 ], (HttpResponse) { | |
| 399 Source source = context.sourceFactory.forUri(sourceUri); | 406 Source source = context.sourceFactory.forUri(sourceUri); |
| 400 if (source == null) { | 407 if (source == null) { |
| 401 buffer.write('<p>Not found.</p>'); | 408 buffer.write('<p>Not found.</p>'); |
| 402 return; | 409 return; |
| 403 } | 410 } |
| 404 SourceEntry entry = context.getReadableSourceEntryOrNull(source); | 411 SourceEntry entry = context.getReadableSourceEntryOrNull(source); |
| 405 if (entry == null) { | 412 if (entry == null) { |
| 406 buffer.write('<p>Not found.</p>'); | 413 buffer.write('<p>Not found.</p>'); |
| 407 return; | 414 return; |
| 408 } | 415 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 458 allContexts.add(folder); | 465 allContexts.add(folder); |
| 459 entryMap[folder] = entry; | 466 entryMap[folder] = entry; |
| 460 } | 467 } |
| 461 } | 468 } |
| 462 }); | 469 }); |
| 463 allContexts.sort((Folder firstFolder, Folder secondFolder) => | 470 allContexts.sort((Folder firstFolder, Folder secondFolder) => |
| 464 firstFolder.path.compareTo(secondFolder.path)); | 471 firstFolder.path.compareTo(secondFolder.path)); |
| 465 AnalysisContextImpl context = analysisServer.folderMap[folder]; | 472 AnalysisContextImpl context = analysisServer.folderMap[folder]; |
| 466 | 473 |
| 467 _writeResponse(request, (StringBuffer buffer) { | 474 _writeResponse(request, (StringBuffer buffer) { |
| 468 _writePage(buffer, 'Analysis Server - Cache Entry', [ | 475 _writePage(buffer, 'Analysis Server - Cache Entry', |
| 469 'Context: $contextFilter', | 476 ['Context: $contextFilter', 'File: $sourceUri'], (HttpResponse) { |
| 470 'File: $sourceUri' | |
| 471 ], (HttpResponse) { | |
| 472 buffer.write('<h3>Analyzing Contexts</h3><p>'); | 477 buffer.write('<h3>Analyzing Contexts</h3><p>'); |
| 473 bool first = true; | 478 bool first = true; |
| 474 allContexts.forEach((Folder folder) { | 479 allContexts.forEach((Folder folder) { |
| 475 if (first) { | 480 if (first) { |
| 476 first = false; | 481 first = false; |
| 477 } else { | 482 } else { |
| 478 buffer.write('<br>'); | 483 buffer.write('<br>'); |
| 479 } | 484 } |
| 480 AnalysisContextImpl analyzingContext = | 485 AnalysisContextImpl analyzingContext = |
| 481 analysisServer.folderMap[folder]; | 486 analysisServer.folderMap[folder]; |
| 482 if (analyzingContext == context) { | 487 if (analyzingContext == context) { |
| 483 buffer.write(folder.path); | 488 buffer.write(folder.path); |
| 484 } else { | 489 } else { |
| 485 buffer.write(makeLink(CACHE_ENTRY_PATH, { | 490 buffer.write(makeLink( |
| 486 CONTEXT_QUERY_PARAM: folder.path, | 491 CACHE_ENTRY_PATH, |
| 487 SOURCE_QUERY_PARAM: sourceUri | 492 { |
| 488 }, HTML_ESCAPE.convert(folder.path))); | 493 CONTEXT_QUERY_PARAM: folder.path, |
| 494 SOURCE_QUERY_PARAM: sourceUri |
| 495 }, |
| 496 HTML_ESCAPE.convert(folder.path))); |
| 489 } | 497 } |
| 490 if (entryMap[folder].explicitlyAdded) { | 498 if (entryMap[folder].explicitlyAdded) { |
| 491 buffer.write(' (explicit)'); | 499 buffer.write(' (explicit)'); |
| 492 } else { | 500 } else { |
| 493 buffer.write(' (implicit)'); | 501 buffer.write(' (implicit)'); |
| 494 } | 502 } |
| 495 }); | 503 }); |
| 496 buffer.write('</p>'); | 504 buffer.write('</p>'); |
| 497 | 505 |
| 498 SourceEntry entry = entryMap[folder]; | 506 SourceEntry entry = entryMap[folder]; |
| 499 if (entry == null) { | 507 if (entry == null) { |
| 500 buffer.write('<p>Not being analyzed in this context.</p>'); | 508 buffer.write('<p>Not being analyzed in this context.</p>'); |
| 501 return; | 509 return; |
| 502 } | 510 } |
| 503 Map<String, String> linkParameters = <String, String>{ | 511 Map<String, String> linkParameters = <String, String>{ |
| 504 CONTEXT_QUERY_PARAM: folder.path, | 512 CONTEXT_QUERY_PARAM: folder.path, |
| 505 SOURCE_QUERY_PARAM: sourceUri | 513 SOURCE_QUERY_PARAM: sourceUri |
| 506 }; | 514 }; |
| 507 | 515 |
| 508 buffer.write('<h3>Library Independent</h3>'); | 516 buffer.write('<h3>Library Independent</h3>'); |
| 509 _writeDescriptorTable(buffer, entry.descriptors, entry.getState, | 517 _writeDescriptorTable(buffer, entry.descriptors, entry.getState, |
| 510 entry.getValue, linkParameters); | 518 entry.getValue, linkParameters); |
| 511 if (entry is DartEntry) { | 519 if (entry is DartEntry) { |
| 512 for (Source librarySource in entry.containingLibraries) { | 520 for (Source librarySource in entry.containingLibraries) { |
| 513 String libraryName = HTML_ESCAPE.convert(librarySource.fullName); | 521 String libraryName = HTML_ESCAPE.convert(librarySource.fullName); |
| 514 buffer.write('<h3>In library $libraryName:</h3>'); | 522 buffer.write('<h3>In library $libraryName:</h3>'); |
| 515 _writeDescriptorTable(buffer, entry.libraryDescriptors, | 523 _writeDescriptorTable( |
| 524 buffer, |
| 525 entry.libraryDescriptors, |
| 516 (DataDescriptor descriptor) => | 526 (DataDescriptor descriptor) => |
| 517 entry.getStateInLibrary(descriptor, librarySource), | 527 entry.getStateInLibrary(descriptor, librarySource), |
| 518 (DataDescriptor descriptor) => | 528 (DataDescriptor descriptor) => |
| 519 entry.getValueInLibrary(descriptor, librarySource), | 529 entry.getValueInLibrary(descriptor, librarySource), |
| 520 linkParameters); | 530 linkParameters); |
| 521 } | 531 } |
| 522 } | 532 } |
| 523 if (entry.exception != null) { | 533 if (entry.exception != null) { |
| 524 buffer.write('<h3>Exception</h3>'); | 534 buffer.write('<h3>Exception</h3>'); |
| 525 _writeException(buffer, entry.exception); | 535 _writeException(buffer, entry.exception); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 568 } | 578 } |
| 569 | 579 |
| 570 Folder folder = _findFolder(analysisServer, contextFilter); | 580 Folder folder = _findFolder(analysisServer, contextFilter); |
| 571 AnalysisContextImpl context = analysisServer.folderMap[folder]; | 581 AnalysisContextImpl context = analysisServer.folderMap[folder]; |
| 572 List<String> links = <String>[]; | 582 List<String> links = <String>[]; |
| 573 context.visitCacheItems((Source source, SourceEntry dartEntry, | 583 context.visitCacheItems((Source source, SourceEntry dartEntry, |
| 574 DataDescriptor rowDesc, CacheState state) { | 584 DataDescriptor rowDesc, CacheState state) { |
| 575 if (state != stateFilter || rowDesc.toString() != descriptorFilter) { | 585 if (state != stateFilter || rowDesc.toString() != descriptorFilter) { |
| 576 return; | 586 return; |
| 577 } | 587 } |
| 578 String link = makeLink(CACHE_ENTRY_PATH, { | 588 String link = makeLink( |
| 579 CONTEXT_QUERY_PARAM: folder.path, | 589 CACHE_ENTRY_PATH, |
| 580 SOURCE_QUERY_PARAM: source.uri.toString() | 590 { |
| 581 }, HTML_ESCAPE.convert(source.fullName)); | 591 CONTEXT_QUERY_PARAM: folder.path, |
| 592 SOURCE_QUERY_PARAM: source.uri.toString() |
| 593 }, |
| 594 HTML_ESCAPE.convert(source.fullName)); |
| 582 links.add(link); | 595 links.add(link); |
| 583 }); | 596 }); |
| 584 | 597 |
| 585 _writeResponse(request, (StringBuffer buffer) { | 598 _writeResponse(request, (StringBuffer buffer) { |
| 586 _writePage(buffer, 'Analysis Server - Cache Search', [ | 599 _writePage(buffer, 'Analysis Server - Cache Search', [ |
| 587 'Context: $contextFilter', | 600 'Context: $contextFilter', |
| 588 'Descriptor: ${HTML_ESCAPE.convert(descriptorFilter)}', | 601 'Descriptor: ${HTML_ESCAPE.convert(descriptorFilter)}', |
| 589 'State: ${HTML_ESCAPE.convert(stateQueryParam)}' | 602 'State: ${HTML_ESCAPE.convert(stateQueryParam)}' |
| 590 ], (StringBuffer buffer) { | 603 ], (StringBuffer buffer) { |
| 591 buffer.write('<p>${links.length} files found</p>'); | 604 buffer.write('<p>${links.length} files found</p>'); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 .map((Source source) => source.fullName) | 723 .map((Source source) => source.fullName) |
| 711 .toList(); | 724 .toList(); |
| 712 context.visitCacheItems((Source source, SourceEntry sourceEntry, | 725 context.visitCacheItems((Source source, SourceEntry sourceEntry, |
| 713 DataDescriptor rowDesc, CacheState state) { | 726 DataDescriptor rowDesc, CacheState state) { |
| 714 String sourceName = source.fullName; | 727 String sourceName = source.fullName; |
| 715 if (!links.containsKey(sourceName)) { | 728 if (!links.containsKey(sourceName)) { |
| 716 CaughtException exception = sourceEntry.exception; | 729 CaughtException exception = sourceEntry.exception; |
| 717 if (exception != null) { | 730 if (exception != null) { |
| 718 exceptions.add(exception); | 731 exceptions.add(exception); |
| 719 } | 732 } |
| 720 String link = makeLink(CACHE_ENTRY_PATH, { | 733 String link = makeLink( |
| 721 CONTEXT_QUERY_PARAM: folder.path, | 734 CACHE_ENTRY_PATH, |
| 722 SOURCE_QUERY_PARAM: source.uri.toString() | 735 { |
| 723 }, sourceName, exception != null); | 736 CONTEXT_QUERY_PARAM: folder.path, |
| 737 SOURCE_QUERY_PARAM: source.uri.toString() |
| 738 }, |
| 739 sourceName, |
| 740 exception != null); |
| 724 if (sourceEntry.explicitlyAdded) { | 741 if (sourceEntry.explicitlyAdded) { |
| 725 explicitNames.add(sourceName); | 742 explicitNames.add(sourceName); |
| 726 } else { | 743 } else { |
| 727 implicitNames.add(sourceName); | 744 implicitNames.add(sourceName); |
| 728 } | 745 } |
| 729 links[sourceName] = link; | 746 links[sourceName] = link; |
| 730 } | 747 } |
| 731 }); | 748 }); |
| 732 explicitNames.sort(); | 749 explicitNames.sort(); |
| 733 implicitNames.sort(); | 750 implicitNames.sort(); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 752 buffer.write( | 769 buffer.write( |
| 753 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); | 770 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); |
| 754 } | 771 } |
| 755 buffer.write('</td></tr>'); | 772 buffer.write('</td></tr>'); |
| 756 } | 773 } |
| 757 buffer.write('</table>'); | 774 buffer.write('</table>'); |
| 758 } | 775 } |
| 759 } | 776 } |
| 760 | 777 |
| 761 _writeResponse(request, (StringBuffer buffer) { | 778 _writeResponse(request, (StringBuffer buffer) { |
| 762 _writePage(buffer, 'Analysis Server - Context', | 779 _writePage( |
| 763 ['Context: $contextFilter'], (StringBuffer buffer) { | 780 buffer, 'Analysis Server - Context', ['Context: $contextFilter'], |
| 781 (StringBuffer buffer) { |
| 764 List headerRowText = ['Context']; | 782 List headerRowText = ['Context']; |
| 765 headerRowText.addAll(CacheState.values); | 783 headerRowText.addAll(CacheState.values); |
| 766 buffer.write('<h3>Summary</h3>'); | 784 buffer.write('<h3>Summary</h3>'); |
| 767 buffer.write('<table>'); | 785 buffer.write('<table>'); |
| 768 _writeRow(buffer, headerRowText, header: true); | 786 _writeRow(buffer, headerRowText, header: true); |
| 769 AnalysisContextStatistics statistics = context.statistics; | 787 AnalysisContextStatistics statistics = context.statistics; |
| 770 statistics.cacheRows.forEach((AnalysisContextStatistics_CacheRow row) { | 788 statistics.cacheRows.forEach((AnalysisContextStatistics_CacheRow row) { |
| 771 List rowText = [row.name]; | 789 List rowText = [row.name]; |
| 772 for (CacheState state in CacheState.values) { | 790 for (CacheState state in CacheState.values) { |
| 773 String text = row.getCount(state).toString(); | 791 String text = row.getCount(state).toString(); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 } | 895 } |
| 878 if (index is LocalIndex) { | 896 if (index is LocalIndex) { |
| 879 Map<List<String>, List<InspectLocation>> relations = | 897 Map<List<String>, List<InspectLocation>> relations = |
| 880 await index.findElementsByName(name); | 898 await index.findElementsByName(name); |
| 881 _writeResponse(request, (StringBuffer buffer) { | 899 _writeResponse(request, (StringBuffer buffer) { |
| 882 _writePage(buffer, 'Analysis Server - Index Elements', ['Name: $name'], | 900 _writePage(buffer, 'Analysis Server - Index Elements', ['Name: $name'], |
| 883 (StringBuffer buffer) { | 901 (StringBuffer buffer) { |
| 884 buffer.write('<table border="1">'); | 902 buffer.write('<table border="1">'); |
| 885 _writeRow(buffer, ['Element', 'Relationship', 'Location'], | 903 _writeRow(buffer, ['Element', 'Relationship', 'Location'], |
| 886 header: true); | 904 header: true); |
| 887 relations.forEach((List<String> elementPath, | 905 relations.forEach( |
| 888 List<InspectLocation> relations) { | 906 (List<String> elementPath, List<InspectLocation> relations) { |
| 889 String elementLocation = elementPath.join(' '); | 907 String elementLocation = elementPath.join(' '); |
| 890 relations.forEach((InspectLocation location) { | 908 relations.forEach((InspectLocation location) { |
| 891 var relString = location.relationship.identifier; | 909 var relString = location.relationship.identifier; |
| 892 var locString = '${location.path} offset=${location.offset} ' | 910 var locString = '${location.path} offset=${location.offset} ' |
| 893 'length=${location.length} flags=${location.flags}'; | 911 'length=${location.length} flags=${location.flags}'; |
| 894 _writeRow(buffer, [elementLocation, relString, locString]); | 912 _writeRow(buffer, [elementLocation, relString, locString]); |
| 895 }); | 913 }); |
| 896 }); | 914 }); |
| 897 buffer.write('</table>'); | 915 buffer.write('</table>'); |
| 898 }); | 916 }); |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1034 buffer.write('<p><b>Analysis Contexts</b></p>'); | 1052 buffer.write('<p><b>Analysis Contexts</b></p>'); |
| 1035 buffer.write('<p>'); | 1053 buffer.write('<p>'); |
| 1036 bool first = true; | 1054 bool first = true; |
| 1037 folders.forEach((Folder folder) { | 1055 folders.forEach((Folder folder) { |
| 1038 if (first) { | 1056 if (first) { |
| 1039 first = false; | 1057 first = false; |
| 1040 } else { | 1058 } else { |
| 1041 buffer.write('<br>'); | 1059 buffer.write('<br>'); |
| 1042 } | 1060 } |
| 1043 String key = folder.shortName; | 1061 String key = folder.shortName; |
| 1044 buffer.write(makeLink(CONTEXT_PATH, { | 1062 buffer.write(makeLink(CONTEXT_PATH, {CONTEXT_QUERY_PARAM: folder.path}, |
| 1045 CONTEXT_QUERY_PARAM: folder.path | 1063 key, _hasException(folderMap[folder]))); |
| 1046 }, key, _hasException(folderMap[folder]))); | |
| 1047 }); | 1064 }); |
| 1048 buffer.write('</p>'); | 1065 buffer.write('</p>'); |
| 1049 | 1066 |
| 1050 buffer.write('<p><b>Options</b></p>'); | 1067 buffer.write('<p><b>Options</b></p>'); |
| 1051 buffer.write('<p>'); | 1068 buffer.write('<p>'); |
| 1052 _writeOption( | 1069 _writeOption( |
| 1053 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); | 1070 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); |
| 1054 _writeOption(buffer, 'Cache size', options.cacheSize); | 1071 _writeOption(buffer, 'Cache size', options.cacheSize); |
| 1055 _writeOption( | 1072 _writeOption( |
| 1056 buffer, 'Enable strict call checks', options.enableStrictCallChecks); | 1073 buffer, 'Enable strict call checks', options.enableStrictCallChecks); |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1123 * Write a table showing summary information for the last several | 1140 * Write a table showing summary information for the last several |
| 1124 * completion requests to the given [buffer] object. | 1141 * completion requests to the given [buffer] object. |
| 1125 */ | 1142 */ |
| 1126 void _writeCompletionPerformanceList(StringBuffer buffer) { | 1143 void _writeCompletionPerformanceList(StringBuffer buffer) { |
| 1127 CompletionDomainHandler handler = _completionDomainHandler; | 1144 CompletionDomainHandler handler = _completionDomainHandler; |
| 1128 buffer.write('<h3>Completion Performance List</h3>'); | 1145 buffer.write('<h3>Completion Performance List</h3>'); |
| 1129 if (handler == null) { | 1146 if (handler == null) { |
| 1130 return; | 1147 return; |
| 1131 } | 1148 } |
| 1132 buffer.write('<table>'); | 1149 buffer.write('<table>'); |
| 1133 _writeRow(buffer, [ | 1150 _writeRow( |
| 1134 'Start Time', | 1151 buffer, |
| 1135 '', | 1152 [ |
| 1136 'First (ms)', | 1153 'Start Time', |
| 1137 '', | 1154 '', |
| 1138 'Complete (ms)', | 1155 'First (ms)', |
| 1139 '', | 1156 '', |
| 1140 '# Notifications', | 1157 'Complete (ms)', |
| 1141 '', | 1158 '', |
| 1142 '# Suggestions', | 1159 '# Notifications', |
| 1143 '', | 1160 '', |
| 1144 'Snippet' | 1161 '# Suggestions', |
| 1145 ], header: true); | 1162 '', |
| 1163 'Snippet' |
| 1164 ], |
| 1165 header: true); |
| 1146 int index = 0; | 1166 int index = 0; |
| 1147 for (CompletionPerformance performance in handler.performanceList) { | 1167 for (CompletionPerformance performance in handler.performanceList) { |
| 1148 String link = makeLink(COMPLETION_PATH, { | 1168 String link = makeLink(COMPLETION_PATH, {'index': '$index'}, |
| 1149 'index': '$index' | 1169 '${performance.startTimeAndMs}'); |
| 1150 }, '${performance.startTimeAndMs}'); | |
| 1151 _writeRow(buffer, [ | 1170 _writeRow(buffer, [ |
| 1152 link, | 1171 link, |
| 1153 ' ', | 1172 ' ', |
| 1154 performance.firstNotificationInMilliseconds, | 1173 performance.firstNotificationInMilliseconds, |
| 1155 ' ', | 1174 ' ', |
| 1156 performance.elapsedInMilliseconds, | 1175 performance.elapsedInMilliseconds, |
| 1157 ' ', | 1176 ' ', |
| 1158 performance.notificationCount, | 1177 performance.notificationCount, |
| 1159 ' ', | 1178 ' ', |
| 1160 performance.suggestionCount, | 1179 performance.suggestionCount, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1182 } | 1201 } |
| 1183 | 1202 |
| 1184 /** | 1203 /** |
| 1185 * Generate a table showing the cache values corresponding to the given | 1204 * Generate a table showing the cache values corresponding to the given |
| 1186 * [descriptors], using [getState] to get the cache state corresponding to | 1205 * [descriptors], using [getState] to get the cache state corresponding to |
| 1187 * each descriptor, and [getValue] to get the cached value corresponding to | 1206 * each descriptor, and [getValue] to get the cached value corresponding to |
| 1188 * each descriptor. Append the resulting HTML to the given [buffer]. The | 1207 * each descriptor. Append the resulting HTML to the given [buffer]. The |
| 1189 * [linkParameters] will be used if the value is too large to be displayed on | 1208 * [linkParameters] will be used if the value is too large to be displayed on |
| 1190 * the current page and needs to be linked to a separate page. | 1209 * the current page and needs to be linked to a separate page. |
| 1191 */ | 1210 */ |
| 1192 void _writeDescriptorTable(StringBuffer buffer, | 1211 void _writeDescriptorTable( |
| 1193 List<DataDescriptor> descriptors, CacheState getState(DataDescriptor), | 1212 StringBuffer buffer, |
| 1194 dynamic getValue(DataDescriptor), Map<String, String> linkParameters) { | 1213 List<DataDescriptor> descriptors, |
| 1214 CacheState getState(DataDescriptor), |
| 1215 dynamic getValue(DataDescriptor), |
| 1216 Map<String, String> linkParameters) { |
| 1195 buffer.write('<dl>'); | 1217 buffer.write('<dl>'); |
| 1196 for (DataDescriptor descriptor in descriptors) { | 1218 for (DataDescriptor descriptor in descriptors) { |
| 1197 String descriptorName = HTML_ESCAPE.convert(descriptor.toString()); | 1219 String descriptorName = HTML_ESCAPE.convert(descriptor.toString()); |
| 1198 String descriptorState = | 1220 String descriptorState = |
| 1199 HTML_ESCAPE.convert(getState(descriptor).toString()); | 1221 HTML_ESCAPE.convert(getState(descriptor).toString()); |
| 1200 buffer.write('<dt>$descriptorName ($descriptorState)</dt><dd>'); | 1222 buffer.write('<dt>$descriptorName ($descriptorState)</dt><dd>'); |
| 1201 try { | 1223 try { |
| 1202 _writeValueAsHtml(buffer, getValue(descriptor), linkParameters); | 1224 _writeValueAsHtml(buffer, getValue(descriptor), linkParameters); |
| 1203 } catch (exception) { | 1225 } catch (exception) { |
| 1204 buffer.write('(${HTML_ESCAPE.convert(exception.toString())})'); | 1226 buffer.write('(${HTML_ESCAPE.convert(exception.toString())})'); |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1624 */ | 1646 */ |
| 1625 static String makeLink( | 1647 static String makeLink( |
| 1626 String path, Map<String, String> params, String innerHtml, | 1648 String path, Map<String, String> params, String innerHtml, |
| 1627 [bool hasError = false]) { | 1649 [bool hasError = false]) { |
| 1628 Uri uri = new Uri(path: path, queryParameters: params); | 1650 Uri uri = new Uri(path: path, queryParameters: params); |
| 1629 String href = HTML_ESCAPE.convert(uri.toString()); | 1651 String href = HTML_ESCAPE.convert(uri.toString()); |
| 1630 String classAttribute = hasError ? ' class="error"' : ''; | 1652 String classAttribute = hasError ? ' class="error"' : ''; |
| 1631 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 1653 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
| 1632 } | 1654 } |
| 1633 } | 1655 } |
| OLD | NEW |