Pass the context as a single object in class body completion tests.
Change-Id: Iec7bc93a150a1dfe4d96ef6c1c87d334db28146a
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/232760
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
diff --git a/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart b/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart
index 8d27610..43f63a5 100644
--- a/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/location/class_body_test.dart
@@ -51,20 +51,16 @@
Future<void> test_nothing_x() async {
await _checkContainers(
line: '^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
// TODO(scheglov) Not quite right, without static.
Keyword.CONST,
- if (isClass || isMixin) Keyword.COVARIANT,
+ if (context.isClass || context.isMixin) Keyword.COVARIANT,
Keyword.DYNAMIC,
// TODO(scheglov) This does not look right, mixin.
- if (isClass || isMixin) Keyword.FACTORY,
+ if (context.isClass || context.isMixin) Keyword.FACTORY,
Keyword.FINAL,
Keyword.GET,
Keyword.LATE,
@@ -83,11 +79,7 @@
Future<void> test_static_const_x() async {
await _checkContainers(
line: 'static const ^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
@@ -103,11 +95,7 @@
Future<void> test_static_final_Ox() async {
await _checkContainers(
line: 'static final O^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
if (isProtocolVersion2) {
check(response).suggestions
..withKindKeyword.isEmpty
@@ -129,11 +117,7 @@
Future<void> test_static_final_x() async {
await _checkContainers(
line: 'static final ^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
@@ -149,11 +133,7 @@
Future<void> test_static_fx() async {
await _checkContainers(
line: 'static f^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
if (isProtocolVersion2) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
@@ -188,11 +168,7 @@
Future<void> test_static_late_x() async {
await _checkContainers(
line: 'static late ^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
@@ -208,11 +184,7 @@
Future<void> test_static_x() async {
await _checkContainers(
line: 'static ^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
@@ -230,11 +202,7 @@
Future<void> test_static_x_name_eq() async {
await _checkContainers(
line: 'static ^ name = 0;',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
{
@@ -258,11 +226,7 @@
Future<void> test_sx() async {
await _checkContainers(
line: 's^',
- validator: (
- response, {
- required bool isClass,
- required bool isMixin,
- }) {
+ validator: (context, response) {
if (isProtocolVersion2) {
check(response).suggestions
..withKindKeyword.matchesInAnyOrder(
@@ -282,10 +246,10 @@
{
// TODO(scheglov) Not quite right, without static.
Keyword.CONST,
- if (isClass || isMixin) Keyword.COVARIANT,
+ if (context.isClass || context.isMixin) Keyword.COVARIANT,
Keyword.DYNAMIC,
// TODO(scheglov) This does not look right, mixin.
- if (isClass || isMixin) Keyword.FACTORY,
+ if (context.isClass || context.isMixin) Keyword.FACTORY,
Keyword.FINAL,
Keyword.GET,
Keyword.LATE,
@@ -305,10 +269,9 @@
Future<void> _checkContainers({
required String line,
required void Function(
- CompletionResponseForTesting response, {
- required bool isClass,
- required bool isMixin,
- })
+ _Context context,
+ CompletionResponseForTesting response,
+ )
validator,
}) async {
// class
@@ -318,11 +281,7 @@
$line
}
''');
- validator(
- response,
- isClass: true,
- isMixin: false,
- );
+ validator(_Context(isClass: true), response);
}
// enum
{
@@ -332,11 +291,7 @@
$line
}
''');
- validator(
- response,
- isClass: false,
- isMixin: false,
- );
+ validator(_Context(), response);
}
// extension
{
@@ -345,11 +300,7 @@
$line
}
''');
- validator(
- response,
- isClass: false,
- isMixin: false,
- );
+ validator(_Context(), response);
}
// mixin
{
@@ -358,11 +309,17 @@
$line
}
''');
- validator(
- response,
- isClass: false,
- isMixin: true,
- );
+ validator(_Context(isMixin: true), response);
}
}
}
+
+class _Context {
+ final bool isClass;
+ final bool isMixin;
+
+ _Context({
+ this.isClass = false,
+ this.isMixin = false,
+ });
+}