| Index: pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
|
| diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
|
| index a179311633dce22b0642c9669c4ca0d06e0b4081..01775a3221b3737590a19959907318177ba623e3 100644
|
| --- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
|
| +++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
|
| @@ -277,6 +277,9 @@ class ArgListContributor extends DartCompletionContributor {
|
| sb.write('${parameter.name}: ');
|
| int offset = sb.length;
|
| sb.write(defaultValue);
|
| + if (appendComma) {
|
| + sb.write(',');
|
| + }
|
| suggestion.defaultArgumentListString = sb.toString();
|
| suggestion.defaultArgumentListTextRanges = [
|
| offset,
|
| @@ -302,16 +305,14 @@ class ArgListContributor extends DartCompletionContributor {
|
| // method which returns some enum with 5+ cases.
|
| if (_isEditingNamedArgLabel(request) || _isAppendingToArgList(request)) {
|
| if (requiredCount == 0 || requiredCount < _argCount(request)) {
|
| - _addDefaultParamSuggestions(parameters);
|
| + bool addTrailingComma =
|
| + !_isFollowedByAComma(request) && _isInFlutterCreation(request);
|
| + _addDefaultParamSuggestions(parameters, addTrailingComma);
|
| }
|
| } else if (_isInsertingToArgListWithNoSynthetic(request)) {
|
| _addDefaultParamSuggestions(parameters, true);
|
| } else if (_isInsertingToArgListWithSynthetic(request)) {
|
| - var entity = request.target.entity;
|
| - Token token =
|
| - entity is AstNode ? entity.endToken : entity is Token ? entity : null;
|
| - bool followedByComma = token?.next?.type == TokenType.COMMA;
|
| - _addDefaultParamSuggestions(parameters, !followedByComma);
|
| + _addDefaultParamSuggestions(parameters, !_isFollowedByAComma(request));
|
| }
|
| }
|
|
|
| @@ -328,6 +329,21 @@ class ArgListContributor extends DartCompletionContributor {
|
| return null;
|
| }
|
|
|
| + bool _isFollowedByAComma(DartCompletionRequest request) {
|
| + var entity = request.target.entity;
|
| + Token token =
|
| + entity is AstNode ? entity.endToken : entity is Token ? entity : null;
|
| + return token?.next?.type == TokenType.COMMA;
|
| + }
|
| +
|
| + bool _isInFlutterCreation(DartCompletionRequest request) {
|
| + AstNode containingNode = request?.target?.containingNode;
|
| + InstanceCreationExpression newExpr = containingNode != null
|
| + ? identifyNewExpression(containingNode.parent)
|
| + : null;
|
| + return newExpr != null && isFlutterInstanceCreationExpression(newExpr);
|
| + }
|
| +
|
| /**
|
| * If the given [comment] is not `null`, fill the [suggestion] documentation
|
| * fields.
|
|
|