Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(284)

Side by Side Diff: pkg/analysis_server/lib/src/get_handler.dart

Issue 679113006: Add a debug option to analysis server to specify HTTP port. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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:convert';
7 import 'dart:io'; 8 import 'dart:io';
8 9
9 import 'package:analysis_server/src/socket_server.dart'; 10 import 'package:analysis_server/src/socket_server.dart';
11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/src/generated/engine.dart';
13 import 'package:analyzer/src/generated/java_engine.dart';
10 14
11 /** 15 /**
12 * Instances of the class [GetHandler] handle GET requests. 16 * Instances of the class [GetHandler] handle GET requests.
13 */ 17 */
14 class GetHandler { 18 class GetHandler {
15 /** 19 /**
16 * The path used to request the status of the analysis server as a whole. 20 * The path used to request the status of the analysis server as a whole.
17 */ 21 */
18 static const String STATUS_PATH = '/status'; 22 static const String STATUS_PATH = '/status';
19 23
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 response.write('<p>Not running</p>'); 60 response.write('<p>Not running</p>');
57 } else { 61 } else {
58 response.write('<p>Running</p>'); 62 response.write('<p>Running</p>');
59 response.write('<h1>Analysis Contexts</h1>'); 63 response.write('<h1>Analysis Contexts</h1>');
60 response.write('<h2>Summary</h2>'); 64 response.write('<h2>Summary</h2>');
61 response.write('<table>'); 65 response.write('<table>');
62 _writeRow( 66 _writeRow(
63 response, 67 response,
64 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], 68 ['Context', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'],
65 true); 69 true);
66 // TODO(scheglov) replace with using folder based contexts 70 _server.analysisServer.folderMap.forEach((Folder folder, AnalysisContextIm pl context) {
67 // _server.analysisServer.contextMap.forEach((String key, AnalysisContext c ontext) { 71 String key = folder.shortName;
68 // AnalysisContentStatistics statistics = 72 AnalysisContextStatistics statistics = context.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((AnalysisContextStatistics_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_${HTML_ESCAPE.convert(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 // });
90 response.write('</table>'); 93 response.write('</table>');
91 // _server.analysisServer.contextMap.forEach((String key, AnalysisContext c ontext) { 94 _server.analysisServer.folderMap.forEach((Folder folder, AnalysisContextIm pl context) {
92 // response.write('<h2><a name="context_$key">Analysis Context: $key</a>< /h2>'); 95 String key = folder.shortName;
93 // AnalysisContentStatistics statistics = (context as AnalysisContextImpl ).statistics; 96 response.write('<h2><a name="context_${HTML_ESCAPE.convert(key)}">Analys is Context: $key</a></h2>');
94 // response.write('<table>'); 97 AnalysisContextStatistics statistics = context.statistics;
95 // _writeRow( 98 response.write('<table>');
96 // response, 99 _writeRow(
97 // ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'], 100 response,
98 // true); 101 ['Item', 'ERROR', 'FLUSHED', 'IN_PROCESS', 'INVALID', 'VALID'],
99 // statistics.cacheRows.forEach((AnalysisContentStatistics_CacheRow row) { 102 true);
100 // _writeRow( 103 statistics.cacheRows.forEach((AnalysisContextStatistics_CacheRow row) {
101 // response, 104 _writeRow(
102 // [row.name, 105 response,
103 // row.errorCount, 106 [row.name,
104 // row.flushedCount, 107 row.errorCount,
105 // row.inProcessCount, 108 row.flushedCount,
106 // row.invalidCount, 109 row.inProcessCount,
107 // row.validCount]); 110 row.invalidCount,
108 // }); 111 row.validCount]);
109 // response.write('</table>'); 112 });
110 // List<CaughtException> exceptions = statistics.exceptions; 113 response.write('</table>');
111 // if (!exceptions.isEmpty) { 114 List<CaughtException> exceptions = statistics.exceptions;
112 // response.write('<h2>Exceptions</h2>'); 115 if (!exceptions.isEmpty) {
113 // exceptions.forEach((CaughtException exception) { 116 response.write('<h2>Exceptions</h2>');
114 // response.write('<p>${exception.exception}</p>'); 117 exceptions.forEach((CaughtException exception) {
115 // }); 118 response.write('<p>${exception.exception}</p>');
116 // } 119 });
117 // }); 120 }
121 });
118 } 122 }
119 response.write('</body>'); 123 response.write('</body>');
120 response.write('</html>'); 124 response.write('</html>');
121 response.close(); 125 response.close();
122 } 126 }
123 127
124 /** 128 /**
125 * Return an error in response to an unrecognized request received by the HTTP 129 * Return an error in response to an unrecognized request received by the HTTP
126 * server. 130 * server.
127 */ 131 */
128 void _returnUnknownRequest(HttpRequest request) { 132 void _returnUnknownRequest(HttpRequest request) {
129 HttpResponse response = request.response; 133 HttpResponse response = request.response;
130 response.statusCode = HttpStatus.NOT_FOUND; 134 response.statusCode = HttpStatus.NOT_FOUND;
131 response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain"); 135 response.headers.add(HttpHeaders.CONTENT_TYPE, "text/plain");
132 response.write('Not found'); 136 response.write('Not found');
133 response.close(); 137 response.close();
134 } 138 }
135 139
136 /** 140 /**
137 * Write a single row within a table to the given [response] object. The row 141 * Write a single row within a table to the given [response] object. The row
138 * will have one cell for each of the [columns], and will be a header row if 142 * will have one cell for each of the [columns], and will be a header row if
139 * [header] is `true`. 143 * [header] is `true`.
140 */ 144 */
141 void _writeRow(HttpResponse response, List<Object> columns, [bool header = fal se]) { 145 void _writeRow(HttpResponse response, List<Object> columns, [bool header = fal se]) {
142 if (header) { 146 response.write('<tr>');
143 response.write('<th>');
144 } else {
145 response.write('<tr>');
146 }
147 columns.forEach((Object value) { 147 columns.forEach((Object value) {
148 response.write('<td>'); 148 if (header) {
149 response.write('<th>');
150 } else {
151 response.write('<td>');
152 }
149 response.write(value); 153 response.write(value);
150 response.write('</td>'); 154 if (header) {
155 response.write('</th>');
156 } else {
157 response.write('</td>');
158 }
151 }); 159 });
152 if (header) { 160 response.write('</tr>');
153 response.write('</th>');
154 } else {
155 response.write('</tr>');
156 }
157 } 161 }
158 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698