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 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'; |
11 | 11 |
12 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; | 12 import 'package:analysis_server/plugin/protocol/protocol.dart' hide Element; |
13 import 'package:analysis_server/src/analysis_server.dart'; | 13 import 'package:analysis_server/src/analysis_server.dart'; |
14 import 'package:analysis_server/src/domain_completion.dart'; | 14 import 'package:analysis_server/src/domain_completion.dart'; |
15 import 'package:analysis_server/src/domain_diagnostic.dart'; | 15 import 'package:analysis_server/src/domain_diagnostic.dart'; |
16 import 'package:analysis_server/src/domain_execution.dart'; | 16 import 'package:analysis_server/src/domain_execution.dart'; |
17 import 'package:analysis_server/src/operation/operation.dart'; | 17 import 'package:analysis_server/src/operation/operation.dart'; |
18 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 18 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
19 import 'package:analysis_server/src/operation/operation_queue.dart'; | 19 import 'package:analysis_server/src/operation/operation_queue.dart'; |
20 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; | 20 import 'package:analysis_server/src/services/completion/completion_performance.d
art'; |
21 import 'package:analysis_server/src/socket_server.dart'; | 21 import 'package:analysis_server/src/socket_server.dart'; |
22 import 'package:analysis_server/src/status/ast_writer.dart'; | 22 import 'package:analysis_server/src/status/ast_writer.dart'; |
23 import 'package:analysis_server/src/status/element_writer.dart'; | 23 import 'package:analysis_server/src/status/element_writer.dart'; |
24 import 'package:analysis_server/src/status/validator.dart'; | 24 import 'package:analysis_server/src/status/validator.dart'; |
25 import 'package:analysis_server/src/utilities/average.dart'; | 25 import 'package:analysis_server/src/utilities/average.dart'; |
26 import 'package:analyzer/dart/ast/ast.dart'; | 26 import 'package:analyzer/dart/ast/ast.dart'; |
27 import 'package:analyzer/dart/element/element.dart'; | 27 import 'package:analyzer/dart/element/element.dart'; |
28 import 'package:analyzer/dart/element/visitor.dart'; | 28 import 'package:analyzer/dart/element/visitor.dart'; |
29 import 'package:analyzer/file_system/file_system.dart'; | 29 import 'package:analyzer/file_system/file_system.dart'; |
| 30 import 'package:analyzer/source/embedder.dart'; |
30 import 'package:analyzer/source/error_processor.dart'; | 31 import 'package:analyzer/source/error_processor.dart'; |
| 32 import 'package:analyzer/source/sdk_ext.dart'; |
31 import 'package:analyzer/src/context/cache.dart'; | 33 import 'package:analyzer/src/context/cache.dart'; |
32 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; | 34 import 'package:analyzer/src/context/context.dart' show AnalysisContextImpl; |
33 import 'package:analyzer/src/context/source.dart'; | 35 import 'package:analyzer/src/context/source.dart'; |
34 import 'package:analyzer/src/generated/engine.dart'; | 36 import 'package:analyzer/src/generated/engine.dart'; |
35 import 'package:analyzer/src/generated/error.dart'; | 37 import 'package:analyzer/src/generated/error.dart'; |
36 import 'package:analyzer/src/generated/java_engine.dart'; | 38 import 'package:analyzer/src/generated/java_engine.dart'; |
37 import 'package:analyzer/src/generated/resolver.dart'; | 39 import 'package:analyzer/src/generated/resolver.dart'; |
| 40 import 'package:analyzer/src/generated/sdk.dart'; |
| 41 import 'package:analyzer/src/generated/sdk_io.dart'; |
38 import 'package:analyzer/src/generated/source.dart'; | 42 import 'package:analyzer/src/generated/source.dart'; |
39 import 'package:analyzer/src/generated/utilities_collection.dart'; | 43 import 'package:analyzer/src/generated/utilities_collection.dart'; |
40 import 'package:analyzer/src/generated/utilities_general.dart'; | 44 import 'package:analyzer/src/generated/utilities_general.dart'; |
41 import 'package:analyzer/src/services/lint.dart'; | 45 import 'package:analyzer/src/services/lint.dart'; |
42 import 'package:analyzer/src/task/dart.dart'; | 46 import 'package:analyzer/src/task/dart.dart'; |
43 import 'package:analyzer/src/task/driver.dart'; | 47 import 'package:analyzer/src/task/driver.dart'; |
44 import 'package:analyzer/src/task/html.dart'; | 48 import 'package:analyzer/src/task/html.dart'; |
45 import 'package:analyzer/src/task/options.dart'; | 49 import 'package:analyzer/src/task/options.dart'; |
46 import 'package:analyzer/task/dart.dart'; | 50 import 'package:analyzer/task/dart.dart'; |
47 import 'package:analyzer/task/general.dart'; | 51 import 'package:analyzer/task/general.dart'; |
(...skipping 1258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1306 buffer.write('</td><td>'); | 1310 buffer.write('</td><td>'); |
1307 if (_overlayContents.containsKey(fileName)) { | 1311 if (_overlayContents.containsKey(fileName)) { |
1308 buffer.write( | 1312 buffer.write( |
1309 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); | 1313 makeLink(OVERLAY_PATH, {PATH_PARAM: fileName}, 'overlay')); |
1310 } | 1314 } |
1311 buffer.write('</td></tr>'); | 1315 buffer.write('</td></tr>'); |
1312 } | 1316 } |
1313 buffer.write('</table></p>'); | 1317 buffer.write('</table></p>'); |
1314 } | 1318 } |
1315 } | 1319 } |
1316 void writeOptions(StringBuffer buffer, AnalysisOptionsImpl options) { | 1320 void writeOptions(StringBuffer buffer, AnalysisOptionsImpl options, |
| 1321 {void writeAdditionalOptions(StringBuffer buffer)}) { |
1317 if (options == null) { | 1322 if (options == null) { |
1318 buffer.write('<p>No option information available.</p>'); | 1323 buffer.write('<p>No option information available.</p>'); |
1319 return; | 1324 return; |
1320 } | 1325 } |
1321 buffer.write('<p>'); | 1326 buffer.write('<p>'); |
1322 _writeOption( | 1327 _writeOption( |
1323 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); | 1328 buffer, 'Analyze functon bodies', options.analyzeFunctionBodies); |
1324 _writeOption(buffer, 'Cache size', options.cacheSize); | 1329 _writeOption(buffer, 'Cache size', options.cacheSize); |
1325 _writeOption(buffer, 'Enable async support', options.enableAsync); | 1330 _writeOption(buffer, 'Enable async support', options.enableAsync); |
1326 _writeOption( | 1331 _writeOption( |
1327 buffer, 'Enable generic methods', options.enableGenericMethods); | 1332 buffer, 'Enable generic methods', options.enableGenericMethods); |
1328 _writeOption( | 1333 _writeOption( |
1329 buffer, 'Enable strict call checks', options.enableStrictCallChecks); | 1334 buffer, 'Enable strict call checks', options.enableStrictCallChecks); |
1330 _writeOption(buffer, 'Enable super mixins', options.enableSuperMixins); | 1335 _writeOption(buffer, 'Enable super mixins', options.enableSuperMixins); |
1331 _writeOption(buffer, 'Generate dart2js hints', options.dart2jsHint); | 1336 _writeOption(buffer, 'Generate dart2js hints', options.dart2jsHint); |
1332 _writeOption(buffer, 'Generate errors in implicit files', | 1337 _writeOption(buffer, 'Generate errors in implicit files', |
1333 options.generateImplicitErrors); | 1338 options.generateImplicitErrors); |
1334 _writeOption( | 1339 _writeOption( |
1335 buffer, 'Generate errors in SDK files', options.generateSdkErrors); | 1340 buffer, 'Generate errors in SDK files', options.generateSdkErrors); |
1336 _writeOption(buffer, 'Generate hints', options.hint); | 1341 _writeOption(buffer, 'Generate hints', options.hint); |
1337 _writeOption(buffer, 'Incremental resolution', options.incremental); | 1342 _writeOption(buffer, 'Incremental resolution', options.incremental); |
1338 _writeOption(buffer, 'Incremental resolution with API changes', | 1343 _writeOption(buffer, 'Incremental resolution with API changes', |
1339 options.incrementalApi); | 1344 options.incrementalApi); |
1340 _writeOption(buffer, 'Preserve comments', options.preserveComments); | 1345 _writeOption(buffer, 'Preserve comments', options.preserveComments); |
1341 _writeOption(buffer, 'Strong mode', options.strongMode); | 1346 _writeOption(buffer, 'Strong mode', options.strongMode); |
1342 _writeOption(buffer, 'Strong mode hints', options.strongModeHints, | 1347 _writeOption(buffer, 'Strong mode hints', options.strongModeHints); |
1343 last: true); | 1348 if (writeAdditionalOptions != null) { |
| 1349 writeAdditionalOptions(buffer); |
| 1350 } |
1344 buffer.write('</p>'); | 1351 buffer.write('</p>'); |
1345 } | 1352 } |
1346 | 1353 |
1347 _writeResponse(request, (StringBuffer buffer) { | 1354 _writeResponse(request, (StringBuffer buffer) { |
1348 _writePage( | 1355 _writePage( |
1349 buffer, 'Analysis Server - Context', ['Context: $contextFilter'], | 1356 buffer, 'Analysis Server - Context', ['Context: $contextFilter'], |
1350 (StringBuffer buffer) { | 1357 (StringBuffer buffer) { |
1351 buffer.write('<h3>Configuration</h3>'); | 1358 buffer.write('<h3>Configuration</h3>'); |
1352 | 1359 |
1353 _writeColumns(buffer, <HtmlGenerator>[ | 1360 _writeColumns(buffer, <HtmlGenerator>[ |
1354 (StringBuffer buffer) { | 1361 (StringBuffer buffer) { |
1355 buffer.write('<p><b>Context Options</b></p>'); | 1362 buffer.write('<p><b>Context Options</b></p>'); |
1356 writeOptions(buffer, context.analysisOptions); | 1363 writeOptions(buffer, context.analysisOptions); |
1357 }, | 1364 }, |
1358 (StringBuffer buffer) { | 1365 (StringBuffer buffer) { |
1359 buffer.write('<p><b>SDK Context Options</b></p>'); | 1366 buffer.write('<p><b>SDK Context Options</b></p>'); |
1360 writeOptions(buffer, | 1367 DartSdk sdk = context?.sourceFactory?.dartSdk; |
1361 context?.sourceFactory?.dartSdk?.context?.analysisOptions); | 1368 writeOptions(buffer, sdk?.context?.analysisOptions, |
| 1369 writeAdditionalOptions: (StringBuffer buffer) { |
| 1370 if (sdk is DirectoryBasedDartSdk) { |
| 1371 _writeOption(buffer, 'Use summaries', sdk.useSummary); |
| 1372 } |
| 1373 }); |
1362 }, | 1374 }, |
1363 (StringBuffer buffer) { | 1375 (StringBuffer buffer) { |
1364 List<Linter> lints = | 1376 List<Linter> lints = |
1365 context.getConfigurationData(CONFIGURED_LINTS_KEY); | 1377 context.getConfigurationData(CONFIGURED_LINTS_KEY); |
1366 buffer.write('<p><b>Lints</b></p>'); | 1378 buffer.write('<p><b>Lints</b></p>'); |
1367 if (lints.isEmpty) { | 1379 if (lints.isEmpty) { |
1368 buffer.write('<p>none</p>'); | 1380 buffer.write('<p>none</p>'); |
1369 } else { | 1381 } else { |
1370 for (Linter lint in lints) { | 1382 for (Linter lint in lints) { |
1371 buffer.write('<p>'); | 1383 buffer.write('<p>'); |
1372 buffer.write(lint.runtimeType); | 1384 buffer.write(lint.runtimeType); |
1373 buffer.write('</p>'); | 1385 buffer.write('</p>'); |
1374 } | 1386 } |
1375 } | 1387 } |
1376 | 1388 |
1377 List<ErrorProcessor> errorProcessors = | 1389 List<ErrorProcessor> errorProcessors = |
1378 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); | 1390 context.getConfigurationData(CONFIGURED_ERROR_PROCESSORS); |
1379 int processorCount = errorProcessors?.length ?? 0; | 1391 int processorCount = errorProcessors?.length ?? 0; |
1380 buffer | 1392 buffer |
1381 .write('<p><b>Error Processor count</b>: $processorCount</p>'); | 1393 .write('<p><b>Error Processor count</b>: $processorCount</p>'); |
1382 } | 1394 } |
1383 ]); | 1395 ]); |
1384 | 1396 |
1385 SourceFactory sourceFactory = context.sourceFactory; | 1397 SourceFactory sourceFactory = context.sourceFactory; |
1386 if (sourceFactory is SourceFactoryImpl) { | 1398 if (sourceFactory is SourceFactoryImpl) { |
1387 buffer.write('<h3>Resolvers</h3>'); | 1399 buffer.write('<h3>Resolvers</h3>'); |
1388 for (UriResolver resolver in sourceFactory.resolvers) { | 1400 for (UriResolver resolver in sourceFactory.resolvers) { |
1389 buffer.write('<p>'); | 1401 buffer.write('<p>'); |
1390 buffer.write(resolver.runtimeType); | 1402 buffer.write(resolver.runtimeType); |
| 1403 if (resolver is DartUriResolver) { |
| 1404 DartSdk sdk = resolver.dartSdk; |
| 1405 buffer.write(' (sdk = '); |
| 1406 buffer.write(sdk.runtimeType); |
| 1407 if (sdk is DirectoryBasedDartSdk) { |
| 1408 buffer.write(' (path = '); |
| 1409 buffer.write(sdk.directory.getAbsolutePath()); |
| 1410 buffer.write(')'); |
| 1411 } else if (sdk is EmbedderSdk) { |
| 1412 buffer.write(' (map = '); |
| 1413 _writeMapOfStringToString(buffer, sdk.urlMappings); |
| 1414 buffer.write(')'); |
| 1415 } |
| 1416 buffer.write(')'); |
| 1417 } else if (resolver is SdkExtUriResolver) { |
| 1418 buffer.write(' (map = '); |
| 1419 _writeMapOfStringToString(buffer, resolver.urlMappings); |
| 1420 buffer.write(')'); |
| 1421 } |
1391 buffer.write('</p>'); | 1422 buffer.write('</p>'); |
1392 } | 1423 } |
1393 } | 1424 } |
1394 | 1425 |
1395 _writeFiles( | 1426 _writeFiles( |
1396 buffer, 'Priority Files (${priorityNames.length})', priorityNames); | 1427 buffer, 'Priority Files (${priorityNames.length})', priorityNames); |
1397 _writeFiles( | 1428 _writeFiles( |
1398 buffer, | 1429 buffer, |
1399 'Explicitly Analyzed Files (${explicitNames.length})', | 1430 'Explicitly Analyzed Files (${explicitNames.length})', |
1400 explicitNames); | 1431 explicitNames); |
(...skipping 667 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 buffer.write('<ul>'); | 2099 buffer.write('<ul>'); |
2069 for (String member in itemList) { | 2100 for (String member in itemList) { |
2070 _writeListItem(buffer, () { | 2101 _writeListItem(buffer, () { |
2071 buffer.write(member); | 2102 buffer.write(member); |
2072 }); | 2103 }); |
2073 } | 2104 } |
2074 buffer.write('</ul>'); | 2105 buffer.write('</ul>'); |
2075 } | 2106 } |
2076 | 2107 |
2077 /** | 2108 /** |
| 2109 * Write to the given [buffer] a representation of the given [map] of strings |
| 2110 * to strings. |
| 2111 */ |
| 2112 void _writeMapOfStringToString(StringBuffer buffer, Map<String, String> map) { |
| 2113 List<String> keys = map.keys.toList(); |
| 2114 keys.sort(); |
| 2115 int length = keys.length; |
| 2116 buffer.write('{'); |
| 2117 for (int i = 0; i < length; i++) { |
| 2118 String key = keys[i]; |
| 2119 if (i > 0) { |
| 2120 buffer.write(', '); |
| 2121 } |
| 2122 buffer.write(key); |
| 2123 buffer.write(' = '); |
| 2124 buffer.write(map[key]); |
| 2125 } |
| 2126 buffer.write('}'); |
| 2127 } |
| 2128 |
| 2129 /** |
2078 * Write a representation of an analysis option with the given [name] and | 2130 * Write a representation of an analysis option with the given [name] and |
2079 * [value] to the given [buffer]. The option should be separated from other | 2131 * [value] to the given [buffer]. The option should be separated from other |
2080 * options unless the [last] flag is true, indicating that this is the last | 2132 * options unless the [last] flag is true, indicating that this is the last |
2081 * option in the list of options. | 2133 * option in the list of options. |
2082 */ | 2134 */ |
2083 void _writeOption(StringBuffer buffer, String name, Object value, | 2135 void _writeOption(StringBuffer buffer, String name, Object value, |
2084 {bool last: false}) { | 2136 {bool last: false}) { |
2085 buffer.write(name); | 2137 buffer.write(name); |
2086 buffer.write(' = '); | 2138 buffer.write(' = '); |
2087 buffer.write(value.toString()); | 2139 buffer.write(value.toString()); |
(...skipping 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2482 */ | 2534 */ |
2483 static String makeLink( | 2535 static String makeLink( |
2484 String path, Map<String, String> params, String innerHtml, | 2536 String path, Map<String, String> params, String innerHtml, |
2485 [bool hasError = false]) { | 2537 [bool hasError = false]) { |
2486 Uri uri = new Uri(path: path, queryParameters: params); | 2538 Uri uri = new Uri(path: path, queryParameters: params); |
2487 String href = HTML_ESCAPE.convert(uri.toString()); | 2539 String href = HTML_ESCAPE.convert(uri.toString()); |
2488 String classAttribute = hasError ? ' class="error"' : ''; | 2540 String classAttribute = hasError ? ' class="error"' : ''; |
2489 return '<a href="$href"$classAttribute>$innerHtml</a>'; | 2541 return '<a href="$href"$classAttribute>$innerHtml</a>'; |
2490 } | 2542 } |
2491 } | 2543 } |
OLD | NEW |