Version 2.17.0-28.0.dev
Merge commit '92da2376bc17357906eb99483f868d7d159ff34e' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
index 72174fe..128ff49 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/override_contributor.dart
@@ -71,6 +71,7 @@
SimpleIdentifier? _getTargetIdFromVarList(VariableDeclarationList fields) {
var variables = fields.variables;
+ var type = fields.type;
if (variables.length == 1) {
var variable = variables[0];
var targetId = variable.name;
@@ -81,10 +82,23 @@
// where _s_ is a synthetic id inserted by the analyzer parser
return targetId;
} else if (fields.keyword == null &&
- fields.type == null &&
+ type == null &&
variable.initializer == null) {
// fasta parser does not insert a synthetic identifier
return targetId;
+ } else if (fields.keyword == null &&
+ type is NamedType &&
+ type.typeArguments == null &&
+ variable.initializer == null) {
+ // class A extends B {
+ // m^
+ //
+ // String foo;
+ // }
+ // Parses as a variable list where `m` is the type and `String` is a
+ // variable.
+ var name = type.name;
+ return name is SimpleIdentifier ? name : null;
}
}
return null;
diff --git a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
index 0e65414..df03716 100644
--- a/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/override_contributor_test.dart
@@ -42,6 +42,56 @@
_assertNoOverrideContaining('bar');
}
+ Future<void> test_beforeGetter() async {
+ addTestSource('''
+class A {
+ method() {}
+ int? age;
+}
+
+class B extends A {
+ m^
+
+ String value1 = '';
+}
+''');
+ await computeSuggestions();
+ _assertOverride('''
+@override
+ method() {
+ // TODO: implement method
+ return super.method();
+ }''',
+ displayText: 'method() { … }',
+ selectionOffset: 57,
+ selectionLength: 22);
+ }
+
+ Future<void> test_beforeMethod() async {
+ addTestSource('''
+class A {
+ method() {}
+ int? age;
+}
+
+class B extends A {
+ m^
+
+ void b() {}
+}
+''');
+ await computeSuggestions();
+ _assertOverride('''
+@override
+ method() {
+ // TODO: implement method
+ return super.method();
+ }''',
+ displayText: 'method() { … }',
+ selectionOffset: 57,
+ selectionLength: 22);
+ }
+
Future<void> test_customOperator() async {
addTestSource('''
class A {
@@ -386,12 +436,13 @@
''');
await computeSuggestions();
_assertOverride('''
-method() {
+@override
+ method() {
// TODO: implement method
return super.method();
}''',
displayText: 'method() { … }',
- selectionOffset: 45,
+ selectionOffset: 57,
selectionLength: 22);
}
diff --git a/tools/VERSION b/tools/VERSION
index 9aa63f0..b7b6318 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 17
PATCH 0
-PRERELEASE 27
+PRERELEASE 28
PRERELEASE_PATCH 0
\ No newline at end of file