[analysis_server] Don't insert trailing commas when editing named argument labels
Change-Id: I691b19eebd8d01796b5763c066573de52192a8a3 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/234740 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Bot
parent
74e37c598e
commit
5ae1838569
@@ -74,7 +74,9 @@ class ArgListContributor extends DartCompletionContributor {
|
||||
// If there's a replacement length and the preference is to replace,
|
||||
// we should not include colons/commas.
|
||||
appendColon: appendColon && !willReplace,
|
||||
appendComma: appendComma && !willReplace,
|
||||
// Commas should always be suppressed when we're not inserting colons:
|
||||
// ke^: Key()
|
||||
appendComma: appendComma && appendColon && !willReplace,
|
||||
replacementLength: replacementLength);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -168,6 +168,27 @@ build() => new Row(
|
||||
});
|
||||
}
|
||||
|
||||
Future<void> test_flutter_InstanceCreationExpression_3() async {
|
||||
// Ensure a trailing comma is not added when only replacing the name.
|
||||
writeTestPackageConfig(flutter: true);
|
||||
|
||||
addTestSource('''
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
build() => new Row(
|
||||
ke^: null,
|
||||
);
|
||||
''');
|
||||
|
||||
var response = await computeSuggestions2();
|
||||
_checkNamedArguments(response).containsMatch((suggestion) {
|
||||
suggestion
|
||||
..completion.isEqualTo('key')
|
||||
..defaultArgumentListString.isNull
|
||||
..hasSelection(offset: 3);
|
||||
});
|
||||
}
|
||||
|
||||
Future<void>
|
||||
test_flutter_InstanceCreationExpression_children_dynamic() async {
|
||||
// Ensure we don't generate unneeded <dynamic> param if a future API doesn't
|
||||
|
||||
Reference in New Issue
Block a user