Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 7e81554

Browse files
jwrencommit-bot@chromium.org
authored andcommitted
Add the dynamic keyword into additional missing portions of the AST in the keyword_contributor.dart
Change-Id: I64ff9721c151e3e51841ea638e8b2fd2b472ac27 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/138743 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Jaime Wren <[email protected]>
1 parent 7bc1714 commit 7e81554

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,15 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
513513

514514
@override
515515
void visitMethodInvocation(MethodInvocation node) {
516-
if (entity == node.methodName || entity == node.argumentList) {
517-
// no keywords in '.' expressions or type argument lists
516+
if (entity == node.methodName) {
517+
// no keywords in '.' expressions
518+
} else if (entity == node.argumentList) {
518519
// Note that we're checking the argumentList rather than the typeArgumentList
519520
// as you'd expect. For some reason, when the cursor is in a type argument
520521
// list (f<^>()), the entity is the invocation's argumentList...
521522
// See similar logic in `imported_reference_contributor`.
523+
524+
_addSuggestion(Keyword.DYNAMIC);
522525
} else {
523526
super.visitMethodInvocation(node);
524527
}
@@ -658,6 +661,11 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
658661
return visitStatement(node);
659662
}
660663

664+
@override
665+
void visitTypeArgumentList(TypeArgumentList node) {
666+
_addSuggestion(Keyword.DYNAMIC);
667+
}
668+
661669
@override
662670
void visitVariableDeclaration(VariableDeclaration node) {
663671
if (entity == node.initializer) {

pkg/analysis_server/test/services/completion/dart/keyword_contributor_test.dart

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2150,6 +2150,12 @@ f() => [...^];
21502150
assertSuggestKeywords(statementStartInSwitchOutsideClass);
21512151
}
21522152

2153+
Future<void> test_variable_decl_type_args() async {
2154+
addTestSource('void m() {List<^> list;}');
2155+
await computeSuggestions();
2156+
assertSuggestKeywords([Keyword.DYNAMIC]);
2157+
}
2158+
21532159
Future<void> test_while_break_continue() async {
21542160
addTestSource('main() {while (true) {^}}');
21552161
await computeSuggestions();
@@ -2267,7 +2273,7 @@ void m() {
22672273
''');
22682274

22692275
await computeSuggestions();
2270-
assertSuggestKeywords([]);
2276+
assertSuggestKeywords([Keyword.DYNAMIC]);
22712277
}
22722278
}
22732279

0 commit comments

Comments
 (0)