Improve the completion of return types on FunctionTypedFormalParameters in FormalParameterLists
Change-Id: I7c7446f5077844daadf935f5ec0af5b12da739fc Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142600 Commit-Queue: Jaime Wren <jwren@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
commit-bot@chromium.org
parent
a31781f737
commit
f0f3199daa
@@ -360,11 +360,12 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
||||
var constructorDeclaration =
|
||||
node.thisOrAncestorOfType<ConstructorDeclaration>();
|
||||
if (constructorDeclaration != null) {
|
||||
_addSuggestions([Keyword.THIS]);
|
||||
_addSuggestion(Keyword.THIS);
|
||||
}
|
||||
if (entity is Token && (entity as Token).type == TokenType.CLOSE_PAREN) {
|
||||
_addSuggestion(Keyword.COVARIANT);
|
||||
_addSuggestion(Keyword.DYNAMIC);
|
||||
_addSuggestion(Keyword.VOID);
|
||||
if (request.featureSet.isEnabled(Feature.non_nullable)) {
|
||||
_addSuggestion(Keyword.REQUIRED);
|
||||
}
|
||||
@@ -373,6 +374,14 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
|
||||
if (beginToken != null && request.target.offset == beginToken.end) {
|
||||
_addSuggestion(Keyword.COVARIANT);
|
||||
_addSuggestion(Keyword.DYNAMIC);
|
||||
_addSuggestion(Keyword.VOID);
|
||||
if (request.featureSet.isEnabled(Feature.non_nullable)) {
|
||||
_addSuggestion(Keyword.REQUIRED);
|
||||
}
|
||||
} else if (entity is FunctionTypedFormalParameter) {
|
||||
_addSuggestion(Keyword.COVARIANT);
|
||||
_addSuggestion(Keyword.DYNAMIC);
|
||||
_addSuggestion(Keyword.VOID);
|
||||
if (request.featureSet.isEnabled(Feature.non_nullable)) {
|
||||
_addSuggestion(Keyword.REQUIRED);
|
||||
}
|
||||
|
||||
@@ -103,8 +103,15 @@ class F {m() { m(); !1}}''', <String>['1+m']);
|
||||
class F {var x = !1false;}''', <String>['1+true']);
|
||||
|
||||
buildTests('testCommentSnippets018', '''
|
||||
class Map{}class Arrays{}class C{ m(!1){} n(!2 x, q)''',
|
||||
<String>['1+Map', '1-void', '1-null', '2+Arrays', '2-void', '2-null']);
|
||||
class Map{}class Arrays{}class C{ m(!1){} n(!2 x, q)''', <String>[
|
||||
'1+Map',
|
||||
'1+dynamic',
|
||||
'1+void',
|
||||
'1-null',
|
||||
'2+Arrays',
|
||||
'2-void',
|
||||
'2-null'
|
||||
]);
|
||||
|
||||
buildTests('testCommentSnippets019', '''
|
||||
class A{m(){Object x;x.!1/**/clear()''', <String>['1+toString']);
|
||||
|
||||
@@ -71,7 +71,13 @@ class KeywordContributorTest extends DartCompletionContributorTest {
|
||||
}
|
||||
|
||||
List<Keyword> get constructorParameter {
|
||||
var keywords = <Keyword>[Keyword.COVARIANT, Keyword.DYNAMIC, Keyword.THIS];
|
||||
var keywords = <Keyword>[
|
||||
Keyword.COVARIANT,
|
||||
Keyword.DYNAMIC,
|
||||
Keyword.THIS,
|
||||
Keyword.DYNAMIC,
|
||||
Keyword.VOID
|
||||
];
|
||||
if (isEnabled(ExperimentalFeatures.non_nullable)) {
|
||||
keywords.add(Keyword.REQUIRED);
|
||||
}
|
||||
@@ -156,7 +162,7 @@ class KeywordContributorTest extends DartCompletionContributorTest {
|
||||
}
|
||||
|
||||
List<Keyword> get methodParameter {
|
||||
var keywords = <Keyword>[Keyword.COVARIANT, Keyword.DYNAMIC];
|
||||
var keywords = <Keyword>[Keyword.COVARIANT, Keyword.DYNAMIC, Keyword.VOID];
|
||||
if (isEnabled(ExperimentalFeatures.non_nullable)) {
|
||||
keywords.add(Keyword.REQUIRED);
|
||||
}
|
||||
@@ -1028,12 +1034,26 @@ class C {
|
||||
assertSuggestKeywords(constructorParameter);
|
||||
}
|
||||
|
||||
Future<void> test_constructor_param_noPrefix_func_parameter() async {
|
||||
addTestSource('class A { A(^ Function(){}) {}}');
|
||||
await computeSuggestions();
|
||||
expect(suggestions, isNotEmpty);
|
||||
assertSuggestKeywords(constructorParameter);
|
||||
}
|
||||
|
||||
Future<void> test_constructor_param_prefix() async {
|
||||
addTestSource('class A { A(t^) {}}');
|
||||
await computeSuggestions();
|
||||
assertSuggestKeywords(constructorParameter);
|
||||
}
|
||||
|
||||
Future<void> test_constructor_param_prefix_func_parameter() async {
|
||||
addTestSource('class A { A(v^ Function(){}) {}}');
|
||||
await computeSuggestions();
|
||||
expect(suggestions, isNotEmpty);
|
||||
assertSuggestKeywords(constructorParameter);
|
||||
}
|
||||
|
||||
Future<void> test_do_break_continue_insideClass() async {
|
||||
addTestSource('class A {foo() {do {^} while (true);}}');
|
||||
await computeSuggestions();
|
||||
@@ -1971,6 +1991,13 @@ f() => <int>{1, ^, 2};
|
||||
assertSuggestKeywords(methodParameter);
|
||||
}
|
||||
|
||||
Future<void> test_method_param_noPrefix_func_parameter() async {
|
||||
addTestSource('class A { foo(^ Function(){}) {}}');
|
||||
await computeSuggestions();
|
||||
expect(suggestions, isNotEmpty);
|
||||
assertSuggestKeywords(methodParameter);
|
||||
}
|
||||
|
||||
Future<void> test_method_param_positional_init() async {
|
||||
addTestSource('class A { foo([bool bar = ^]) {}}');
|
||||
await computeSuggestions();
|
||||
@@ -1992,6 +2019,13 @@ f() => <int>{1, ^, 2};
|
||||
assertSuggestKeywords(methodParameter);
|
||||
}
|
||||
|
||||
Future<void> test_method_param_prefix_func_parameter() async {
|
||||
addTestSource('class A { foo(v^ Function(){}) {}}');
|
||||
await computeSuggestions();
|
||||
expect(suggestions, isNotEmpty);
|
||||
assertSuggestKeywords(methodParameter);
|
||||
}
|
||||
|
||||
Future<void> test_mixin() async {
|
||||
addTestSource('mixin M o^ { }');
|
||||
await computeSuggestions();
|
||||
|
||||
Reference in New Issue
Block a user