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

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

Issue 1842063003: Start making server strong mode clean (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Remove unintended change Created 4 years, 8 months 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
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 analysis_server.src.status.get_handler; 5 library analysis_server.src.status.get_handler;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 import 'dart:math'; 10 import 'dart:math';
(...skipping 868 matching lines...) Expand 10 before | Expand all | Expand 10 after
879 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM]; 879 String sourceUri = request.uri.queryParameters[SOURCE_QUERY_PARAM];
880 if (sourceUri == null) { 880 if (sourceUri == null) {
881 return _returnFailure( 881 return _returnFailure(
882 request, 'Query parameter $SOURCE_QUERY_PARAM required'); 882 request, 'Query parameter $SOURCE_QUERY_PARAM required');
883 } 883 }
884 884
885 List<Folder> allContexts = <Folder>[]; 885 List<Folder> allContexts = <Folder>[];
886 Map<Folder, List<CacheEntry>> entryMap = 886 Map<Folder, List<CacheEntry>> entryMap =
887 new HashMap<Folder, List<CacheEntry>>(); 887 new HashMap<Folder, List<CacheEntry>>();
888 StringBuffer invalidKeysBuffer = new StringBuffer(); 888 StringBuffer invalidKeysBuffer = new StringBuffer();
889 analysisServer.folderMap 889 analysisServer.folderMap.forEach((Folder folder, AnalysisContext context) {
890 .forEach((Folder folder, InternalAnalysisContext context) {
891 Source source = context.sourceFactory.forUri(sourceUri); 890 Source source = context.sourceFactory.forUri(sourceUri);
892 if (source != null) { 891 if (source != null) {
893 MapIterator<AnalysisTarget, CacheEntry> iterator = 892 MapIterator<AnalysisTarget, CacheEntry> iterator =
894 context.analysisCache.iterator(); 893 (context as InternalAnalysisContext).analysisCache.iterator();
895 while (iterator.moveNext()) { 894 while (iterator.moveNext()) {
896 if (source == iterator.key.source) { 895 if (source == iterator.key.source) {
897 if (!allContexts.contains(folder)) { 896 if (!allContexts.contains(folder)) {
898 allContexts.add(folder); 897 allContexts.add(folder);
899 } 898 }
900 List<CacheEntry> entries = entryMap[folder]; 899 List<CacheEntry> entries = entryMap[folder];
901 if (entries == null) { 900 if (entries == null) {
902 entries = <CacheEntry>[]; 901 entries = <CacheEntry>[];
903 entryMap[folder] = entries; 902 entryMap[folder] = entries;
904 } 903 }
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
1216 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM]; 1215 String contextFilter = request.uri.queryParameters[CONTEXT_QUERY_PARAM];
1217 if (contextFilter == null) { 1216 if (contextFilter == null) {
1218 return _returnFailure( 1217 return _returnFailure(
1219 request, 'Query parameter $CONTEXT_QUERY_PARAM required'); 1218 request, 'Query parameter $CONTEXT_QUERY_PARAM required');
1220 } 1219 }
1221 Folder folder = _findFolder(analysisServer, contextFilter); 1220 Folder folder = _findFolder(analysisServer, contextFilter);
1222 if (folder == null) { 1221 if (folder == null) {
1223 return _returnFailure(request, 'Invalid context: $contextFilter'); 1222 return _returnFailure(request, 'Invalid context: $contextFilter');
1224 } 1223 }
1225 1224
1226 List<String> priorityNames; 1225 List<String> priorityNames = <String>[];
1227 List<String> explicitNames = <String>[]; 1226 List<String> explicitNames = <String>[];
1228 List<String> implicitNames = <String>[]; 1227 List<String> implicitNames = <String>[];
1229 Map<String, String> links = new HashMap<String, String>(); 1228 Map<String, String> links = new HashMap<String, String>();
1230 List<CaughtException> exceptions = <CaughtException>[]; 1229 List<CaughtException> exceptions = <CaughtException>[];
1231 InternalAnalysisContext context = analysisServer.folderMap[folder]; 1230 InternalAnalysisContext context = analysisServer.folderMap[folder];
1232 priorityNames = context.prioritySources 1231 context.prioritySources.forEach((Source source) {
1233 .map((Source source) => source.fullName) 1232 priorityNames.add(source.fullName);
1234 .toList(); 1233 });
1235 MapIterator<AnalysisTarget, CacheEntry> iterator = 1234 MapIterator<AnalysisTarget, CacheEntry> iterator =
1236 context.analysisCache.iterator(context: context); 1235 context.analysisCache.iterator(context: context);
1237 while (iterator.moveNext()) { 1236 while (iterator.moveNext()) {
1238 AnalysisTarget target = iterator.key; 1237 AnalysisTarget target = iterator.key;
1239 if (target is Source) { 1238 if (target is Source) {
1240 CacheEntry entry = iterator.value; 1239 CacheEntry entry = iterator.value;
1241 String sourceName = target.fullName; 1240 String sourceName = target.fullName;
1242 if (!links.containsKey(sourceName)) { 1241 if (!links.containsKey(sourceName)) {
1243 CaughtException exception = entry.exception; 1242 CaughtException exception = entry.exception;
1244 if (exception != null) { 1243 if (exception != null) {
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
1330 (StringBuffer buffer) { 1329 (StringBuffer buffer) {
1331 buffer.write('<p><b>Context Options</b></p>'); 1330 buffer.write('<p><b>Context Options</b></p>');
1332 writeOptions(buffer, context.analysisOptions); 1331 writeOptions(buffer, context.analysisOptions);
1333 }, 1332 },
1334 (StringBuffer buffer) { 1333 (StringBuffer buffer) {
1335 buffer.write('<p><b>SDK Context Options</b></p>'); 1334 buffer.write('<p><b>SDK Context Options</b></p>');
1336 writeOptions(buffer, 1335 writeOptions(buffer,
1337 context?.sourceFactory?.dartSdk?.context?.analysisOptions); 1336 context?.sourceFactory?.dartSdk?.context?.analysisOptions);
1338 }, 1337 },
1339 (StringBuffer buffer) { 1338 (StringBuffer buffer) {
1340 List<Linter> lints = 1339 List<Linter> lints = context
1341 context.getConfigurationData(CONFIGURED_LINTS_KEY); 1340 .getConfigurationData(CONFIGURED_LINTS_KEY) as List<Linter>;
1342 buffer.write('<p><b>Lints</b></p>'); 1341 buffer.write('<p><b>Lints</b></p>');
1343 if (lints.isEmpty) { 1342 if (lints.isEmpty) {
1344 buffer.write('<p>none</p>'); 1343 buffer.write('<p>none</p>');
1345 } else { 1344 } else {
1346 for (Linter lint in lints) { 1345 for (Linter lint in lints) {
1347 buffer.write('<p>'); 1346 buffer.write('<p>');
1348 buffer.write(lint.runtimeType); 1347 buffer.write(lint.runtimeType);
1349 buffer.write('</p>'); 1348 buffer.write('</p>');
1350 } 1349 }
1351 } 1350 }
1352 1351
1353 List<ErrorProcessor> errorProcessors = 1352 List<ErrorProcessor> errorProcessors =
1354 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); 1353 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS)
1354 as List<ErrorProcessor>;
1355 int processorCount = errorProcessors?.length ?? 0; 1355 int processorCount = errorProcessors?.length ?? 0;
1356 buffer 1356 buffer
1357 .write('<p><b>Error Processor count</b>: $processorCount</p>'); 1357 .write('<p><b>Error Processor count</b>: $processorCount</p>');
1358 } 1358 }
1359 ]); 1359 ]);
1360 1360
1361 SourceFactory sourceFactory = context.sourceFactory; 1361 SourceFactory sourceFactory = context.sourceFactory;
1362 if (sourceFactory is SourceFactoryImpl) { 1362 if (sourceFactory is SourceFactoryImpl) {
1363 buffer.write('<h3>Resolvers</h3>'); 1363 buffer.write('<h3>Resolvers</h3>');
1364 for (UriResolver resolver in sourceFactory.resolvers) { 1364 for (UriResolver resolver in sourceFactory.resolvers) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
1878 1878
1879 buffer.write('<h3>Timing</h3>'); 1879 buffer.write('<h3>Timing</h3>');
1880 1880
1881 buffer.write('<p>getDiagnostic (last call): '); 1881 buffer.write('<p>getDiagnostic (last call): ');
1882 buffer.write(elapsedMs); 1882 buffer.write(elapsedMs);
1883 buffer.write(' (ms)</p>'); 1883 buffer.write(' (ms)</p>');
1884 buffer.write('<p>getDiagnostic (rolling average): '); 1884 buffer.write('<p>getDiagnostic (rolling average): ');
1885 buffer.write(_diagnosticCallAverage.value); 1885 buffer.write(_diagnosticCallAverage.value);
1886 buffer.write(' (ms)</p>&nbsp;'); 1886 buffer.write(' (ms)</p>&nbsp;');
1887 1887
1888 var json = response.toJson()[Response.RESULT]; 1888 Map json = response.toJson()[Response.RESULT];
1889 List contexts = json['contexts']; 1889 List contexts = json['contexts'];
1890 contexts.sort((first, second) => first['name'].compareTo(second['name'])); 1890 contexts.sort((first, second) => first['name'].compareTo(second['name']));
1891 1891
1892 // Track visited libraries. 1892 // Track visited libraries.
1893 Set<LibraryElement> libraries = new HashSet<LibraryElement>(); 1893 Set<LibraryElement> libraries = new HashSet<LibraryElement>();
1894 1894
1895 // Count SDK elements separately. 1895 // Count SDK elements separately.
1896 ElementCounter sdkCounter = new ElementCounter(); 1896 ElementCounter sdkCounter = new ElementCounter();
1897 1897
1898 for (var context in contexts) { 1898 for (var context in contexts) {
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
2225 * given [response] object. 2225 * given [response] object.
2226 */ 2226 */
2227 bool _writeServerStatus(StringBuffer buffer) { 2227 bool _writeServerStatus(StringBuffer buffer) {
2228 AnalysisServer analysisServer = _server.analysisServer; 2228 AnalysisServer analysisServer = _server.analysisServer;
2229 Set<ServerService> services = analysisServer.serverServices; 2229 Set<ServerService> services = analysisServer.serverServices;
2230 2230
2231 buffer.write('<h3>Server Domain</h3>'); 2231 buffer.write('<h3>Server Domain</h3>');
2232 _writeTwoColumns(buffer, (StringBuffer buffer) { 2232 _writeTwoColumns(buffer, (StringBuffer buffer) {
2233 if (analysisServer == null) { 2233 if (analysisServer == null) {
2234 buffer.write('Status: <span style="color:red">Not running</span>'); 2234 buffer.write('Status: <span style="color:red">Not running</span>');
2235 return false; 2235 return;
2236 } 2236 }
2237 buffer.write('<p>'); 2237 buffer.write('<p>');
2238 buffer.write('Status: Running<br>'); 2238 buffer.write('Status: Running<br>');
2239 buffer.write('Instrumentation: '); 2239 buffer.write('Instrumentation: ');
2240 if (AnalysisEngine.instance.instrumentationService.isActive) { 2240 if (AnalysisEngine.instance.instrumentationService.isActive) {
2241 buffer.write('<span style="color:red">Active</span>'); 2241 buffer.write('<span style="color:red">Active</span>');
2242 } else { 2242 } else {
2243 buffer.write('Inactive'); 2243 buffer.write('Inactive');
2244 } 2244 }
2245 buffer.write('<br>'); 2245 buffer.write('<br>');
2246 buffer.write('Version: '); 2246 buffer.write('Version: ');
2247 buffer.write(AnalysisServer.VERSION); 2247 buffer.write(AnalysisServer.VERSION);
2248 buffer.write('<br>'); 2248 buffer.write('<br>');
2249 buffer.write('Process ID: '); 2249 buffer.write('Process ID: ');
2250 buffer.write(pid); 2250 buffer.write(pid);
2251 buffer.write('</p>'); 2251 buffer.write('</p>');
2252 2252
2253 buffer.write('<p><b>Performance Data</b></p>'); 2253 buffer.write('<p><b>Performance Data</b></p>');
2254 buffer.write('<p>'); 2254 buffer.write('<p>');
2255 buffer.write(makeLink( 2255 buffer.write(makeLink(
2256 COMMUNICATION_PERFORMANCE_PATH, {}, 'Communication performance')); 2256 COMMUNICATION_PERFORMANCE_PATH, {}, 'Communication performance'));
2257 buffer.write('</p>'); 2257 buffer.write('</p>');
2258 buffer.write('<p>'); 2258 buffer.write('<p>');
2259 buffer.write(makeLink(DIAGNOSTIC_PATH, {}, 'General diagnostics')); 2259 buffer.write(makeLink(DIAGNOSTIC_PATH, {}, 'General diagnostics'));
2260 buffer.write('</p>'); 2260 buffer.write('</p>');
2261 }, (StringBuffer buffer) { 2261 }, (StringBuffer buffer) {
2262 _writeSubscriptionList(buffer, ServerService.VALUES, services); 2262 _writeSubscriptionList(buffer, ServerService.VALUES, services);
2263 }); 2263 });
2264 return true; 2264 return analysisServer != null;
2265 } 2265 }
2266 2266
2267 /** 2267 /**
2268 * Write a representation of the given [stackTrace] to the given [buffer]. 2268 * Write a representation of the given [stackTrace] to the given [buffer].
2269 */ 2269 */
2270 void _writeStackTrace(StringBuffer buffer, StackTrace stackTrace) { 2270 void _writeStackTrace(StringBuffer buffer, StackTrace stackTrace) {
2271 if (stackTrace != null) { 2271 if (stackTrace != null) {
2272 String trace = stackTrace.toString().replaceAll('#', '<br>#'); 2272 String trace = stackTrace.toString().replaceAll('#', '<br>#');
2273 if (trace.startsWith('<br>#')) { 2273 if (trace.startsWith('<br>#')) {
2274 trace = trace.substring(4); 2274 trace = trace.substring(4);
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
2458 */ 2458 */
2459 static String makeLink( 2459 static String makeLink(
2460 String path, Map<String, String> params, String innerHtml, 2460 String path, Map<String, String> params, String innerHtml,
2461 [bool hasError = false]) { 2461 [bool hasError = false]) {
2462 Uri uri = new Uri(path: path, queryParameters: params); 2462 Uri uri = new Uri(path: path, queryParameters: params);
2463 String href = HTML_ESCAPE.convert(uri.toString()); 2463 String href = HTML_ESCAPE.convert(uri.toString());
2464 String classAttribute = hasError ? ' class="error"' : ''; 2464 String classAttribute = hasError ? ' class="error"' : '';
2465 return '<a href="$href"$classAttribute>$innerHtml</a>'; 2465 return '<a href="$href"$classAttribute>$innerHtml</a>';
2466 } 2466 }
2467 } 2467 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698