analysis_server: Enforce single quotes preference
Change-Id: I553befc2c45e66bfc569004d810b4e0a958d4baa
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325544
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/analysis_options.yaml b/pkg/analysis_server/analysis_options.yaml
index 96b49e7..6e4e646 100644
--- a/pkg/analysis_server/analysis_options.yaml
+++ b/pkg/analysis_server/analysis_options.yaml
@@ -35,6 +35,7 @@
- depend_on_referenced_packages
- implicit_call_tearoffs
- library_annotations
+ - prefer_single_quotes
- unawaited_futures
- unnecessary_breaks
- unnecessary_library_directive
diff --git a/pkg/analysis_server/benchmark/perf/benchmark_uploader.dart b/pkg/analysis_server/benchmark/perf/benchmark_uploader.dart
index 39648fd..0ddc7e2 100644
--- a/pkg/analysis_server/benchmark/perf/benchmark_uploader.dart
+++ b/pkg/analysis_server/benchmark/perf/benchmark_uploader.dart
@@ -25,7 +25,7 @@
}
if (!Platform.isWindows) {
- print("Analyzer benchmark uploads only run on Windows");
+ print('Analyzer benchmark uploads only run on Windows');
exit(1);
}
final targetResults = [
@@ -100,8 +100,8 @@
final resultsFile = File.fromUri(tempDir.uri.resolve('results.json'));
resultsFile.writeAsStringSync(resultsJson, flush: true);
- final taskId = Platform.environment['SWARMING_TASK_ID'] ?? "test_task_id";
- if (taskId == "test_task_id") {
+ final taskId = Platform.environment['SWARMING_TASK_ID'] ?? 'test_task_id';
+ if (taskId == 'test_task_id') {
print('Benchmark_uploader requires SWARMING_TASK_ID in the environment.');
}
final cloudStoragePath =
diff --git a/pkg/analysis_server/benchmark/perf/dart_analyze.dart b/pkg/analysis_server/benchmark/perf/dart_analyze.dart
index 292ead7..c1a0286 100644
--- a/pkg/analysis_server/benchmark/perf/dart_analyze.dart
+++ b/pkg/analysis_server/benchmark/perf/dart_analyze.dart
@@ -77,7 +77,7 @@
verbose: false,
stdout: stdout,
);
- int kbNoCache = jsonDecode(stdout[1])["memory"] as int;
+ int kbNoCache = jsonDecode(stdout[1])['memory'] as int;
result.add('no-cache-memory', BenchMarkResult('bytes', kbNoCache * 1024));
stdout = [];
@@ -95,7 +95,7 @@
verbose: false,
stdout: stdout,
);
- int kbWithCache = jsonDecode(stdout[1])["memory"] as int;
+ int kbWithCache = jsonDecode(stdout[1])['memory'] as int;
result.add(
'with-cache-memory', BenchMarkResult('bytes', kbWithCache * 1024));
}
@@ -119,7 +119,7 @@
@override
List<String> analyzeWhat(bool quick) =>
- quick ? ["meta"] : ["analysis_server"];
+ quick ? ['meta'] : ['analysis_server'];
}
class CmdLineSeveralProjectsBenchmark extends AbstractCmdLineBenchmark {
diff --git a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
index a34706a..5bb6f70 100644
--- a/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
+++ b/pkg/analysis_server/lib/src/computer/import_elements_computer.dart
@@ -65,7 +65,7 @@
for (var i = 0; i < description.newLinesBefore; i++) {
builder.writeln();
}
- builder.write("import $quote");
+ builder.write('import $quote');
builder.write(importUri);
builder.write(quote);
if (importedElements.prefix.isNotEmpty) {
diff --git a/pkg/analysis_server/lib/src/handler/legacy/analysis_get_hover.dart b/pkg/analysis_server/lib/src/handler/legacy/analysis_get_hover.dart
index 019e523..ee48bf8 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/analysis_get_hover.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/analysis_get_hover.dart
@@ -28,7 +28,7 @@
// Prepare the resolved units.
var result = await performance.runAsync(
- "getResolvedUnit", (_) async => await server.getResolvedUnit(file));
+ 'getResolvedUnit', (_) async => await server.getResolvedUnit(file));
if (result is! ResolvedUnitResult) {
sendResponse(Response.fileNotAnalyzed(request, file));
return;
@@ -40,7 +40,7 @@
var computer = DartUnitHoverComputer(
server.getDartdocDirectiveInfoFor(result), unit, params.offset);
var hoverInformation =
- performance.run("compute", (_) => computer.compute());
+ performance.run('compute', (_) => computer.compute());
if (hoverInformation != null) {
hovers.add(hoverInformation);
}
diff --git a/pkg/analysis_server/lib/src/handler/legacy/edit_get_assists.dart b/pkg/analysis_server/lib/src/handler/legacy/edit_get_assists.dart
index 8586ee2..b889b6a 100644
--- a/pkg/analysis_server/lib/src/handler/legacy/edit_get_assists.dart
+++ b/pkg/analysis_server/lib/src/handler/legacy/edit_get_assists.dart
@@ -42,20 +42,20 @@
//
var requestParams = plugin.EditGetAssistsParams(file, offset, length);
var driver = performance.run(
- "getAnalysisDriver", (_) => server.getAnalysisDriver(file));
+ 'getAnalysisDriver', (_) => server.getAnalysisDriver(file));
var pluginFutures = server.broadcastRequestToPlugins(requestParams, driver);
//
// Compute fixes associated with server-generated errors.
//
- var changes = await performance.runAsync("_computeServerAssists",
+ var changes = await performance.runAsync('_computeServerAssists',
(_) => _computeServerAssists(request, file, offset, length));
//
// Add the fixes produced by plugins to the server-generated fixes.
//
var responses = await performance.runAsync(
- "waitForResponses",
+ 'waitForResponses',
(_) =>
waitForResponses(pluginFutures, requestParameters: requestParams));
server.requestStatistics?.addItemTimeNow(request, 'pluginResponses');
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
index 12293a8..4e274c6 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_implementation.dart
@@ -37,12 +37,12 @@
final pos = params.position;
final path = pathOfDoc(params.textDocument);
final unit = await performance.runAsync(
- "requireResolvedUnit",
+ 'requireResolvedUnit',
(_) async => path.mapResult(requireResolvedUnit),
);
final offset = await unit.mapResult((unit) => toOffset(unit.lineInfo, pos));
return await performance.runAsync(
- "_getImplementations",
+ '_getImplementations',
(performance) async => offset.mapResult((offset) =>
_getImplementations(unit.result, offset, token, performance)));
}
@@ -67,12 +67,12 @@
var allSubtypes = <InterfaceElement>{};
await performance.runAsync(
- "appendAllSubtypes",
+ 'appendAllSubtypes',
(performance) => server.searchEngine
.appendAllSubtypes(interfaceElement, allSubtypes, performance));
final locations = performance.run(
- "filter and get location",
+ 'filter and get location',
(_) => allSubtypes
.map((element) {
return needsMember
diff --git a/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart b/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
index 30a307c..5b205be 100644
--- a/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
+++ b/pkg/analysis_server/lib/src/lsp/handlers/handler_references.dart
@@ -42,7 +42,7 @@
final unit = await path.mapResult(requireResolvedUnit);
final offset = await unit.mapResult((unit) => toOffset(unit.lineInfo, pos));
return await message.performance.runAsync(
- "_getReferences",
+ '_getReferences',
(performance) async => offset.mapResult((offset) => _getReferences(
unit.result, offset, params, unit.result, performance)));
}
@@ -77,7 +77,7 @@
final computer = ElementReferencesComputer(server.searchEngine);
final session = element.session ?? unit.session;
final results = await performance.runAsync(
- "computer.compute",
+ 'computer.compute',
(childPerformance) =>
computer.compute(element, false, performance: childPerformance));
@@ -97,12 +97,12 @@
}
final referenceResults = performance.run(
- "convert", (_) => convert(results, toLocation).whereNotNull().toList());
+ 'convert', (_) => convert(results, toLocation).whereNotNull().toList());
final compilationUnit = unit.unit;
if (params.context.includeDeclaration == true) {
// Also include the definition for the symbol at this location.
- referenceResults.addAll(performance.run("_getDeclarations",
+ referenceResults.addAll(performance.run('_getDeclarations',
(_) => _getDeclarations(compilationUnit, offset)));
}
diff --git a/pkg/analysis_server/lib/src/search/element_references.dart b/pkg/analysis_server/lib/src/search/element_references.dart
index 1813e54..5e2842b 100644
--- a/pkg/analysis_server/lib/src/search/element_references.dart
+++ b/pkg/analysis_server/lib/src/search/element_references.dart
@@ -19,11 +19,11 @@
Future<List<SearchMatch>> compute(Element element, bool withPotential,
{OperationPerformanceImpl? performance}) async {
var results = <SearchMatch>[];
- performance ??= OperationPerformanceImpl("<root>");
+ performance ??= OperationPerformanceImpl('<root>');
// Add element references.
results.addAll(await performance.runAsync(
- "_findElementsReferences",
+ '_findElementsReferences',
(childPerformance) =>
_findElementsReferences(element, childPerformance)));
@@ -31,7 +31,7 @@
if (withPotential && _isMemberElement(element)) {
var name = element.displayName;
var matches = await performance.runAsync(
- "searchEngine.searchMemberReferences",
+ 'searchEngine.searchMemberReferences',
(_) => searchEngine.searchMemberReferences(name));
results.addAll(matches.where((match) => !match.isResolved));
}
@@ -44,11 +44,11 @@
Future<List<SearchMatch>> _findElementsReferences(
Element element, OperationPerformanceImpl performance) async {
var allResults = <SearchMatch>[];
- var refElements = await performance.runAsync("_getRefElements",
+ var refElements = await performance.runAsync('_getRefElements',
(childPerformance) => _getRefElements(element, childPerformance));
for (var refElement in refElements) {
var elementResults = await performance.runAsync(
- "_findSingleElementReferences",
+ '_findSingleElementReferences',
(_) => _findSingleElementReferences(refElement));
allResults.addAll(elementResults);
}
@@ -70,12 +70,12 @@
Future<Iterable<Element>> _getRefElements(
Element element, OperationPerformanceImpl performance) {
if (element is ParameterElement && element.isNamed) {
- return performance.runAsync("getHierarchyNamedParameters",
+ return performance.runAsync('getHierarchyNamedParameters',
(_) => getHierarchyNamedParameters(searchEngine, element));
}
if (element is ClassMemberElement) {
return performance.runAsync(
- "getHierarchyMembers",
+ 'getHierarchyMembers',
(performance) => getHierarchyMembers(searchEngine, element,
performance: performance));
}
diff --git a/pkg/analysis_server/lib/src/services/correction/fix.dart b/pkg/analysis_server/lib/src/services/correction/fix.dart
index d48a5e3..7ec3c19 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix.dart
@@ -321,7 +321,7 @@
static const ADD_SUPER_PARAMETER = FixKind(
'dart.fix.add.superParameter',
DartFixKindPriority.DEFAULT,
- "Add required parameter{0}",
+ 'Add required parameter{0}',
);
static const ADD_SWITCH_CASE_BREAK = FixKind(
'dart.fix.add.switchCaseReturn',
@@ -451,7 +451,7 @@
static const CONVERT_TO_CONSTANT_PATTERN = FixKind(
'dart.fix.convert.toConstantPattern',
49,
- "Convert to constant pattern",
+ 'Convert to constant pattern',
);
static const CONVERT_TO_CONTAINS = FixKind(
'dart.fix.convert.toContains',
@@ -681,7 +681,7 @@
static const CONVERT_TO_WILDCARD_PATTERN = FixKind(
'dart.fix.convert.toWildcardPattern',
DartFixKindPriority.DEFAULT,
- "Convert to wildcard pattern",
+ 'Convert to wildcard pattern',
);
static const CREATE_CLASS = FixKind(
'dart.fix.create.class',
@@ -890,17 +890,17 @@
static const MAKE_REQUIRED_NAMED_PARAMETERS_FIRST = FixKind(
'dart.fix.makeRequiredNamedParametersFirst',
DartFixKindPriority.DEFAULT,
- "Put required named parameter first",
+ 'Put required named parameter first',
);
static const MAKE_REQUIRED_NAMED_PARAMETERS_FIRST_MULTI = FixKind(
'dart.fix.makeRequiredNamedParametersFirst.multi',
DartFixKindPriority.IN_FILE,
- "Put required named parameters first everywhere in file",
+ 'Put required named parameters first everywhere in file',
);
static const MAKE_SUPER_INVOCATION_LAST = FixKind(
'dart.fix.makeSuperInvocationLast',
DartFixKindPriority.DEFAULT,
- "Move the invocation to the end of the initializer list",
+ 'Move the invocation to the end of the initializer list',
);
static const MAKE_VARIABLE_NOT_FINAL = FixKind(
'dart.fix.makeVariableNotFinal',
@@ -915,22 +915,22 @@
static const MATCH_ANY_MAP = FixKind(
'dart.fix.matchAnyMap',
DartFixKindPriority.DEFAULT,
- "Match any map",
+ 'Match any map',
);
static const MATCH_EMPTY_MAP = FixKind(
'dart.fix.matchEmptyMap',
DartFixKindPriority.DEFAULT,
- "Match an empty map",
+ 'Match an empty map',
);
static const MOVE_ANNOTATION_TO_LIBRARY_DIRECTIVE = FixKind(
'dart.fix.moveAnnotationToLibraryDirective',
DartFixKindPriority.DEFAULT,
- "Move this annotation to a library directive",
+ 'Move this annotation to a library directive',
);
static const MOVE_DOC_COMMENT_TO_LIBRARY_DIRECTIVE = FixKind(
'dart.fix.moveDocCommentToLibraryDirective',
DartFixKindPriority.DEFAULT,
- "Move this doc comment to a library directive",
+ 'Move this doc comment to a library directive',
);
static const MOVE_TYPE_ARGUMENTS_TO_CLASS = FixKind(
'dart.fix.moveTypeArgumentsToClass',
@@ -1052,7 +1052,7 @@
static const REMOVE_DEFAULT_VALUE = FixKind(
'dart.fix.remove.defaultValue',
DartFixKindPriority.DEFAULT,
- "Remove the default value",
+ 'Remove the default value',
);
static const REMOVE_DEPRECATED_NEW_IN_COMMENT_REFERENCE = FixKind(
'dart.fix.remove.deprecatedNewInCommentReference',
@@ -1783,7 +1783,7 @@
static const REPLACE_WITH_UNICODE_ESCAPE = FixKind(
'dart.fix.replace.withUnicodeEscape',
DartFixKindPriority.DEFAULT,
- "Replace with Unicode escape",
+ 'Replace with Unicode escape',
);
static const REPLACE_WITH_VAR = FixKind(
'dart.fix.replace.withVar',
diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_error_code.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_error_code.dart
index c928935..dd900e1 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_error_code.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_error_code.dart
@@ -16,7 +16,7 @@
/// No parameters.
static const TransformSetErrorCode expectedPrimary = TransformSetErrorCode(
- 'expected_primary', "Expected either an identifier or a string literal.");
+ 'expected_primary', 'Expected either an identifier or a string literal.');
/// Parameters:
/// 0: the old kind
@@ -61,7 +61,7 @@
/// 0: the list of valid parameter styles
static const TransformSetErrorCode invalidParameterStyle =
TransformSetErrorCode('invalid_parameter_style',
- "The parameter style must be one of the following: {0}.");
+ 'The parameter style must be one of the following: {0}.');
/// Parameters:
/// 0: the key with which the value is associated
@@ -79,20 +79,20 @@
/// 0: the list of valid keys
static const TransformSetErrorCode missingOneOfMultipleKeys =
TransformSetErrorCode('missing_one_of_multiple_keys',
- "Exactly one of the following keys must be provided: {0}.");
+ 'Exactly one of the following keys must be provided: {0}.');
/// No parameters.
static const TransformSetErrorCode missingTemplateEnd = TransformSetErrorCode(
- 'missing_template_end', "Missing the end brace for the template.");
+ 'missing_template_end', 'Missing the end brace for the template.');
/// Parameters:
/// 0: a description of the expected kinds of tokens
static const TransformSetErrorCode missingToken =
- TransformSetErrorCode('missing_token', "Expected to find {0}.");
+ TransformSetErrorCode('missing_token', 'Expected to find {0}.');
/// No parameters.
static const TransformSetErrorCode missingUri = TransformSetErrorCode(
- 'missing_uri', "At least one URI must be provided.");
+ 'missing_uri', 'At least one URI must be provided.');
/// Parameters:
/// 0: the missing key
@@ -118,7 +118,7 @@
static const TransformSetErrorCode unsupportedStatic = TransformSetErrorCode(
'unsupported_static',
"The key 'static' is only supported for elements in a class, enum, "
- "extension, or mixin.");
+ 'extension, or mixin.');
/// No parameters.
static const TransformSetErrorCode unsupportedVersion = TransformSetErrorCode(
@@ -128,12 +128,12 @@
/// 0: a description of the expected kind of token
/// 1: a description of the actual kind of token
static const TransformSetErrorCode wrongToken = TransformSetErrorCode(
- 'wrong_token', "Expected to find {0}, but found {1}.");
+ 'wrong_token', 'Expected to find {0}, but found {1}.');
/// Parameters:
/// 0: the message produced by the YAML parser
static const TransformSetErrorCode yamlSyntaxError =
- TransformSetErrorCode('yaml_syntax_error', "Parse error: {0}");
+ TransformSetErrorCode('yaml_syntax_error', 'Parse error: {0}');
/// Initialize a newly created error code.
const TransformSetErrorCode(
diff --git a/pkg/analysis_server/lib/src/services/correction/util.dart b/pkg/analysis_server/lib/src/services/correction/util.dart
index 6a5034f..5fc34c1 100644
--- a/pkg/analysis_server/lib/src/services/correction/util.dart
+++ b/pkg/analysis_server/lib/src/services/correction/util.dart
@@ -88,7 +88,7 @@
isFirstPackage = false;
}
if (importUri.compareTo(existingImport.uri) < 0) {
- var importCode = "import $quote$importUri$quote;$eol";
+ var importCode = 'import $quote$importUri$quote;$eol';
doSourceChange_addElementEdit(change, targetLibrary,
SourceEdit(existingImport.offset, 0, importCode));
inserted = true;
@@ -96,7 +96,7 @@
}
}
if (!inserted) {
- var importCode = "${eol}import $quote$importUri$quote;";
+ var importCode = '${eol}import $quote$importUri$quote;';
if (isPackage && isFirstPackage && isAfterDart) {
importCode = eol + importCode;
}
@@ -114,7 +114,7 @@
if (libraryDirective != null) {
var prefix = eol + eol;
for (var importUri in uriList) {
- var importCode = "${prefix}import $quote$importUri$quote;";
+ var importCode = '${prefix}import $quote$importUri$quote;';
prefix = eol;
doSourceChange_addElementEdit(change, targetLibrary,
SourceEdit(libraryDirective.end, 0, importCode));
@@ -128,7 +128,7 @@
var offset = desc.offset;
for (var i = 0; i < uriList.length; i++) {
var importUri = uriList[i];
- var importCode = "import $quote$importUri$quote;$eol";
+ var importCode = 'import $quote$importUri$quote;$eol';
if (i == 0) {
importCode = desc.prefix + importCode;
}
diff --git a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_class_member.dart b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_class_member.dart
index f163492..da9d65d 100644
--- a/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_class_member.dart
+++ b/pkg/analysis_server/lib/src/services/refactoring/legacy/rename_class_member.dart
@@ -278,7 +278,7 @@
// do chained computations
var subClasses = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- interfaceElement, subClasses, OperationPerformanceImpl("<root>"));
+ interfaceElement, subClasses, OperationPerformanceImpl('<root>'));
// check shadowing of class names
if (interfaceElement.name == name) {
result.addError(
@@ -368,7 +368,7 @@
await _prepareReferences();
var subClasses = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- interfaceElement, subClasses, OperationPerformanceImpl("<root>"));
+ interfaceElement, subClasses, OperationPerformanceImpl('<root>'));
// check shadowing of class names
for (var element in elements) {
var enclosingElement = element.enclosingElement;
diff --git a/pkg/analysis_server/lib/src/services/search/hierarchy.dart b/pkg/analysis_server/lib/src/services/search/hierarchy.dart
index 37c4249..186bf07 100644
--- a/pkg/analysis_server/lib/src/services/search/hierarchy.dart
+++ b/pkg/analysis_server/lib/src/services/search/hierarchy.dart
@@ -85,7 +85,7 @@
Future<Set<ClassMemberElement>> getHierarchyMembers(
SearchEngine searchEngine, ClassMemberElement member,
{OperationPerformanceImpl? performance}) async {
- performance ??= OperationPerformanceImpl("<root>");
+ performance ??= OperationPerformanceImpl('<root>');
Set<ClassMemberElement> result = HashSet<ClassMemberElement>();
// extension member
var enclosingElement = member.enclosingElement;
@@ -119,7 +119,7 @@
}
// check all sub- classes
await performance.runAsync(
- "appendAllSubtypes",
+ 'appendAllSubtypes',
(performance) => searchEngine.appendAllSubtypes(
superClass, subClasses, performance));
subClasses.add(superClass);
diff --git a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
index 3d96567..3830035 100644
--- a/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
+++ b/pkg/analysis_server/lib/src/services/search/search_engine_internal.dart
@@ -26,7 +26,7 @@
Future<void> addSubtypes(InterfaceElement type) async {
var directResults = await performance.runAsync(
- "_searchDirectSubtypes",
+ '_searchDirectSubtypes',
(performance) =>
_searchDirectSubtypes(type, searchEngineCache, performance));
for (var directResult in directResults) {
@@ -125,7 +125,7 @@
Future<List<SearchMatch>> searchSubtypes(
InterfaceElement type, SearchEngineCache searchEngineCache,
{OperationPerformanceImpl? performance}) async {
- performance ??= OperationPerformanceImpl("<root>");
+ performance ??= OperationPerformanceImpl('<root>');
var results =
await _searchDirectSubtypes(type, searchEngineCache, performance);
return results.map(SearchMatchImpl.forSearchResult).toList();
@@ -169,7 +169,7 @@
for (var driver in drivers) {
var assignedFilesForDrive = assignedFiles[driver] = [];
await performance.runAsync(
- "discoverAvailableFiles", (_) => driver.discoverAvailableFiles());
+ 'discoverAvailableFiles', (_) => driver.discoverAvailableFiles());
for (var file in driver.fsState.knownFiles) {
if (searchedFiles.add(file.path, driver.search)) {
assignedFilesForDrive.add(file);
@@ -180,7 +180,7 @@
for (var driver in drivers) {
var results = await performance.runAsync(
- "subTypes",
+ 'subTypes',
(_) => driver.search.subTypes(type, searchedFiles,
filesToCheck: assignedFiles![driver]));
allResults.addAll(results);
diff --git a/pkg/analysis_server/lib/src/status/diagnostics.dart b/pkg/analysis_server/lib/src/status/diagnostics.dart
index 2a1db95..57afa1e 100644
--- a/pkg/analysis_server/lib/src/status/diagnostics.dart
+++ b/pkg/analysis_server/lib/src/status/diagnostics.dart
@@ -34,7 +34,7 @@
import 'package:analyzer/src/util/file_paths.dart' as file_paths;
import 'package:collection/collection.dart';
import 'package:path/path.dart' as path;
-import "package:vm_service/vm_service_io.dart" as vm_service;
+import 'package:vm_service/vm_service_io.dart' as vm_service;
final String kCustomCss = '''
.lead, .page-title+.markdown-body>p:first-child {
@@ -290,16 +290,16 @@
var server = this.server;
// General data.
- collectedData["currentTime"] = DateTime.now().millisecondsSinceEpoch;
- collectedData["operatingSystem"] = Platform.operatingSystem;
- collectedData["version"] = Platform.version;
- collectedData["clientId"] = server.options.clientId;
- collectedData["clientVersion"] = server.options.clientVersion;
- collectedData["protocolVersion"] = PROTOCOL_VERSION;
- collectedData["serverType"] = server.runtimeType.toString();
- collectedData["uptime"] = server.uptime.toString();
+ collectedData['currentTime'] = DateTime.now().millisecondsSinceEpoch;
+ collectedData['operatingSystem'] = Platform.operatingSystem;
+ collectedData['version'] = Platform.version;
+ collectedData['clientId'] = server.options.clientId;
+ collectedData['clientVersion'] = server.options.clientVersion;
+ collectedData['protocolVersion'] = PROTOCOL_VERSION;
+ collectedData['serverType'] = server.runtimeType.toString();
+ collectedData['uptime'] = server.uptime.toString();
if (server is LegacyAnalysisServer) {
- collectedData["serverServices"] =
+ collectedData['serverServices'] =
server.serverServices.map((e) => e.toString()).toList();
}
@@ -308,16 +308,16 @@
if (profiler != null) {
usage = await profiler.getProcessUsage(pid);
}
- collectedData["memoryKB"] = usage?.memoryKB;
- collectedData["cpuPercentage"] = usage?.cpuPercentage;
- collectedData["currentRss"] = ProcessInfo.currentRss;
- collectedData["maxRss"] = ProcessInfo.maxRss;
+ collectedData['memoryKB'] = usage?.memoryKB;
+ collectedData['cpuPercentage'] = usage?.cpuPercentage;
+ collectedData['currentRss'] = ProcessInfo.currentRss;
+ collectedData['maxRss'] = ProcessInfo.maxRss;
// Communication.
for (var data in {
- "startup": server.performanceDuringStartup,
+ 'startup': server.performanceDuringStartup,
if (server.performanceAfterStartup != null)
- "afterStartup": server.performanceAfterStartup!
+ 'afterStartup': server.performanceAfterStartup!
}.entries) {
var perf = data.value;
var perfData = {};
@@ -330,68 +330,68 @@
var maximumLatency = perf.maxLatency;
var slowRequestCount = perf.slowRequestCount;
- perfData["RequestCount"] = requestCount;
- perfData["LatencyCount"] = latencyCount;
- perfData["AverageLatency"] = averageLatency;
- perfData["MaximumLatency"] = maximumLatency;
- perfData["SlowRequestCount"] = slowRequestCount;
+ perfData['RequestCount'] = requestCount;
+ perfData['LatencyCount'] = latencyCount;
+ perfData['AverageLatency'] = averageLatency;
+ perfData['MaximumLatency'] = maximumLatency;
+ perfData['SlowRequestCount'] = slowRequestCount;
}
// Contexts.
var driverMapValues = server.driverMap.values.toList();
var contexts = [];
- collectedData["contexts"] = contexts;
+ collectedData['contexts'] = contexts;
Set<String> uniqueKnownFiles = {};
for (var data in driverMapValues) {
var contextData = {};
contexts.add(contextData);
// We don't include the name as some might see that as "secret".
- contextData["priorityFiles"] = data.priorityFiles.length;
- contextData["addedFiles"] = data.addedFiles.length;
- contextData["knownFiles"] = data.knownFiles.length;
+ contextData['priorityFiles'] = data.priorityFiles.length;
+ contextData['addedFiles'] = data.addedFiles.length;
+ contextData['knownFiles'] = data.knownFiles.length;
uniqueKnownFiles.addAll(data.knownFiles);
- contextData["lints"] =
+ contextData['lints'] =
data.analysisOptions.lintRules.map((e) => e.name).toList();
- contextData["plugins"] = data.analysisOptions.enabledPluginNames.toList();
+ contextData['plugins'] = data.analysisOptions.enabledPluginNames.toList();
}
- collectedData["uniqueKnownFiles"] = uniqueKnownFiles.length;
+ collectedData['uniqueKnownFiles'] = uniqueKnownFiles.length;
// Recorded performance data (timing and code completion).
void collectPerformance(List<RequestPerformance> items, String type) {
var performance = [];
- collectedData["performance$type"] = performance;
+ collectedData['performance$type'] = performance;
for (var item in items) {
var itemData = {};
performance.add(itemData);
- itemData["id"] = item.id;
- itemData["operation"] = item.operation;
- itemData["requestLatency"] = item.requestLatency;
- itemData["elapsed"] = item.performance.elapsed.inMilliseconds;
- itemData["startTime"] = item.startTime?.toIso8601String();
+ itemData['id'] = item.id;
+ itemData['operation'] = item.operation;
+ itemData['requestLatency'] = item.requestLatency;
+ itemData['elapsed'] = item.performance.elapsed.inMilliseconds;
+ itemData['startTime'] = item.startTime?.toIso8601String();
var buffer = StringBuffer();
item.performance.write(buffer: buffer);
- itemData["performance"] = buffer.toString();
+ itemData['performance'] = buffer.toString();
}
}
collectPerformance(
- server.recentPerformance.completion.items.toList(), "Completion");
+ server.recentPerformance.completion.items.toList(), 'Completion');
collectPerformance(
- server.recentPerformance.requests.items.toList(), "Requests");
+ server.recentPerformance.requests.items.toList(), 'Requests');
collectPerformance(
- server.recentPerformance.slowRequests.items.toList(), "SlowRequests");
+ server.recentPerformance.slowRequests.items.toList(), 'SlowRequests');
// Exceptions.
var exceptions = [];
- collectedData["exceptions"] = exceptions;
+ collectedData['exceptions'] = exceptions;
for (var exception in server.exceptions.items) {
exceptions.add({
- "exception": exception.exception?.toString(),
- "fatal": exception.fatal,
- "message": exception.message,
- "stackTrace": exception.stackTrace.toString(),
+ 'exception': exception.exception?.toString(),
+ 'fatal': exception.fatal,
+ 'message': exception.message,
+ 'stackTrace': exception.stackTrace.toString(),
});
}
@@ -407,35 +407,35 @@
var serverUri = serviceProtocolInfo.serverUri;
if (serverUri != null) {
var path = serverUri.path;
- if (!path.endsWith("/")) path += "/";
+ if (!path.endsWith('/')) path += '/';
var wsUriString = 'ws://${serverUri.authority}${path}ws';
var serviceClient = await vm_service.vmServiceConnectUri(wsUriString);
var vm = await serviceClient.getVM();
- collectedData["vm.architectureBits"] = vm.architectureBits;
- collectedData["vm.hostCPU"] = vm.hostCPU;
- collectedData["vm.operatingSystem"] = vm.operatingSystem;
- collectedData["vm.startTime"] = vm.startTime;
+ collectedData['vm.architectureBits'] = vm.architectureBits;
+ collectedData['vm.hostCPU'] = vm.hostCPU;
+ collectedData['vm.operatingSystem'] = vm.operatingSystem;
+ collectedData['vm.startTime'] = vm.startTime;
var processMemoryUsage = await serviceClient.getProcessMemoryUsage();
- collectedData["processMemoryUsage"] = processMemoryUsage.json;
+ collectedData['processMemoryUsage'] = processMemoryUsage.json;
var isolateData = [];
- collectedData["isolates"] = isolateData;
+ collectedData['isolates'] = isolateData;
var isolates = vm.isolates ?? [];
for (var isolate in isolates) {
String? id = isolate.id;
if (id == null) continue;
var thisIsolateData = {};
isolateData.add(thisIsolateData);
- thisIsolateData["id"] = id;
- thisIsolateData["isolateGroupId"] = isolate.isolateGroupId;
- thisIsolateData["name"] = isolate.name;
+ thisIsolateData['id'] = id;
+ thisIsolateData['isolateGroupId'] = isolate.isolateGroupId;
+ thisIsolateData['name'] = isolate.name;
var isolateMemoryUsage = await serviceClient.getMemoryUsage(id);
- thisIsolateData["memory"] = isolateMemoryUsage.json;
+ thisIsolateData['memory'] = isolateMemoryUsage.json;
var allocationProfile = await serviceClient.getAllocationProfile(id);
var allocationMembers = allocationProfile.members ?? [];
var allocationProfileData = [];
- thisIsolateData["allocationProfile"] = allocationProfileData;
+ thisIsolateData['allocationProfile'] = allocationProfileData;
for (var member in allocationMembers) {
var bytesCurrent = member.bytesCurrent;
// Filter out very small entries to avoid the report becoming too big.
@@ -443,16 +443,16 @@
var memberData = {};
allocationProfileData.add(memberData);
- memberData["bytesCurrent"] = bytesCurrent;
- memberData["instancesCurrent"] = member.instancesCurrent;
- memberData["accumulatedSize"] = member.accumulatedSize;
- memberData["instancesAccumulated"] = member.instancesAccumulated;
- memberData["className"] = member.classRef?.name;
- memberData["libraryName"] = member.classRef?.library?.name;
+ memberData['bytesCurrent'] = bytesCurrent;
+ memberData['instancesCurrent'] = member.instancesCurrent;
+ memberData['accumulatedSize'] = member.accumulatedSize;
+ memberData['instancesAccumulated'] = member.instancesAccumulated;
+ memberData['className'] = member.classRef?.name;
+ memberData['libraryName'] = member.classRef?.library?.name;
}
allocationProfileData.sort((a, b) {
- int bytesCurrentA = a["bytesCurrent"] as int;
- int bytesCurrentB = b["bytesCurrent"] as int;
+ int bytesCurrentA = a['bytesCurrent'] as int;
+ int bytesCurrentB = b['bytesCurrent'] as int;
// Largest first.
return bytesCurrentB.compareTo(bytesCurrentA);
});
@@ -1629,12 +1629,12 @@
h3("Request '${item.operation}'");
var requestLatency = item.requestLatency;
if (requestLatency != null) {
- buf.writeln("Request latency: $requestLatency ms.");
+ buf.writeln('Request latency: $requestLatency ms.');
buf.writeln('<p>');
}
var startTime = item.startTime;
if (startTime != null) {
- buf.writeln("Request start time: ${startTime.toIso8601String()}.");
+ buf.writeln('Request start time: ${startTime.toIso8601String()}.');
buf.writeln('<p>');
}
var buffer = StringBuffer();
diff --git a/pkg/analysis_server/lib/src/status/pages.dart b/pkg/analysis_server/lib/src/status/pages.dart
index aefc761..0b991b4 100644
--- a/pkg/analysis_server/lib/src/status/pages.dart
+++ b/pkg/analysis_server/lib/src/status/pages.dart
@@ -210,7 +210,7 @@
page.contentDispositionString(queryParameters);
if (contentDispositionString != null) {
response.headers
- .add("Content-Disposition", contentDispositionString);
+ .add('Content-Disposition', contentDispositionString);
}
response.write(await page.generate(queryParameters));
unawaited(response.close());
diff --git a/pkg/analysis_server/lib/src/utilities/profiling.dart b/pkg/analysis_server/lib/src/utilities/profiling.dart
index b6b1fec..8c8d389 100644
--- a/pkg/analysis_server/lib/src/utilities/profiling.dart
+++ b/pkg/analysis_server/lib/src/utilities/profiling.dart
@@ -106,17 +106,17 @@
UsageInfo? _parse(String tasklistResults) {
try {
- var lines = tasklistResults.split(RegExp("\r?\n"));
+ var lines = tasklistResults.split(RegExp('\r?\n'));
for (var line in lines) {
if (line.trim().isEmpty) continue;
// Hacky parsing of csv line.
- var entries = jsonDecode("[$line]") as List;
+ var entries = jsonDecode('[$line]') as List;
if (entries.length != 5) continue;
// E.g. 123,456 K
var memory = entries[4] as String;
- memory = memory.substring(0, memory.indexOf(" "));
- memory = memory.replaceAll(",", "");
- memory = memory.replaceAll(".", "");
+ memory = memory.substring(0, memory.indexOf(' '));
+ memory = memory.replaceAll(',', '');
+ memory = memory.replaceAll('.', '');
return UsageInfo(null, int.parse(memory));
}
return null;
diff --git a/pkg/analysis_server/test/analysis/get_navigation_test.dart b/pkg/analysis_server/test/analysis/get_navigation_test.dart
index 7de9661..007eabf 100644
--- a/pkg/analysis_server/test/analysis/get_navigation_test.dart
+++ b/pkg/analysis_server/test/analysis/get_navigation_test.dart
@@ -369,7 +369,7 @@
await waitForTasksFinished();
await _getNavigation(offset: 10, length: 0);
expect(regions, hasLength(1));
- assertHasRegionString("foo");
+ assertHasRegionString('foo');
expect(testTargets, hasLength(1));
expect(testTargets[0].kind, ElementKind.LIBRARY);
assertHasFileTarget(partOfFile.path, 8, 3); // library [[foo]]
diff --git a/pkg/analysis_server/test/integration/lsp/handle_test.dart b/pkg/analysis_server/test/integration/lsp/handle_test.dart
index 1bd79b6..4f91bc4 100644
--- a/pkg/analysis_server/test/integration/lsp/handle_test.dart
+++ b/pkg/analysis_server/test/integration/lsp/handle_test.dart
@@ -71,7 +71,7 @@
expect(
message.error['message'],
"The 'lspMessage' parameter was not a valid LSP request:\n"
- "jsonrpc must not be undefined");
+ 'jsonrpc must not be undefined');
}
}
@@ -156,8 +156,8 @@
'id': '12345',
'method': Method.textDocument_hover.toString(),
'params': {
- "textDocument": {"uri": testFileUri.toString()},
- "position": code.position.position.toJson(),
+ 'textDocument': {'uri': testFileUri.toString()},
+ 'position': code.position.position.toJson(),
},
}
});
diff --git a/pkg/analysis_server/test/lsp/open_uri_test.dart b/pkg/analysis_server/test/lsp/open_uri_test.dart
index 85037de..c183330 100644
--- a/pkg/analysis_server/test/lsp/open_uri_test.dart
+++ b/pkg/analysis_server/test/lsp/open_uri_test.dart
@@ -17,7 +17,7 @@
@reflectiveTest
class OpenUriTest extends AbstractLspAnalysisServerTest {
- final exampleUri = Uri.parse("https://example.org");
+ final exampleUri = Uri.parse('https://example.org');
Future<void> initializeWithUriSupport() async {
await initialize(initializationOptions: {
diff --git a/pkg/analysis_server/test/services/refactoring/legacy/extract_method_test.dart b/pkg/analysis_server/test/services/refactoring/legacy/extract_method_test.dart
index 85f6182..4ab0a4d 100644
--- a/pkg/analysis_server/test/services/refactoring/legacy/extract_method_test.dart
+++ b/pkg/analysis_server/test/services/refactoring/legacy/extract_method_test.dart
@@ -348,7 +348,7 @@
''');
_createRefactoringForStringOffset('(');
return _assertConditionsFatal(
- "Can only extract a single expression or a set of statements.");
+ 'Can only extract a single expression or a set of statements.');
}
Future<void> test_bad_functionDeclaration_inParameters() async {
@@ -357,7 +357,7 @@
''');
_createRefactoringForStringOffset(')');
return _assertConditionsFatal(
- "Can only extract a single expression or a set of statements.");
+ 'Can only extract a single expression or a set of statements.');
}
Future<void> test_bad_functionDeclaration_name() async {
@@ -366,7 +366,7 @@
''');
_createRefactoringForStringOffset('st()');
return _assertConditionsFatal(
- "Can only extract a single expression or a set of statements.");
+ 'Can only extract a single expression or a set of statements.');
}
Future<void> test_bad_methodName_reference() async {
diff --git a/pkg/analysis_server/test/services/search/hierarchy_test.dart b/pkg/analysis_server/test/services/search/hierarchy_test.dart
index f5f4e1f..3ac5e22 100644
--- a/pkg/analysis_server/test/services/search/hierarchy_test.dart
+++ b/pkg/analysis_server/test/services/search/hierarchy_test.dart
@@ -136,10 +136,10 @@
await resolveTestCode(sb.toString());
var classLast = findElement.class_('X$last');
ClassMemberElement member =
- classLast.methods.where((element) => element.name == "foo").single;
- OperationPerformanceImpl performance = OperationPerformanceImpl("<root>");
+ classLast.methods.where((element) => element.name == 'foo').single;
+ OperationPerformanceImpl performance = OperationPerformanceImpl('<root>');
var result = await performance.runAsync(
- "getHierarchyMembers",
+ 'getHierarchyMembers',
(performance) => getHierarchyMembers(searchEngine, member,
performance: performance));
expect(result, hasLength(count));
diff --git a/pkg/analysis_server/test/services/search/search_engine_test.dart b/pkg/analysis_server/test/services/search/search_engine_test.dart
index a8dfb21..7fdd6e8 100644
--- a/pkg/analysis_server/test/services/search/search_engine_test.dart
+++ b/pkg/analysis_server/test/services/search/search_engine_test.dart
@@ -209,7 +209,7 @@
var subtypes = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- element, subtypes, OperationPerformanceImpl("<root>"));
+ element, subtypes, OperationPerformanceImpl('<root>'));
expect(subtypes, hasLength(3));
_assertContainsClass(subtypes, 'A');
_assertContainsClass(subtypes, 'B');
@@ -235,7 +235,7 @@
var subtypes = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- element, subtypes, OperationPerformanceImpl("<root>"));
+ element, subtypes, OperationPerformanceImpl('<root>'));
expect(subtypes, hasLength(3));
_assertContainsClass(subtypes, 'A');
_assertContainsClass(subtypes, 'B');
@@ -253,7 +253,7 @@
var subtypes = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- element, subtypes, OperationPerformanceImpl("<root>"));
+ element, subtypes, OperationPerformanceImpl('<root>'));
expect(subtypes, hasLength(2));
_assertContainsClass(subtypes, 'B');
_assertContainsClass(subtypes, 'C');
@@ -276,7 +276,7 @@
var subtypes = <InterfaceElement>{};
await searchEngine.appendAllSubtypes(
- element, subtypes, OperationPerformanceImpl("<root>"));
+ element, subtypes, OperationPerformanceImpl('<root>'));
expect(subtypes, hasLength(5));
_assertContainsClass(subtypes, 'A');
_assertContainsClass(subtypes, 'B');
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
index 83aa3ae..178e261 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
@@ -234,7 +234,7 @@
''');
}
- @FailingTest(issue: "https://github.com/dart-lang/sdk/issues/51139")
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/51139')
Future<void> test_caseConstConstructorCall() async {
await resolveTestCode('''
class A {
@@ -357,7 +357,7 @@
await assertNoFix();
}
- @FailingTest(reason: "TODO(keertip): Add support for local variables")
+ @FailingTest(reason: 'TODO(keertip): Add support for local variables')
Future<void> test_caseWithLocalVariable() async {
await resolveTestCode('''
void f() {
@@ -402,7 +402,7 @@
''');
}
- @FailingTest(reason: "TODO(keertip): Add support for local variables")
+ @FailingTest(reason: 'TODO(keertip): Add support for local variables')
Future<void> test_relationalExpressionConst() async {
await resolveTestCode('''
void f(int x) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
index 5742a1a..6e60aff 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart
@@ -515,7 +515,7 @@
''');
}
- @FailingTest(issue: "https://github.com/dart-lang/sdk/issues/50950")
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/50950')
Future<void> test_switchExpression() async {
await resolveTestCode('''
void f() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_var_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_var_test.dart
index 2bfb843..d1ff5cb 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_var_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_var_test.dart
@@ -34,8 +34,8 @@
}
@FailingTest(
- issue: "https://github.com/dart-lang/sdk/issues/49960",
- reason: "Fix once error is reported")
+ issue: 'https://github.com/dart-lang/sdk/issues/49960',
+ reason: 'Fix once error is reported')
Future<void> test_declaredVariablePattern_patternAssignment() async {
await resolveTestCode('''
f() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
index bfa6a50..a832ece 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
@@ -21,7 +21,7 @@
FixKind get kind => DartFixKind.REPLACE_COLON_WITH_EQUALS;
@override
- String get latestLanguageVersion => "2.19";
+ String get latestLanguageVersion => '2.19';
Future<void> test_defaultFormalParameter() async {
await resolveTestCode('''
diff --git a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
index 0273c08..a117ccc 100644
--- a/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
+++ b/pkg/analysis_server/test/src/services/refactoring/move_top_level_to_file_test.dart
@@ -1724,7 +1724,7 @@
await _refactor(
originalSource: originalSource,
expected: expected,
- actionTitle: "Move $count declarations to file",
+ actionTitle: 'Move $count declarations to file',
otherFilePath: otherFilePath,
otherFileContent: otherFileContent,
);
diff --git a/pkg/analysis_server/test/tool/lsp_spec/meta_model_test.dart b/pkg/analysis_server/test/tool/lsp_spec/meta_model_test.dart
index b854fbe..0101f28 100644
--- a/pkg/analysis_server/test/tool/lsp_spec/meta_model_test.dart
+++ b/pkg/analysis_server/test/tool/lsp_spec/meta_model_test.dart
@@ -18,21 +18,21 @@
});
test('reads an interface', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "SomeOptions",
- "properties": [
+ 'name': 'SomeOptions',
+ 'properties': [
{
- "name": "options",
- "type": {
- "kind": "array",
- "element": {"kind": "reference", "name": "string"}
+ 'name': 'options',
+ 'type': {
+ 'kind': 'array',
+ 'element': {'kind': 'reference', 'name': 'string'}
},
- "optional": true,
- "documentation": "Options used by something.",
+ 'optional': true,
+ 'documentation': 'Options used by something.',
}
],
- "documentation": "Some options."
+ 'documentation': 'Some options.'
},
],
};
@@ -55,28 +55,28 @@
test('reads an interface with a field with an inline/unnamed type', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "Capabilities",
- "properties": [
+ 'name': 'Capabilities',
+ 'properties': [
{
- "name": "textDoc",
- "type": {
- "kind": "literal",
- "value": {
- "properties": [
+ 'name': 'textDoc',
+ 'type': {
+ 'kind': 'literal',
+ 'value': {
+ 'properties': [
{
- "name": "deprecated",
- "type": {"kind": "base", "name": "bool"},
- "optional": true,
+ 'name': 'deprecated',
+ 'type': {'kind': 'base', 'name': 'bool'},
+ 'optional': true,
}
]
}
},
- "optional": true,
+ 'optional': true,
}
],
- "documentation": "Some options."
+ 'documentation': 'Some options.'
},
],
};
@@ -110,19 +110,19 @@
test('reads an interface with multiple fields', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "SomeOptions",
- "properties": [
+ 'name': 'SomeOptions',
+ 'properties': [
{
- "name": "options0",
- "type": {"kind": "reference", "name": "LSPAny"},
- "documentation": "Options0 used by something.",
+ 'name': 'options0',
+ 'type': {'kind': 'reference', 'name': 'LSPAny'},
+ 'documentation': 'Options0 used by something.',
},
{
- "name": "options1",
- "type": {"kind": "reference", "name": "LSPAny"},
- "documentation": "Options1 used by something.",
+ 'name': 'options1',
+ 'type': {'kind': 'reference', 'name': 'LSPAny'},
+ 'documentation': 'Options1 used by something.',
}
],
},
@@ -143,18 +143,18 @@
test('reads an interface with a map into a MapType', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "WorkspaceEdit",
- "properties": [
+ 'name': 'WorkspaceEdit',
+ 'properties': [
{
- "name": "changes",
- "type": {
- "kind": "map",
- "key": {"kind": "base", "name": "string"},
- "value": {
- "kind": "array",
- "element": {"kind": "reference", "name": "TextEdit"}
+ 'name': 'changes',
+ 'type': {
+ 'kind': 'map',
+ 'key': {'kind': 'base', 'name': 'string'},
+ 'value': {
+ 'kind': 'array',
+ 'element': {'kind': 'reference', 'name': 'TextEdit'}
},
},
}
@@ -176,39 +176,39 @@
test('flags nullable undefined values', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "A",
- "properties": [
+ 'name': 'A',
+ 'properties': [
{
- "name": "canBeBoth",
- "type": {
- "kind": "or",
- "items": [
- {"kind": "base", "name": "string"},
- {"kind": "base", "name": "null"}
+ 'name': 'canBeBoth',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
+ {'kind': 'base', 'name': 'string'},
+ {'kind': 'base', 'name': 'null'}
]
},
- "optional": true,
+ 'optional': true,
},
{
- "name": "canBeNeither",
- "type": {"kind": "base", "name": "string"},
+ 'name': 'canBeNeither',
+ 'type': {'kind': 'base', 'name': 'string'},
},
{
- "name": "canBeNull",
- "type": {
- "kind": "or",
- "items": [
- {"kind": "base", "name": "string"},
- {"kind": "base", "name": "null"}
+ 'name': 'canBeNull',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
+ {'kind': 'base', 'name': 'string'},
+ {'kind': 'base', 'name': 'null'}
]
},
},
{
- "name": "canBeUndefined",
- "type": {"kind": "base", "name": "string"},
- "optional": true,
+ 'name': 'canBeUndefined',
+ 'type': {'kind': 'base', 'name': 'string'},
+ 'optional': true,
},
],
},
@@ -236,11 +236,11 @@
test('formats comments correctly', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "A",
- "properties": [],
- "documentation": r"""
+ 'name': 'A',
+ 'properties': [],
+ 'documentation': r"""
Describes the what this class in lots of words that wrap onto multiple lines that will need re-wrapping to format nicely when converted into Dart.
Blank lines should remain in-tact, as should:
@@ -275,12 +275,12 @@
test('reads a type alias', () {
final input = {
- "typeAliases": [
+ 'typeAliases': [
{
- "name": "DocumentSelector",
- "type": {
- "kind": "array",
- "element": {"kind": "reference", "name": "DocumentFilter"}
+ 'name': 'DocumentSelector',
+ 'type': {
+ 'kind': 'array',
+ 'element': {'kind': 'reference', 'name': 'DocumentFilter'}
},
},
],
@@ -295,30 +295,30 @@
test('reads a type alias that is a union of unnamed types', () {
final input = {
- "typeAliases": [
+ 'typeAliases': [
{
- "name": "NameOrLength",
- "type": {
- "kind": "or",
- "items": [
+ 'name': 'NameOrLength',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
{
- "kind": "literal",
- "value": {
- "properties": [
+ 'kind': 'literal',
+ 'value': {
+ 'properties': [
{
- "name": "name",
- "type": {"kind": "base", "name": "string"}
+ 'name': 'name',
+ 'type': {'kind': 'base', 'name': 'string'}
},
]
},
},
{
- "kind": "literal",
- "value": {
- "properties": [
+ 'kind': 'literal',
+ 'value': {
+ 'properties': [
{
- "name": "length",
- "type": {"kind": "base", "name": "number"}
+ 'name': 'length',
+ 'type': {'kind': 'base', 'name': 'number'}
},
]
},
@@ -359,27 +359,27 @@
test('reads a namespace of constants', () {
final input = {
- "enumerations": [
+ 'enumerations': [
{
- "name": "ResourceOperationKind",
- "type": {"kind": "base", "name": "string"},
- "values": [
+ 'name': 'ResourceOperationKind',
+ 'type': {'kind': 'base', 'name': 'string'},
+ 'values': [
{
- "name": "Create",
- "value": "create",
- "documentation": "Supports creating new files and folders.",
+ 'name': 'Create',
+ 'value': 'create',
+ 'documentation': 'Supports creating new files and folders.',
},
{
- "name": "Delete",
- "value": "delete",
- "documentation":
- "Supports deleting existing files and folders.",
+ 'name': 'Delete',
+ 'value': 'delete',
+ 'documentation':
+ 'Supports deleting existing files and folders.',
},
{
- "name": "Rename",
- "value": "rename",
- "documentation":
- "Supports renaming existing files and folders.",
+ 'name': 'Rename',
+ 'value': 'rename',
+ 'documentation':
+ 'Supports renaming existing files and folders.',
},
],
},
@@ -413,21 +413,21 @@
test('reads a tuple in an array', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "SomeInformation",
- "properties": [
+ 'name': 'SomeInformation',
+ 'properties': [
{
- "name": "label",
- "type": {
- "kind": "or",
- "items": [
- {"kind": "base", "name": "string"},
+ 'name': 'label',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
+ {'kind': 'base', 'name': 'string'},
{
- "kind": "tuple",
- "items": [
- {"kind": "base", "name": "number"},
- {"kind": "base", "name": "number"}
+ 'kind': 'tuple',
+ 'items': [
+ {'kind': 'base', 'name': 'number'},
+ {'kind': 'base', 'name': 'number'}
]
}
]
@@ -454,17 +454,17 @@
test('reads an union including LSPAny into a single type', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "SomeInformation",
- "properties": [
+ 'name': 'SomeInformation',
+ 'properties': [
{
- "name": "label",
- "type": {
- "kind": "or",
- "items": [
- {"kind": "base", "name": "string"},
- {"kind": "base", "name": "LSPAny"},
+ 'name': 'label',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
+ {'kind': 'base', 'name': 'string'},
+ {'kind': 'base', 'name': 'LSPAny'},
]
},
},
@@ -485,13 +485,13 @@
test('reads literal string values', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "MyType",
- "properties": [
+ 'name': 'MyType',
+ 'properties': [
{
- "name": "kind",
- "type": {"kind": "stringLiteral", "value": "one"},
+ 'name': 'kind',
+ 'type': {'kind': 'stringLiteral', 'value': 'one'},
},
],
},
@@ -513,17 +513,17 @@
test('reads literal union values', () {
final input = {
- "structures": [
+ 'structures': [
{
- "name": "MyType",
- "properties": [
+ 'name': 'MyType',
+ 'properties': [
{
- "name": "kind",
- "type": {
- "kind": "or",
- "items": [
- {"kind": "stringLiteral", "value": "one"},
- {"kind": "stringLiteral", "value": "two"},
+ 'name': 'kind',
+ 'type': {
+ 'kind': 'or',
+ 'items': [
+ {'kind': 'stringLiteral', 'value': 'one'},
+ {'kind': 'stringLiteral', 'value': 'two'},
]
},
},
diff --git a/pkg/analysis_server/tool/codebase/failing_tests.dart b/pkg/analysis_server/tool/codebase/failing_tests.dart
index 5723ac6..d30b774 100644
--- a/pkg/analysis_server/tool/codebase/failing_tests.dart
+++ b/pkg/analysis_server/tool/codebase/failing_tests.dart
@@ -131,7 +131,7 @@
.where((arg) => arg.name.label.name == 'issue')
.firstOrNull;
final issueUrl = (issue?.expression as SimpleStringLiteral?)?.value;
- if (issueUrl != null && issueUrl.startsWith("https://github.com/")) {
+ if (issueUrl != null && issueUrl.startsWith('https://github.com/')) {
final issueUri = Uri.parse(issueUrl);
final apiUri = issueUri.replace(
host: 'api.github.com',
diff --git a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
index 784652d..17e9613 100644
--- a/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
+++ b/pkg/analysis_server/tool/lsp_spec/codegen_dart.dart
@@ -389,11 +389,11 @@
buffer.writeIndentedln('return $invocation;');
} else {
buffer
- ..writeIndentedln("if (!$invocation) {")
+ ..writeIndentedln('if (!$invocation) {')
..indent()
- ..writeIndentedln("return false;")
+ ..writeIndentedln('return false;')
..outdent()
- ..writeIndentedln("}");
+ ..writeIndentedln('}');
}
if (!_canParseFunctions.containsKey(functionName)) {
var temp = IndentableStringBuffer();
@@ -427,28 +427,28 @@
'}) {');
buffer
- ..writeIndentedln("reporter.push(fieldName);")
+ ..writeIndentedln('reporter.push(fieldName);')
..writeIndentedln('try {')
..indent();
buffer
- ..writeIndentedln("if (!allowsUndefined && !map.containsKey(fieldName)) {")
+ ..writeIndentedln('if (!allowsUndefined && !map.containsKey(fieldName)) {')
..indent()
..writeIndentedln("reporter.reportError('must not be undefined');")
..writeIndentedln('return false;')
..outdent()
..writeIndentedln('}');
- buffer.writeIndentedln("final value = map[fieldName];");
- buffer.writeIndentedln("final nullCheck = allowsNull || allowsUndefined;");
+ buffer.writeIndentedln('final value = map[fieldName];');
+ buffer.writeIndentedln('final nullCheck = allowsNull || allowsUndefined;');
buffer
- ..writeIndentedln("if (!nullCheck && value == null) {")
+ ..writeIndentedln('if (!nullCheck && value == null) {')
..indent()
..writeIndentedln("reporter.reportError('must not be null');")
..writeIndentedln('return false;')
..outdent()
..writeIndentedln('}');
- buffer.writeIndented("if ((!nullCheck || value != null) && ");
+ buffer.writeIndented('if ((!nullCheck || value != null) && ');
_writeTypeCheckCondition(buffer, interface, 'value', type, 'reporter',
negation: true, parenForCollection: true);
@@ -458,7 +458,7 @@
buffer
..write(') {')
..indent()
- ..writeIndentedln("reporter.reportError($quote$failureMessage$quote);")
+ ..writeIndentedln('reporter.reportError($quote$failureMessage$quote);')
..writeIndentedln('return false;')
..outdent()
..writeIndentedln('}')
@@ -470,7 +470,7 @@
..writeIndentedln('}')
..writeIndentedln('return true;');
- buffer.writeln("}");
+ buffer.writeln('}');
}
void _writeConst(IndentableStringBuffer buffer, Constant cons) {
@@ -843,9 +843,9 @@
}
if (interface.abstract) {
buffer.writeIndentedln(
- "throw ArgumentError("
+ 'throw ArgumentError('
"'Supplied map is not valid for any subclass of ${interface.name}'"
- ");",
+ ');',
);
} else {
for (final field in allFields) {
diff --git a/pkg/analysis_server/tool/lsp_test_with_parameters.dart b/pkg/analysis_server/tool/lsp_test_with_parameters.dart
index 60e7643..833ce3c 100644
--- a/pkg/analysis_server/tool/lsp_test_with_parameters.dart
+++ b/pkg/analysis_server/tool/lsp_test_with_parameters.dart
@@ -7,7 +7,7 @@
import 'dart:io';
Future<void> main(List<String> args) async {
- print("""
+ print('''
================================================================================
Stress test tool for language-server protocol.
@@ -27,15 +27,15 @@
--every=<int> Set how often - in ms - to fire an event. Defaults to 100.
================================================================================
-""");
+''');
{
Uri exe = Uri.base.resolve(Platform.resolvedExecutable);
Uri librariesDart =
- exe.resolve("../lib/_internal/sdk_library_metadata/lib/libraries.dart");
+ exe.resolve('../lib/_internal/sdk_library_metadata/lib/libraries.dart');
if (!File.fromUri(librariesDart).existsSync()) {
- throw "Execute with a dart that has "
+ throw 'Execute with a dart that has '
"'../lib/_internal/sdk_library_metadata/lib/libraries.dart' "
- "available (e.g. out/ReleaseX64/dart-sdk/bin/dart)";
+ 'available (e.g. out/ReleaseX64/dart-sdk/bin/dart)';
}
}
Uri? rootUri;
@@ -45,24 +45,24 @@
int? clickColumn;
int everyMs = 100;
for (String arg in args) {
- if (arg.startsWith("--root=")) {
- rootUri = Uri.base.resolve(arg.substring("--root=".length).trim());
- } else if (arg.startsWith("--sdk=")) {
- sdkUri = Uri.base.resolve(arg.substring("--sdk=".length).trim());
- } else if (arg.startsWith("--click=")) {
- clickOnUri = Uri.base.resolve(arg.substring("--click=".length).trim());
- } else if (arg.startsWith("--line=")) {
- clickLine = int.parse(arg.substring("--line=".length).trim());
- } else if (arg.startsWith("--column=")) {
- clickColumn = int.parse(arg.substring("--column=".length).trim());
- } else if (arg.startsWith("--every=")) {
- everyMs = int.parse(arg.substring("--every=".length).trim());
- } else if (arg == "--verbose" || arg == "-v") {
+ if (arg.startsWith('--root=')) {
+ rootUri = Uri.base.resolve(arg.substring('--root='.length).trim());
+ } else if (arg.startsWith('--sdk=')) {
+ sdkUri = Uri.base.resolve(arg.substring('--sdk='.length).trim());
+ } else if (arg.startsWith('--click=')) {
+ clickOnUri = Uri.base.resolve(arg.substring('--click='.length).trim());
+ } else if (arg.startsWith('--line=')) {
+ clickLine = int.parse(arg.substring('--line='.length).trim());
+ } else if (arg.startsWith('--column=')) {
+ clickColumn = int.parse(arg.substring('--column='.length).trim());
+ } else if (arg.startsWith('--every=')) {
+ everyMs = int.parse(arg.substring('--every='.length).trim());
+ } else if (arg == '--verbose' || arg == '-v') {
verbosity++;
- } else if (arg.startsWith("--verbosity=")) {
- verbosity = int.parse(arg.substring("--verbosity=".length).trim());
+ } else if (arg.startsWith('--verbosity=')) {
+ verbosity = int.parse(arg.substring('--verbosity='.length).trim());
} else {
- throw "Unknown argument: $arg";
+ throw 'Unknown argument: $arg';
}
}
@@ -71,7 +71,7 @@
}
if (!Directory.fromUri(rootUri).existsSync()) {
throw "Directory $rootUri doesn't exist. "
- "Specify existing directory with --root=";
+ 'Specify existing directory with --root=';
}
if (sdkUri == null) {
@@ -79,7 +79,7 @@
}
if (!Directory.fromUri(sdkUri).existsSync()) {
throw "Directory $sdkUri doesn't exist. "
- "Specify existing directory with --sdk=";
+ 'Specify existing directory with --sdk=';
}
if (clickOnUri == null) {
@@ -87,7 +87,7 @@
}
if (!File.fromUri(clickOnUri).existsSync()) {
throw "File $clickOnUri doesn't exist. "
- "Specify existing file with --click=";
+ 'Specify existing file with --click=';
}
if (clickLine == null) {
@@ -98,7 +98,7 @@
}
Process p = await Process.start(Platform.resolvedExecutable, [
- "language-server",
+ 'language-server',
]);
p.stdout.listen(listenToStdout);
@@ -108,17 +108,17 @@
in outstandingRequestsWithId.entries) {
if (waitingFor.value.elapsed > const Duration(seconds: 1)) {
if (!reportedSomething) {
- print("----");
+ print('----');
reportedSomething = true;
}
- print("==> Has been waiting for ${waitingFor.key} for "
- "${waitingFor.value.elapsed}");
+ print('==> Has been waiting for ${waitingFor.key} for '
+ '${waitingFor.value.elapsed}');
}
}
if (reportedSomething) {
- print("----");
+ print('----');
} else {
- print(" -- not waiting for anything -- ");
+ print(' -- not waiting for anything -- ');
}
});
@@ -151,9 +151,9 @@
int? headerContentLength;
Map<String, dynamic> initNotification = {
- "jsonrpc": "2.0",
- "method": "initialized",
- "params": {}
+ 'jsonrpc': '2.0',
+ 'method': 'initialized',
+ 'params': {}
};
/// There's something weird about getting (several) id 3's that wasn't
@@ -165,12 +165,12 @@
int verbosity = 0;
Map<String, dynamic> gotoDef(int id, Uri uri, int line, int char) {
return {
- "jsonrpc": "2.0",
- "id": id,
- "method": "textDocument/definition",
- "params": {
- "textDocument": {"uri": "$uri"},
- "position": {"line": line, "character": char}
+ 'jsonrpc': '2.0',
+ 'id': id,
+ 'method': 'textDocument/definition',
+ 'params': {
+ 'textDocument': {'uri': '$uri'},
+ 'position': {'line': line, 'character': char}
}
};
}
@@ -184,19 +184,19 @@
name = rootUri.pathSegments[rootUri.pathSegments.length - 2];
}
return {
- "id": 0,
- "jsonrpc": "2.0",
- "method": "initialize",
- "params": {
- "processId": processId,
- "clientInfo": {"name": "lspTestScript", "version": "0.0.1"},
- "locale": "en",
- "rootPath": rootPath,
- "rootUri": "$rootUri",
- "capabilities": {},
- "initializationOptions": {},
- "workspaceFolders": [
- {"uri": "$rootUri", "name": rootUri.pathSegments.last}
+ 'id': 0,
+ 'jsonrpc': '2.0',
+ 'method': 'initialize',
+ 'params': {
+ 'processId': processId,
+ 'clientInfo': {'name': 'lspTestScript', 'version': '0.0.1'},
+ 'locale': 'en',
+ 'rootPath': rootPath,
+ 'rootUri': '$rootUri',
+ 'capabilities': {},
+ 'initializationOptions': {},
+ 'workspaceFolders': [
+ {'uri': '$rootUri', 'name': rootUri.pathSegments.last}
]
}
};
@@ -205,13 +205,13 @@
Map<String, dynamic> initMore(Uri sdkUri) {
String sdkPath = sdkUri.toFilePath();
return {
- "id": 1,
- "jsonrpc": "2.0",
- "result": [
+ 'id': 1,
+ 'jsonrpc': '2.0',
+ 'result': [
{
- "useLsp": true,
- "sdkPath": sdkPath,
- "allowAnalytics": false,
+ 'useLsp': true,
+ 'sdkPath': sdkPath,
+ 'allowAnalytics': false,
}
]
};
@@ -223,17 +223,17 @@
for (int element in event) {
buffer.add(element);
if (verbosity > 3 && buffer.length % 1000 == 999) {
- print("DEBUG MESSAGE: Stdout buffer with length ${buffer.length} so far: "
- "${utf8.decode(buffer)}");
+ print('DEBUG MESSAGE: Stdout buffer with length ${buffer.length} so far: '
+ '${utf8.decode(buffer)}');
}
if (headerContentLength == null && _endsWithCrLfCrLf()) {
String headerRaw = utf8.decode(buffer);
buffer.clear();
- List<String> headers = headerRaw.split("\r\n");
+ List<String> headers = headerRaw.split('\r\n');
for (String header in headers) {
- if (header.startsWith("Content-Length:")) {
+ if (header.startsWith('Content-Length:')) {
String contentLength =
- header.substring("Content-Length:".length).trim();
+ header.substring('Content-Length:'.length).trim();
headerContentLength = int.parse(contentLength);
break;
}
@@ -245,7 +245,7 @@
headerContentLength = null;
Map<String, dynamic> message =
json.decode(messageString) as Map<String, dynamic>;
- dynamic possibleId = message["id"];
+ dynamic possibleId = message['id'];
if (possibleId is int) {
if (possibleId > largestIdSeen) {
largestIdSeen = possibleId;
@@ -253,9 +253,9 @@
if (verbosity > 0) {
if (messageString.length > 100) {
- print("Got message ${messageString.substring(0, 100)}...");
+ print('Got message ${messageString.substring(0, 100)}...');
} else {
- print("Got message $messageString");
+ print('Got message $messageString');
}
}
@@ -263,14 +263,14 @@
if (stopwatch != null) {
stopwatch.stop();
if (verbosity > 2) {
- print(" => Got response for $possibleId in ${stopwatch.elapsed}");
+ print(' => Got response for $possibleId in ${stopwatch.elapsed}');
}
}
} else if (verbosity > 1) {
if (messageString.length > 100) {
- print("Got message ${messageString.substring(0, 100)}...");
+ print('Got message ${messageString.substring(0, 100)}...');
} else {
- print("Got message $messageString");
+ print('Got message $messageString');
}
}
receivedCompleter.complete(message);
@@ -288,12 +288,12 @@
'Content-Type: application/vscode-jsonrpc; charset=utf-8\r\n\r\n';
final asciiEncodedHeader = ascii.encode(header);
- dynamic possibleId = json["id"];
+ dynamic possibleId = json['id'];
if (possibleId is int && possibleId > largestIdSeen) {
largestIdSeen = possibleId;
outstandingRequestsWithId[possibleId] = Stopwatch()..start();
if (verbosity > 2) {
- print("Sending message with id $possibleId");
+ print('Sending message with id $possibleId');
}
}
@@ -302,7 +302,7 @@
p.stdin.add(utf8EncodedBody);
await p.stdin.flush();
if (verbosity > 2) {
- print("\n\nMessage sent...\n\n");
+ print('\n\nMessage sent...\n\n');
}
}
diff --git a/pkg/analyzer/doc/implementation/coding_style.md b/pkg/analyzer/doc/implementation/coding_style.md
index 98175ed..808b7e2 100644
--- a/pkg/analyzer/doc/implementation/coding_style.md
+++ b/pkg/analyzer/doc/implementation/coding_style.md
@@ -23,6 +23,9 @@
None.
+- prefer_single_quotes - We don't enforce this in each of our packages yet, but
+ we aspire to.
+
### Formatting and sorting
All of our source code is expected to be