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.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 10 matching lines...) Expand all Loading... |
21 import 'package:analysis_server/src/socket_server.dart'; | 21 import 'package:analysis_server/src/socket_server.dart'; |
22 import 'package:analysis_server/src/status/ast_writer.dart'; | 22 import 'package:analysis_server/src/status/ast_writer.dart'; |
23 import 'package:analysis_server/src/status/element_writer.dart'; | 23 import 'package:analysis_server/src/status/element_writer.dart'; |
24 import 'package:analysis_server/src/status/memory_use.dart'; | 24 import 'package:analysis_server/src/status/memory_use.dart'; |
25 import 'package:analysis_server/src/status/validator.dart'; | 25 import 'package:analysis_server/src/status/validator.dart'; |
26 import 'package:analysis_server/src/utilities/average.dart'; | 26 import 'package:analysis_server/src/utilities/average.dart'; |
27 import 'package:analyzer/dart/ast/ast.dart'; | 27 import 'package:analyzer/dart/ast/ast.dart'; |
28 import 'package:analyzer/dart/element/element.dart'; | 28 import 'package:analyzer/dart/element/element.dart'; |
29 import 'package:analyzer/dart/element/visitor.dart'; | 29 import 'package:analyzer/dart/element/visitor.dart'; |
30 import 'package:analyzer/file_system/file_system.dart'; | 30 import 'package:analyzer/file_system/file_system.dart'; |
31 import 'package:analyzer/source/embedder.dart'; | |
32 import 'package:analyzer/source/error_processor.dart'; | 31 import 'package:analyzer/source/error_processor.dart'; |
33 import 'package:analyzer/source/sdk_ext.dart'; | 32 import 'package:analyzer/source/sdk_ext.dart'; |
34 import 'package:analyzer/src/context/cache.dart'; | 33 import 'package:analyzer/src/context/cache.dart'; |
35 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; | 34 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; |
36 import 'package:analyzer/src/context/source.dart'; | 35 import 'package:analyzer/src/context/source.dart'; |
| 36 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
37 import 'package:analyzer/src/generated/engine.dart'; | 37 import 'package:analyzer/src/generated/engine.dart'; |
38 import 'package:analyzer/src/generated/error.dart'; | 38 import 'package:analyzer/src/generated/error.dart'; |
39 import 'package:analyzer/src/generated/java_engine.dart'; | 39 import 'package:analyzer/src/generated/java_engine.dart'; |
40 import 'package:analyzer/src/generated/resolver.dart'; | 40 import 'package:analyzer/src/generated/resolver.dart'; |
41 import 'package:analyzer/src/generated/sdk.dart'; | 41 import 'package:analyzer/src/generated/sdk.dart'; |
42 import 'package:analyzer/src/generated/sdk_io.dart'; | 42 import 'package:analyzer/src/generated/sdk_io.dart'; |
43 import 'package:analyzer/src/generated/source.dart'; | 43 import 'package:analyzer/src/generated/source.dart'; |
44 import 'package:analyzer/src/generated/utilities_collection.dart'; | 44 import 'package:analyzer/src/generated/utilities_collection.dart'; |
45 import 'package:analyzer/src/generated/utilities_general.dart'; | 45 import 'package:analyzer/src/generated/utilities_general.dart'; |
46 import 'package:analyzer/src/services/lint.dart'; | 46 import 'package:analyzer/src/services/lint.dart'; |
(...skipping 616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 tags.forEach((PerformanceTag tag) { | 663 tags.forEach((PerformanceTag tag) { |
664 totalTagTime += tag.elapsedMs; | 664 totalTagTime += tag.elapsedMs; |
665 }); | 665 }); |
666 // write rows | 666 // write rows |
667 void writeRow(PerformanceTag tag) { | 667 void writeRow(PerformanceTag tag) { |
668 double percent = (tag.elapsedMs * 100) / totalTagTime; | 668 double percent = (tag.elapsedMs * 100) / totalTagTime; |
669 String percentStr = '${percent.toStringAsFixed(2)}%'; | 669 String percentStr = '${percent.toStringAsFixed(2)}%'; |
670 _writeRow(buffer, [tag.elapsedMs, percentStr, tag.label], | 670 _writeRow(buffer, [tag.elapsedMs, percentStr, tag.label], |
671 classes: ["right", "right", null]); | 671 classes: ["right", "right", null]); |
672 } | 672 } |
| 673 |
673 tags.forEach(writeRow); | 674 tags.forEach(writeRow); |
674 buffer.write('</table>'); | 675 buffer.write('</table>'); |
675 // | 676 // |
676 // Write target counts. | 677 // Write target counts. |
677 // | 678 // |
678 void incrementCount(Map<String, int> counts, String key) { | 679 void incrementCount(Map<String, int> counts, String key) { |
679 int count = counts[key]; | 680 int count = counts[key]; |
680 if (count == null) { | 681 if (count == null) { |
681 count = 1; | 682 count = 1; |
682 } else { | 683 } else { |
683 count++; | 684 count++; |
684 } | 685 } |
685 counts[key] = count; | 686 counts[key] = count; |
686 } | 687 } |
| 688 |
687 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>(); | 689 Set<AnalysisTarget> countedTargets = new HashSet<AnalysisTarget>(); |
688 Map<String, int> sourceTypeCounts = new HashMap<String, int>(); | 690 Map<String, int> sourceTypeCounts = new HashMap<String, int>(); |
689 Map<String, int> typeCounts = new HashMap<String, int>(); | 691 Map<String, int> typeCounts = new HashMap<String, int>(); |
690 int explicitSourceCount = 0; | 692 int explicitSourceCount = 0; |
691 int explicitLineInfoCount = 0; | 693 int explicitLineInfoCount = 0; |
692 int explicitLineCount = 0; | 694 int explicitLineCount = 0; |
693 int implicitSourceCount = 0; | 695 int implicitSourceCount = 0; |
694 int implicitLineInfoCount = 0; | 696 int implicitLineInfoCount = 0; |
695 int implicitLineCount = 0; | 697 int implicitLineCount = 0; |
696 for (InternalAnalysisContext context | 698 for (InternalAnalysisContext context |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
744 explicitLineInfoCount++; | 746 explicitLineInfoCount++; |
745 } else { | 747 } else { |
746 implicitLineInfoCount++; | 748 implicitLineInfoCount++; |
747 } | 749 } |
748 return previousTotal + lineInfo.lineCount; | 750 return previousTotal + lineInfo.lineCount; |
749 } else { | 751 } else { |
750 return previousTotal; | 752 return previousTotal; |
751 } | 753 } |
752 }); | 754 }); |
753 } | 755 } |
| 756 |
754 explicitSourceCount += explicitSources.length; | 757 explicitSourceCount += explicitSources.length; |
755 explicitLineCount += lineCount(explicitSources, true); | 758 explicitLineCount += lineCount(explicitSources, true); |
756 implicitSourceCount += implicitSources.length; | 759 implicitSourceCount += implicitSources.length; |
757 implicitLineCount += lineCount(implicitSources, false); | 760 implicitLineCount += lineCount(implicitSources, false); |
758 } | 761 } |
759 List<String> sourceTypeNames = sourceTypeCounts.keys.toList(); | 762 List<String> sourceTypeNames = sourceTypeCounts.keys.toList(); |
760 sourceTypeNames.sort(); | 763 sourceTypeNames.sort(); |
761 List<String> typeNames = typeCounts.keys.toList(); | 764 List<String> typeNames = typeCounts.keys.toList(); |
762 typeNames.sort(); | 765 typeNames.sort(); |
763 | 766 |
(...skipping 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1392 buffer.write('</td><td>'); | 1395 buffer.write('</td><td>'); |
1393 if (_overlayContents.containsKey(fileName)) { | 1396 if (_overlayContents.containsKey(fileName)) { |
1394 buffer.write( | 1397 buffer.write( |
1395 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); | 1398 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); |
1396 } | 1399 } |
1397 buffer.write('</td></tr>'); | 1400 buffer.write('</td></tr>'); |
1398 } | 1401 } |
1399 buffer.write('</table></p>'); | 1402 buffer.write('</table></p>'); |
1400 } | 1403 } |
1401 } | 1404 } |
| 1405 |
1402 void writeOptions(StringBuffer buffer, AnalysisOptionsImpl options, | 1406 void writeOptions(StringBuffer buffer, AnalysisOptionsImpl options, |
1403 {void writeAdditionalOptions(StringBuffer buffer)}) { | 1407 {void writeAdditionalOptions(StringBuffer buffer)}) { |
1404 if (options == null) { | 1408 if (options == null) { |
1405 buffer.write('<p>No option information available.</p>'); | 1409 buffer.write('<p>No option information available.</p>'); |
1406 return; | 1410 return; |
1407 } | 1411 } |
1408 buffer.write('<p>'); | 1412 buffer.write('<p>'); |
1409 _writeOption( | 1413 _writeOption( |
1410 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); | 1414 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); |
1411 _writeOption(buffer, 'Cache size', options.cacheSize); | 1415 _writeOption(buffer, 'Cache size', options.cacheSize); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1713 left.toString().compareTo(right.toString())); | 1717 left.toString().compareTo(right.toString())); |
1714 | 1718 |
1715 buffer.write('<h3>$title</h3>'); | 1719 buffer.write('<h3>$title</h3>'); |
1716 buffer.write('<table>'); | 1720 buffer.write('<table>'); |
1717 _writeRow(buffer, ['Count', 'Class name'], header: true); | 1721 _writeRow(buffer, ['Count', 'Class name'], header: true); |
1718 classNames.forEach((Type type) { | 1722 classNames.forEach((Type type) { |
1719 _writeRow(buffer, [counts[type], type], classes: ['right', null]); | 1723 _writeRow(buffer, [counts[type], type], classes: ['right', null]); |
1720 }); | 1724 }); |
1721 buffer.write('</table>'); | 1725 buffer.write('</table>'); |
1722 } | 1726 } |
| 1727 |
1723 writeCountMap('Directly Held AST Nodes', data.directNodeCounts); | 1728 writeCountMap('Directly Held AST Nodes', data.directNodeCounts); |
1724 writeCountMap('Indirectly Held AST Nodes', data.indirectNodeCounts); | 1729 writeCountMap('Indirectly Held AST Nodes', data.indirectNodeCounts); |
1725 writeCountMap('Directly Held Elements', data.elementCounts); | 1730 writeCountMap('Directly Held Elements', data.elementCounts); |
1726 }); | 1731 }); |
1727 }); | 1732 }); |
1728 }); | 1733 }); |
1729 } | 1734 } |
1730 | 1735 |
1731 void _returnOverlayContents(HttpRequest request) { | 1736 void _returnOverlayContents(HttpRequest request) { |
1732 String path = request.requestedUri.queryParameters[PATH_PARAM]; | 1737 String path = request.requestedUri.queryParameters[PATH_PARAM]; |
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2411 * Write the recent output section (on the main status page) to the given | 2416 * Write the recent output section (on the main status page) to the given |
2412 * [buffer] object. | 2417 * [buffer] object. |
2413 */ | 2418 */ |
2414 void _writePluginStatus(StringBuffer buffer) { | 2419 void _writePluginStatus(StringBuffer buffer) { |
2415 void writePlugin(Plugin plugin) { | 2420 void writePlugin(Plugin plugin) { |
2416 buffer.write(plugin.uniqueIdentifier); | 2421 buffer.write(plugin.uniqueIdentifier); |
2417 buffer.write(' ('); | 2422 buffer.write(' ('); |
2418 buffer.write(plugin.runtimeType); | 2423 buffer.write(plugin.runtimeType); |
2419 buffer.write(')<br>'); | 2424 buffer.write(')<br>'); |
2420 } | 2425 } |
| 2426 |
2421 buffer.write('<h3>Plugin Status</h3><p>'); | 2427 buffer.write('<h3>Plugin Status</h3><p>'); |
2422 writePlugin(AnalysisEngine.instance.enginePlugin); | 2428 writePlugin(AnalysisEngine.instance.enginePlugin); |
2423 writePlugin(_server.serverPlugin); | 2429 writePlugin(_server.serverPlugin); |
2424 for (Plugin plugin in _server.analysisServer.userDefinedPlugins) { | 2430 for (Plugin plugin in _server.analysisServer.userDefinedPlugins) { |
2425 writePlugin(plugin); | 2431 writePlugin(plugin); |
2426 } | 2432 } |
2427 buffer.write('<p>'); | 2433 buffer.write('<p>'); |
2428 } | 2434 } |
2429 | 2435 |
2430 /** | 2436 /** |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2737 */ | 2743 */ |
2738 static String makeLink( | 2744 static String makeLink( |
2739 String path, Map<String, String> params, String innerHtml, | 2745 String path, Map<String, String> params, String innerHtml, |
2740 [bool hasError = false]) { | 2746 [bool hasError = false]) { |
2741 Uri uri = new Uri(path: path, queryParameters: params); | 2747 Uri uri = new Uri(path: path, queryParameters: params); |
2742 String href = HTML_ESCAPE.convert(uri.toString()); | 2748 String href = HTML_ESCAPE.convert(uri.toString()); |
2743 String classAttribute = hasError ? ' class="error"' : ''; | 2749 String classAttribute = hasError ? ' class="error"' : ''; |
2744 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 2750 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
2745 } | 2751 } |
2746 } | 2752 } |
OLD | NEW |