| 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 get.handler; | 5 library get.handler; |
| 6 | 6 |
| 7 import 'dart:io'; | 7 import 'dart:io'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/engine.dart'; | |
| 10 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; | |
| 11 | |
| 12 import 'package:analysis_server/src/socket_server.dart'; | 9 import 'package:analysis_server/src/socket_server.dart'; |
| 13 | 10 |
| 14 /** | 11 /** |
| 15 * Instances of the class [GetHandler] handle GET requests. | 12 * Instances of the class [GetHandler] handle GET requests. |
| 16 */ | 13 */ |
| 17 class GetHandler { | 14 class GetHandler { |
| 18 /** | 15 /** |
| 19 * The path used to request the status of the analysis server as a whole. | 16 * The path used to request the status of the analysis server as a whole. |
| 20 */ | 17 */ |
| 21 static const String STATUS_PATH = '/status'; | 18 static const String STATUS_PATH = '/status'; |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 } else { | 57 } else { |
| 61 response.write('<p>Running</p>'); | 58 response.write('<p>Running</p>'); |
| 62 response.write('<h1>Analysis Contexts</h1>'); | 59 response.write('<h1>Analysis Contexts</h1>'); |
| 63 response.write('<h2>Summary</h2>'); | 60 response.write('<h2>Summary</h2>'); |
| 64 response.write('<table>'); | 61 response.write('<table>'); |
| 65 _writeRow( | 62 _writeRow( |
| 66 response, | 63 response, |
| 67 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], | 64 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], |
| 68 true); | 65 true); |
| 69 // TODO(scheglov) replace with using folder based contexts | 66 // TODO(scheglov) replace with using folder based contexts |
| 70 _server.analysisServer.contextMap.forEach((String key, AnalysisContext con
text) { | 67 // _server.analysisServer.contextMap.forEach((String key, AnalysisContext c
ontext) { |
| 71 AnalysisContentStatistics statistics = | 68 // AnalysisContentStatistics statistics = |
| 72 (context as AnalysisContextImpl).statistics; | 69 // (context as AnalysisContextImpl).statistics; |
| 73 int errorCount = 0; | 70 // int errorCount = 0; |
| 74 int flushedCount = 0; | 71 // int flushedCount = 0; |
| 75 int inProcessCount = 0; | 72 // int inProcessCount = 0; |
| 76 int invalidCount = 0; | 73 // int invalidCount = 0; |
| 77 int validCount = 0; | 74 // int validCount = 0; |
| 78 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) { | 75 // statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row)
{ |
| 79 errorCount += row.errorCount; | 76 // errorCount += row.errorCount; |
| 80 flushedCount += row.flushedCount; | 77 // flushedCount += row.flushedCount; |
| 81 inProcessCount += row.inProcessCount; | 78 // inProcessCount += row.inProcessCount; |
| 82 invalidCount += row.invalidCount; | 79 // invalidCount += row.invalidCount; |
| 83 validCount += row.validCount; | 80 // validCount += row.validCount; |
| 84 }); | 81 // }); |
| 85 _writeRow(response, [ | 82 // _writeRow(response, [ |
| 86 '<a href="#context_$key">$key</a>', | 83 // '<a href="#context_$key">$key</a>', |
| 87 errorCount, | 84 // errorCount, |
| 88 flushedCount, | 85 // flushedCount, |
| 89 inProcessCount, | 86 // inProcessCount, |
| 90 invalidCount, | 87 // invalidCount, |
| 91 validCount]); | 88 // validCount]); |
| 92 }); | 89 // }); |
| 93 response.write('</table>'); | 90 response.write('</table>'); |
| 94 _server.analysisServer.contextMap.forEach((String key, AnalysisContext con
text) { | 91 // _server.analysisServer.contextMap.forEach((String key, AnalysisContext c
ontext) { |
| 95 response.write('<h2><a name="context_$key">Analysis Context: $key</a></h
2>'); | 92 // response.write('<h2><a name="context_$key">Analysis Context: $key</a><
/h2>'); |
| 96 AnalysisContentStatistics statistics = (context as AnalysisContextImpl).
statistics; | 93 // AnalysisContentStatistics statistics = (context as AnalysisContextImpl
).statistics; |
| 97 response.write('<table>'); | 94 // response.write('<table>'); |
| 98 _writeRow( | 95 // _writeRow( |
| 99 response, | 96 // response, |
| 100 ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], | 97 // ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], |
| 101 true); | 98 // true); |
| 102 statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) { | 99 // statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row)
{ |
| 103 _writeRow( | 100 // _writeRow( |
| 104 response, | 101 // response, |
| 105 [row.name, | 102 // [row.name, |
| 106 row.errorCount, | 103 // row.errorCount, |
| 107 row.flushedCount, | 104 // row.flushedCount, |
| 108 row.inProcessCount, | 105 // row.inProcessCount, |
| 109 row.invalidCount, | 106 // row.invalidCount, |
| 110 row.validCount]); | 107 // row.validCount]); |
| 111 }); | 108 // }); |
| 112 response.write('</table>'); | 109 // response.write('</table>'); |
| 113 List<CaughtException> exceptions = statistics.exceptions; | 110 // List<CaughtException> exceptions = statistics.exceptions; |
| 114 if (!exceptions.isEmpty) { | 111 // if (!exceptions.isEmpty) { |
| 115 response.write('<h2>Exceptions</h2>'); | 112 // response.write('<h2>Exceptions</h2>'); |
| 116 exceptions.forEach((CaughtException exception) { | 113 // exceptions.forEach((CaughtException exception) { |
| 117 response.write('<p>${exception.exception}</p>'); | 114 // response.write('<p>${exception.exception}</p>'); |
| 118 }); | 115 // }); |
| 119 } | 116 // } |
| 120 }); | 117 // }); |
| 121 } | 118 } |
| 122 response.write('</body>'); | 119 response.write('</body>'); |
| 123 response.write('</html>'); | 120 response.write('</html>'); |
| 124 response.close(); | 121 response.close(); |
| 125 } | 122 } |
| 126 | 123 |
| 127 /** | 124 /** |
| 128 * Return an error in response to an unrecognized request received by the HTTP | 125 * Return an error in response to an unrecognized request received by the HTTP |
| 129 * server. | 126 * server. |
| 130 */ | 127 */ |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 response.write(value); | 149 response.write(value); |
| 153 response.write('</td>'); | 150 response.write('</td>'); |
| 154 }); | 151 }); |
| 155 if (header) { | 152 if (header) { |
| 156 response.write('</th>'); | 153 response.write('</th>'); |
| 157 } else { | 154 } else { |
| 158 response.write('</tr>'); | 155 response.write('</tr>'); |
| 159 } | 156 } |
| 160 } | 157 } |
| 161 } | 158 } |
| OLD | NEW |