Skip to content

Commit 9be1160

Browse files
bwilkersoncommit-bot@chromium.org
authored andcommitted
Do not suggest the keyword const when completing in a constant context
While it isn't an error to use `const` in those contexts, it also isn't necessary and we already omit `new` because it's never required. This makes `const` more consistent with `new`. Change-Id: Ia577065d53ab57543b86161f5e62e3947ff9a2a7 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/151029 Reviewed-by: Jaime Wren <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent 3a31bc2 commit 9be1160

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -758,11 +758,13 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
758758

759759
void _addExpressionKeywords(AstNode node) {
760760
_addSuggestions([
761-
Keyword.CONST,
762761
Keyword.FALSE,
763762
Keyword.NULL,
764763
Keyword.TRUE,
765764
]);
765+
if (!request.inConstantContext) {
766+
_addSuggestions([Keyword.CONST]);
767+
}
766768
if (node.inClassMemberBody) {
767769
_addSuggestions([Keyword.SUPER, Keyword.THIS]);
768770
}

0 commit comments

Comments
 (0)