OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 | 7 |
8 import 'package:analysis_server/protocol/protocol_generated.dart'; | 8 import 'package:analysis_server/protocol/protocol_generated.dart'; |
9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/domain_completion.dart'; | 10 import 'package:analysis_server/src/domain_completion.dart'; |
11 import 'package:analysis_server/src/domain_execution.dart'; | 11 import 'package:analysis_server/src/domain_execution.dart'; |
12 import 'package:analysis_server/src/plugin/plugin_manager.dart'; | 12 import 'package:analysis_server/src/plugin/plugin_manager.dart'; |
13 import 'package:analysis_server/src/server/http_server.dart'; | 13 import 'package:analysis_server/src/server/http_server.dart'; |
14 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 14 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
15 import 'package:analysis_server/src/socket_server.dart'; | 15 import 'package:analysis_server/src/socket_server.dart'; |
16 import 'package:analysis_server/src/status/pages.dart'; | 16 import 'package:analysis_server/src/status/pages.dart'; |
17 import 'package:analyzer/exception/exception.dart'; | |
18 import 'package:analyzer/file_system/file_system.dart'; | 17 import 'package:analyzer/file_system/file_system.dart'; |
19 import 'package:analyzer/instrumentation/instrumentation.dart'; | 18 import 'package:analyzer/instrumentation/instrumentation.dart'; |
20 import 'package:analyzer/source/package_map_resolver.dart'; | 19 import 'package:analyzer/source/package_map_resolver.dart'; |
21 import 'package:analyzer/source/sdk_ext.dart'; | 20 import 'package:analyzer/source/sdk_ext.dart'; |
22 import 'package:analyzer/src/context/source.dart'; | 21 import 'package:analyzer/src/context/source.dart'; |
23 import 'package:analyzer/src/dart/analysis/driver.dart'; | 22 import 'package:analyzer/src/dart/analysis/driver.dart'; |
24 import 'package:analyzer/src/dart/analysis/file_state.dart'; | 23 import 'package:analyzer/src/dart/analysis/file_state.dart'; |
25 import 'package:analyzer/src/dart/sdk/sdk.dart'; | 24 import 'package:analyzer/src/dart/sdk/sdk.dart'; |
26 import 'package:analyzer/src/generated/engine.dart'; | 25 import 'package:analyzer/src/generated/engine.dart'; |
27 import 'package:analyzer/src/generated/sdk.dart'; | 26 import 'package:analyzer/src/generated/sdk.dart'; |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 List<String> lastPrintedLines = <String>[]; | 135 List<String> lastPrintedLines = <String>[]; |
137 | 136 |
138 DiagnosticsSite(this.socketServer, this.lastPrintedLines) | 137 DiagnosticsSite(this.socketServer, this.lastPrintedLines) |
139 : super('Analysis Server') { | 138 : super('Analysis Server') { |
140 pages.add(new CompletionPage(this)); | 139 pages.add(new CompletionPage(this)); |
141 pages.add(new CommunicationsPage(this)); | 140 pages.add(new CommunicationsPage(this)); |
142 pages.add(new ContextsPage(this)); | 141 pages.add(new ContextsPage(this)); |
143 pages.add(new ExecutionDomainPage(this)); | 142 pages.add(new ExecutionDomainPage(this)); |
144 pages.add(new OverlaysPage(this)); | 143 pages.add(new OverlaysPage(this)); |
145 pages.add(new ProfilePage(this)); | 144 pages.add(new ProfilePage(this)); |
146 //pages.add(new ExceptionsPage(this)); | 145 pages.add(new ExceptionsPage(this)); |
147 pages.add(new InstrumentationPage(this)); | 146 pages.add(new InstrumentationPage(this)); |
148 pages.add(new PluginsPage(this)); | 147 pages.add(new PluginsPage(this)); |
149 | 148 |
150 pages.sort(((Page a, Page b) => | 149 pages.sort(((Page a, Page b) => |
151 a.title.toLowerCase().compareTo(b.title.toLowerCase()))); | 150 a.title.toLowerCase().compareTo(b.title.toLowerCase()))); |
152 | 151 |
153 // Add the status page at the beginning. | 152 // Add the status page at the beginning. |
154 pages.insert(0, new StatusPage(this)); | 153 pages.insert(0, new StatusPage(this)); |
155 | 154 |
156 // Add non-nav pages. | 155 // Add non-nav pages. |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
489 printMilliseconds(tag.elapsedMs), | 488 printMilliseconds(tag.elapsedMs), |
490 printPercentage(percent) | 489 printPercentage(percent) |
491 ]); | 490 ]); |
492 } | 491 } |
493 | 492 |
494 tags.forEach(writeRow); | 493 tags.forEach(writeRow); |
495 buf.write('</table>'); | 494 buf.write('</table>'); |
496 } | 495 } |
497 } | 496 } |
498 | 497 |
499 // TODO(devoncarew): This is not hooked up. | |
500 class ExceptionsPage extends DiagnosticPageWithNav { | 498 class ExceptionsPage extends DiagnosticPageWithNav { |
501 ExceptionsPage(DiagnosticsSite site) | 499 ExceptionsPage(DiagnosticsSite site) |
502 : super(site, 'exceptions', 'Exceptions', | 500 : super(site, 'exceptions', 'Exceptions', |
503 description: 'Exceptions from the analysis server.'); | 501 description: 'Exceptions from the analysis server.'); |
504 | 502 |
505 String get navDetail => exceptions.length.toString(); | 503 String get navDetail => printInteger(exceptions.length); |
506 | 504 |
507 @override | 505 @override |
508 void generateContent(Map<String, String> params) { | 506 void generateContent(Map<String, String> params) { |
509 if (exceptions.isEmpty) { | 507 if (exceptions.isEmpty) { |
510 blankslate('No exceptions encountered!'); | 508 blankslate('No exceptions encountered!'); |
511 } else { | 509 } else { |
512 for (CaughtException ex in exceptions) { | 510 for (ServerException ex in exceptions) { |
513 h3('${ex.exception}'); | 511 h3('Exception ${ex.exception}'); |
514 p(ex.toString(), style: 'white-space: pre'); | 512 p('${escape(ex.message)}<br>${writeOption('fatal', ex.fatal)}', |
| 513 raw: true); |
| 514 pre(() { |
| 515 buf.writeln('<code>${escape(ex.stackTrace.toString())}</code>'); |
| 516 }, classes: "scroll-table"); |
515 } | 517 } |
516 } | 518 } |
517 } | 519 } |
518 | 520 |
519 // TODO: Implement - read this from a server exception ring buffer. | 521 Iterable<ServerException> get exceptions => server.exceptions.items; |
520 List<CaughtException> get exceptions => []; | |
521 } | 522 } |
522 | 523 |
523 class ContextsPage extends DiagnosticPageWithNav { | 524 class ContextsPage extends DiagnosticPageWithNav { |
524 ContextsPage(DiagnosticsSite site) | 525 ContextsPage(DiagnosticsSite site) |
525 : super(site, 'contexts', 'Contexts', | 526 : super(site, 'contexts', 'Contexts', |
526 description: | 527 description: |
527 'An analysis context defines the options and the set of sources
being analyzed.'); | 528 'An analysis context defines the options and the set of sources
being analyzed.'); |
528 | 529 |
529 String get navDetail => printInteger(server.driverMap.length); | 530 String get navDetail => printInteger(server.driverMap.length); |
530 | 531 |
(...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 return '$name: <code>$value</code><br> '; | 962 return '$name: <code>$value</code><br> '; |
962 } | 963 } |
963 | 964 |
964 String get _sdkVersion { | 965 String get _sdkVersion { |
965 String version = Platform.version; | 966 String version = Platform.version; |
966 if (version.contains(' ')) { | 967 if (version.contains(' ')) { |
967 version = version.substring(0, version.indexOf(' ')); | 968 version = version.substring(0, version.indexOf(' ')); |
968 } | 969 } |
969 return version; | 970 return version; |
970 } | 971 } |
OLD | NEW |