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: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 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 * Buffer containing strings printed by the analysis server. | 177 * Buffer containing strings printed by the analysis server. |
178 */ | 178 */ |
179 List<String> _printBuffer; | 179 List<String> _printBuffer; |
180 | 180 |
181 /** | 181 /** |
182 * Contents of overlay files. | 182 * Contents of overlay files. |
183 */ | 183 */ |
184 final Map<String, String> _overlayContents = <String, String>{}; | 184 final Map<String, String> _overlayContents = <String, String>{}; |
185 | 185 |
186 /** | 186 /** |
| 187 * Handler for diagnostics requests. |
| 188 */ |
| 189 DiagnosticDomainHandler _diagnosticHandler; |
| 190 |
| 191 /** |
187 * Initialize a newly created handler for GET requests. | 192 * Initialize a newly created handler for GET requests. |
188 */ | 193 */ |
189 GetHandler(this._server, this._printBuffer); | 194 GetHandler(this._server, this._printBuffer); |
190 | 195 |
| 196 DiagnosticDomainHandler get diagnosticHandler { |
| 197 if (_diagnosticHandler == null) { |
| 198 _diagnosticHandler = new DiagnosticDomainHandler(_server.analysisServer); |
| 199 } |
| 200 return _diagnosticHandler; |
| 201 } |
| 202 |
191 /** | 203 /** |
192 * Return the active [CompletionDomainHandler] | 204 * Return the active [CompletionDomainHandler] |
193 * or `null` if either analysis server is not running | 205 * or `null` if either analysis server is not running |
194 * or there is no completion domain handler. | 206 * or there is no completion domain handler. |
195 */ | 207 */ |
196 CompletionDomainHandler get _completionDomainHandler { | 208 CompletionDomainHandler get _completionDomainHandler { |
197 AnalysisServer analysisServer = _server.analysisServer; | 209 AnalysisServer analysisServer = _server.analysisServer; |
198 if (analysisServer == null) { | 210 if (analysisServer == null) { |
199 return null; | 211 return null; |
200 } | 212 } |
(...skipping 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1477 sent to the client in the first notification, followed by a comma, | 1489 sent to the client in the first notification, followed by a comma, |
1478 followed by the number of suggestions send to the client | 1490 followed by the number of suggestions send to the client |
1479 in the last notification. If there is only one notification, | 1491 in the last notification. If there is only one notification, |
1480 then there will be only one number in this column.'''); | 1492 then there will be only one number in this column.'''); |
1481 } | 1493 } |
1482 | 1494 |
1483 /** | 1495 /** |
1484 * Write the status of the diagnostic domain to the given [buffer]. | 1496 * Write the status of the diagnostic domain to the given [buffer]. |
1485 */ | 1497 */ |
1486 void _writeDiagnosticStatus(StringBuffer buffer) { | 1498 void _writeDiagnosticStatus(StringBuffer buffer) { |
1487 DiagnosticDomainHandler handler = | |
1488 new DiagnosticDomainHandler(_server.analysisServer); | |
1489 | |
1490 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); | 1499 var request = new DiagnosticGetDiagnosticsParams().toRequest('0'); |
1491 | 1500 |
1492 var stopwatch = new Stopwatch(); | 1501 var stopwatch = new Stopwatch(); |
1493 stopwatch.start(); | 1502 stopwatch.start(); |
1494 var response = handler.handleRequest(request); | 1503 var response = diagnosticHandler.handleRequest(request); |
1495 stopwatch.stop(); | 1504 stopwatch.stop(); |
1496 | 1505 |
1497 int elapsedMs = stopwatch.elapsedMilliseconds; | 1506 int elapsedMs = stopwatch.elapsedMilliseconds; |
1498 _diagnosticCallAverage.addSample(elapsedMs); | 1507 _diagnosticCallAverage.addSample(elapsedMs); |
1499 | 1508 |
1500 buffer.write('<h3>Timing</h3>'); | 1509 buffer.write('<h3>Timing</h3>'); |
1501 | 1510 |
1502 buffer.write('<p>'); | 1511 buffer.write('<p>'); |
1503 buffer.write('getDiagnostic (last call): $elapsedMs (ms)'); | 1512 buffer.write('getDiagnostic (last call): $elapsedMs (ms)'); |
1504 buffer.write('<p>'); | 1513 buffer.write('<p>'); |
(...skipping 516 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2021 */ | 2030 */ |
2022 static String makeLink( | 2031 static String makeLink( |
2023 String path, Map<String, String> params, String innerHtml, | 2032 String path, Map<String, String> params, String innerHtml, |
2024 [bool hasError = false]) { | 2033 [bool hasError = false]) { |
2025 Uri uri = new Uri(path: path, queryParameters: params); | 2034 Uri uri = new Uri(path: path, queryParameters: params); |
2026 String href = HTML_ESCAPE.convert(uri.toString()); | 2035 String href = HTML_ESCAPE.convert(uri.toString()); |
2027 String classAttribute = hasError ? ' class="error"' : ''; | 2036 String classAttribute = hasError ? ' class="error"' : ''; |
2028 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 2037 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
2029 } | 2038 } |
2030 } | 2039 } |
OLD | NEW |