Skip to content

Commit 851701d

Browse files
pqcommit-bot@chromium.org
authored andcommitted
add BREAK suggestions to switch cases
fixes: #36605 Change-Id: I29e3b6a46c542895995b5eedcc64262352bb49a0 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/114748 Reviewed-by: Dan Rubel <[email protected]> Commit-Queue: Phil Quitslund <[email protected]>
1 parent 57f7941 commit 851701d

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,12 @@ class _KeywordVisitor extends GeneralizingAstVisitor {
646646
}
647647
}
648648

649+
@override
650+
visitSwitchCase(SwitchCase node) {
651+
_addSuggestion(Keyword.BREAK);
652+
return super.visitSwitchCase(node);
653+
}
654+
649655
@override
650656
visitTryStatement(TryStatement node) {
651657
var obj = entity;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,18 @@ f() => [...^];
19831983
relevance: DART_RELEVANCE_HIGH);
19841984
}
19851985

1986+
test_switch_statement_case_break_insideClass() async {
1987+
addTestSource('class A{foo() {switch(1) {case 1: b^}}}');
1988+
await computeSuggestions();
1989+
assertSuggestKeywords([Keyword.BREAK]);
1990+
}
1991+
1992+
test_switch_statement_case_break_outsideClass() async {
1993+
addTestSource('foo() {switch(1) {case 1: b^}}');
1994+
await computeSuggestions();
1995+
assertSuggestKeywords([Keyword.BREAK]);
1996+
}
1997+
19861998
test_switch_statement_insideClass() async {
19871999
addTestSource('class A{foo() {switch(1) {case 1:^}}}');
19882000
await computeSuggestions();

0 commit comments

Comments
 (0)