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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 import 'package:analyzer/task/model.dart'; | 52 import 'package:analyzer/task/model.dart'; |
53 import 'package:plugin/plugin.dart'; | 53 import 'package:plugin/plugin.dart'; |
54 | 54 |
55 /** | 55 /** |
56 * A function that can be used to generate HTML output into the given [buffer]. | 56 * A function that can be used to generate HTML output into the given [buffer]. |
57 * The HTML that is generated must be valid (special characters must already be | 57 * The HTML that is generated must be valid (special characters must already be |
58 * encoded). | 58 * encoded). |
59 */ | 59 */ |
60 typedef void HtmlGenerator(StringBuffer buffer); | 60 typedef void HtmlGenerator(StringBuffer buffer); |
61 | 61 |
| 62 /** |
| 63 * Instances of the class [AbstractGetHandler] handle GET requests. |
| 64 */ |
| 65 abstract class AbstractGetHandler { |
| 66 /** |
| 67 * Handle a GET request received by the HTTP server. |
| 68 */ |
| 69 void handleGetRequest(HttpRequest request); |
| 70 } |
| 71 |
62 class ElementCounter extends RecursiveElementVisitor { | 72 class ElementCounter extends RecursiveElementVisitor { |
63 Map<Type, int> counts = new HashMap<Type, int>(); | 73 Map<Type, int> counts = new HashMap<Type, int>(); |
64 int elementsWithDocs = 0; | 74 int elementsWithDocs = 0; |
65 int totalDocSpan = 0; | 75 int totalDocSpan = 0; |
66 | 76 |
67 void visit(Element element) { | 77 void visit(Element element) { |
68 String comment = element.documentationComment; | 78 String comment = element.documentationComment; |
69 if (comment != null) { | 79 if (comment != null) { |
70 ++elementsWithDocs; | 80 ++elementsWithDocs; |
71 totalDocSpan += comment.length; | 81 totalDocSpan += comment.length; |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 @override | 200 @override |
191 visitTypeParameterElement(TypeParameterElement element) { | 201 visitTypeParameterElement(TypeParameterElement element) { |
192 visit(element); | 202 visit(element); |
193 super.visitTypeParameterElement(element); | 203 super.visitTypeParameterElement(element); |
194 } | 204 } |
195 } | 205 } |
196 | 206 |
197 /** | 207 /** |
198 * Instances of the class [GetHandler] handle GET requests. | 208 * Instances of the class [GetHandler] handle GET requests. |
199 */ | 209 */ |
200 class GetHandler { | 210 class GetHandler implements AbstractGetHandler { |
201 /** | 211 /** |
202 * The path used to request overall performance information. | 212 * The path used to request overall performance information. |
203 */ | 213 */ |
204 static const String ANALYSIS_PERFORMANCE_PATH = '/perf/analysis'; | 214 static const String ANALYSIS_PERFORMANCE_PATH = '/perf/analysis'; |
205 | 215 |
206 /** | 216 /** |
207 * The path used to request information about a element model. | 217 * The path used to request information about a element model. |
208 */ | 218 */ |
209 static const String AST_PATH = '/ast'; | 219 static const String AST_PATH = '/ast'; |
210 | 220 |
(...skipping 2288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2499 Set<ServerService> services = analysisServer.serverServices; | 2509 Set<ServerService> services = analysisServer.serverServices; |
2500 | 2510 |
2501 buffer.write('<h3>Server Domain</h3>'); | 2511 buffer.write('<h3>Server Domain</h3>'); |
2502 _writeTwoColumns(buffer, (StringBuffer buffer) { | 2512 _writeTwoColumns(buffer, (StringBuffer buffer) { |
2503 if (analysisServer == null) { | 2513 if (analysisServer == null) { |
2504 buffer.write('Status: <span style="color:red">Not running</span>'); | 2514 buffer.write('Status: <span style="color:red">Not running</span>'); |
2505 return; | 2515 return; |
2506 } | 2516 } |
2507 buffer.write('<p>'); | 2517 buffer.write('<p>'); |
2508 buffer.write('Status: Running<br>'); | 2518 buffer.write('Status: Running<br>'); |
| 2519 buffer.write('New analysis driver: '); |
| 2520 buffer.write(analysisServer.options.enableNewAnalysisDriver); |
| 2521 buffer.write('<br>'); |
2509 buffer.write('Instrumentation: '); | 2522 buffer.write('Instrumentation: '); |
2510 if (AnalysisEngine.instance.instrumentationService.isActive) { | 2523 if (AnalysisEngine.instance.instrumentationService.isActive) { |
2511 buffer.write('<span style="color:red">Active</span>'); | 2524 buffer.write('<span style="color:red">Active</span>'); |
2512 } else { | 2525 } else { |
2513 buffer.write('Inactive'); | 2526 buffer.write('Inactive'); |
2514 } | 2527 } |
2515 buffer.write('<br>'); | 2528 buffer.write('<br>'); |
2516 buffer.write('Version: '); | 2529 buffer.write('Version: '); |
2517 buffer.write(AnalysisServer.VERSION); | 2530 buffer.write(AnalysisServer.VERSION); |
2518 buffer.write('<br>'); | 2531 buffer.write('<br>'); |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2731 */ | 2744 */ |
2732 static String makeLink( | 2745 static String makeLink( |
2733 String path, Map<String, String> params, String innerHtml, | 2746 String path, Map<String, String> params, String innerHtml, |
2734 [bool hasError = false]) { | 2747 [bool hasError = false]) { |
2735 Uri uri = new Uri(path: path, queryParameters: params); | 2748 Uri uri = new Uri(path: path, queryParameters: params); |
2736 String href = HTML_ESCAPE.convert(uri.toString()); | 2749 String href = HTML_ESCAPE.convert(uri.toString()); |
2737 String classAttribute = hasError ? ' class="error"' : ''; | 2750 String classAttribute = hasError ? ' class="error"' : ''; |
2738 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 2751 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
2739 } | 2752 } |
2740 } | 2753 } |
OLD | NEW |