OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 import 'dart:convert'; | 5 import 'dart:convert'; |
6 import 'dart:io'; | 6 import 'dart:io'; |
7 import 'dart:math'; | 7 import 'dart:math'; |
8 | 8 |
9 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; | 9 import 'package:analysis_server/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/protocol/protocol_generated.dart' hide Element; |
10 import 'package:analysis_server/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
11 import 'package:analysis_server/src/domain_completion.dart'; | 12 import 'package:analysis_server/src/domain_completion.dart'; |
12 import 'package:analysis_server/src/domain_diagnostic.dart'; | 13 import 'package:analysis_server/src/domain_diagnostic.dart'; |
13 import 'package:analysis_server/src/domain_execution.dart'; | 14 import 'package:analysis_server/src/domain_execution.dart'; |
14 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 15 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
15 import 'package:analysis_server/src/socket_server.dart'; | 16 import 'package:analysis_server/src/socket_server.dart'; |
16 import 'package:analysis_server/src/status/get_handler.dart'; | 17 import 'package:analysis_server/src/status/get_handler.dart'; |
17 import 'package:analyzer/exception/exception.dart'; | 18 import 'package:analyzer/exception/exception.dart'; |
18 import 'package:analyzer/file_system/file_system.dart'; | 19 import 'package:analyzer/file_system/file_system.dart'; |
19 import 'package:analyzer/instrumentation/instrumentation.dart'; | 20 import 'package:analyzer/instrumentation/instrumentation.dart'; |
20 import 'package:analyzer/source/error_processor.dart'; | 21 import 'package:analyzer/source/error_processor.dart'; |
21 import 'package:analyzer/source/sdk_ext.dart'; | 22 import 'package:analyzer/source/sdk_ext.dart'; |
22 import 'package:analyzer/src/context/source.dart'; | 23 import 'package:analyzer/src/context/source.dart'; |
23 import 'package:analyzer/src/dart/analysis/driver.dart'; | 24 import 'package:analyzer/src/dart/analysis/driver.dart'; |
24 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 25 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
25 import 'package:analyzer/src/generated/engine.dart'; | 26 import 'package:analyzer/src/generated/engine.dart'; |
26 import 'package:analyzer/src/generated/sdk.dart'; | 27 import 'package:analyzer/src/generated/sdk.dart'; |
27 import 'package:analyzer/src/generated/source.dart'; | 28 import 'package:analyzer/src/generated/source.dart'; |
28 import 'package:analyzer/src/generated/utilities_general.dart'; | 29 import 'package:analyzer/src/generated/utilities_general.dart'; |
29 import 'package:analyzer/src/services/lint.dart'; | 30 import 'package:analyzer/src/services/lint.dart'; |
30 import 'package:analyzer/task/model.dart'; | 31 import 'package:analyzer/task/model.dart'; |
31 import 'package:path/path.dart' as path; | 32 import 'package:path/path.dart' as path; |
32 import 'package:plugin/plugin.dart'; | 33 import 'package:plugin/plugin.dart'; |
33 | 34 |
| 35 String _writeWithSeparators(int value) { |
| 36 // TODO(devoncarew): Replace with the implementation from package:intl. |
| 37 String str = value.toString(); |
| 38 int pos = 3; |
| 39 while (str.length > pos) { |
| 40 int len = str.length; |
| 41 str = '${str.substring(0, len - pos)},${str.substring(len - pos)}'; |
| 42 pos += 4; |
| 43 } |
| 44 return str; |
| 45 } |
| 46 |
34 /** | 47 /** |
35 * A function that can be used to generate HTML output into the given [buffer]. | 48 * A function that can be used to generate HTML output into the given [buffer]. |
36 * The HTML that is generated must be valid (special characters must already be | 49 * The HTML that is generated must be valid (special characters must already be |
37 * encoded). | 50 * encoded). |
38 */ | 51 */ |
39 typedef void HtmlGenerator(StringBuffer buffer); | 52 typedef void HtmlGenerator(StringBuffer buffer); |
40 | 53 |
41 /** | 54 /** |
42 * Instances of the class [GetHandler2] handle GET requests. | 55 * Instances of the class [GetHandler2] handle GET requests. |
43 */ | 56 */ |
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 _writeRow(buffer, [link, time]); | 596 _writeRow(buffer, [link, time]); |
584 _overlayContents[fullName] = contents; | 597 _overlayContents[fullName] = contents; |
585 }); | 598 }); |
586 int count = _overlayContents.length; | 599 int count = _overlayContents.length; |
587 buffer.write('<tr><td colspan="2">Total: $count entries</td></tr>'); | 600 buffer.write('<tr><td colspan="2">Total: $count entries</td></tr>'); |
588 buffer.write('</table>'); | 601 buffer.write('</table>'); |
589 }); | 602 }); |
590 }); | 603 }); |
591 } | 604 } |
592 | 605 |
| 606 void _returnRedirect(HttpRequest request, String pathFragment) { |
| 607 HttpResponse response = request.response; |
| 608 response.redirect(request.uri.resolve(pathFragment)); |
| 609 } |
| 610 |
593 /** | 611 /** |
594 * Return a response indicating the status of the analysis server. | 612 * Return a response indicating the status of the analysis server. |
595 */ | 613 */ |
596 void _returnServerStatus(HttpRequest request) { | 614 void _returnServerStatus(HttpRequest request) { |
597 _writeResponse(request, (StringBuffer buffer) { | 615 _writeResponse(request, (StringBuffer buffer) { |
598 _writePage(buffer, 'Status', [], (StringBuffer buffer) { | 616 _writePage(buffer, 'Status', [], (StringBuffer buffer) { |
599 if (_writeServerStatus(buffer)) { | 617 if (_writeServerStatus(buffer)) { |
600 _writeAnalysisStatus(buffer); | 618 _writeAnalysisStatus(buffer); |
601 _writeEditStatus(buffer); | 619 _writeEditStatus(buffer); |
602 _writeExecutionStatus(buffer); | 620 _writeExecutionStatus(buffer); |
603 _writePluginStatus(buffer); | 621 _writePluginStatus(buffer); |
604 _writeRecentOutput(buffer); | 622 _writeRecentOutput(buffer); |
605 } | 623 } |
606 }); | 624 }); |
607 }); | 625 }); |
608 } | 626 } |
609 | 627 |
610 void _returnRedirect(HttpRequest request, String pathFragment) { | |
611 HttpResponse response = request.response; | |
612 response.redirect(request.uri.resolve(pathFragment)); | |
613 } | |
614 | |
615 /** | 628 /** |
616 * Return an error in response to an unrecognized request received by the HTTP | 629 * Return an error in response to an unrecognized request received by the HTTP |
617 * server. | 630 * server. |
618 */ | 631 */ |
619 void _returnUnknownRequest(HttpRequest request) { | 632 void _returnUnknownRequest(HttpRequest request) { |
620 _writeResponse(request, (StringBuffer buffer) { | 633 _writeResponse(request, (StringBuffer buffer) { |
621 _writePage(buffer, 'Analysis Server', [], (StringBuffer buffer) { | 634 _writePage(buffer, 'Analysis Server', [], (StringBuffer buffer) { |
622 buffer.write('<h3>Unknown page: '); | 635 buffer.write('<h3>Unknown page: '); |
623 buffer.write(request.uri.path); | 636 buffer.write(request.uri.path); |
624 buffer.write('</h3>'); | 637 buffer.write('</h3>'); |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1237 String path, Map<String, String> params, String innerHtml, | 1250 String path, Map<String, String> params, String innerHtml, |
1238 [bool hasError = false]) { | 1251 [bool hasError = false]) { |
1239 Uri uri = params.isEmpty | 1252 Uri uri = params.isEmpty |
1240 ? new Uri(path: path) | 1253 ? new Uri(path: path) |
1241 : new Uri(path: path, queryParameters: params); | 1254 : new Uri(path: path, queryParameters: params); |
1242 String href = HTML_ESCAPE.convert(uri.toString()); | 1255 String href = HTML_ESCAPE.convert(uri.toString()); |
1243 String classAttribute = hasError ? ' class="error"' : ''; | 1256 String classAttribute = hasError ? ' class="error"' : ''; |
1244 return '<a href="$href" $classAttribute>$innerHtml</a>'; | 1257 return '<a href="$href" $classAttribute>$innerHtml</a>'; |
1245 } | 1258 } |
1246 } | 1259 } |
1247 | |
1248 String _writeWithSeparators(int value) { | |
1249 // TODO(devoncarew): Replace with the implementation from package:intl. | |
1250 String str = value.toString(); | |
1251 int pos = 3; | |
1252 while (str.length > pos) { | |
1253 int len = str.length; | |
1254 str = '${str.substring(0, len - pos)},${str.substring(len - pos)}'; | |
1255 pos += 4; | |
1256 } | |
1257 return str; | |
1258 } | |
OLD | NEW |