Version 3.0.0-17.0.dev
Merge 315ff0b8a290f04cc9b023fe0b8f29788e4e138c into dev
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/rename_to_camel_case.dart b/pkg/analysis_server/lib/src/services/correction/dart/rename_to_camel_case.dart
index 7c36201..1dffa0e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/rename_to_camel_case.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/rename_to_camel_case.dart
@@ -43,8 +43,21 @@
} else if (node is VariableDeclaration) {
nameToken = node.name;
element = node.declaredElement;
+ } else if (node is RecordTypeAnnotationField) {
+ // RecordTypeAnnotationFields do not have Elements.
+ nameToken = node.name;
+ var newName = nameToken?.lexeme.toLowerCamelCase;
+ if (newName == null) {
+ return;
+ }
+ _newName = newName;
+ await builder.addDartFileEdit(file, (builder) {
+ builder.addSimpleReplacement(range.token(nameToken!), _newName);
+ });
+ return;
}
- if (nameToken == null || element == null) {
+
+ if (nameToken == null) {
return;
}
@@ -54,6 +67,9 @@
return;
}
_newName = newName;
+ if (element == null) {
+ return;
+ }
// Find references to the identifier.
List<SimpleIdentifier>? references;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
index a70faee..ee12665 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
@@ -155,4 +155,13 @@
}
''');
}
+
+ Future<void> test_recordField() async {
+ await resolveTestCode('''
+void f(({int some_field}) p) {}
+''');
+ await assertHasFix('''
+void f(({int someField}) p) {}
+''');
+ }
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
index 7c3c8dc..3b60641 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
@@ -80,6 +80,33 @@
''');
}
+ Future<void> test_emptyRecordLiteral() async {
+ await resolveTestCode('''
+final () a = ();
+''');
+ await assertHasFix('''
+const () a = ();
+''');
+ }
+
+ Future<void> test_recordLiteral() async {
+ await resolveTestCode('''
+final (int, int) a = (1, 2);
+''');
+ await assertHasFix('''
+const (int, int) a = (1, 2);
+''');
+ }
+
+ Future<void> test_recordLiteral_nonConst() async {
+ await resolveTestCode('''
+void f(int a) {
+ final (int, int) r = (a, a);
+}
+''');
+ await assertNoFix();
+ }
+
Future<void> test_variable() async {
await resolveTestCode('''
final int a = 1;
diff --git a/tools/VERSION b/tools/VERSION
index 6fbdab5..965a3a0 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 3
MINOR 0
PATCH 0
-PRERELEASE 16
+PRERELEASE 17
PRERELEASE_PATCH 0