Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1949)

Unified Diff: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart

Issue 2927343002: Prioritize required name param completions (flutter-intellij#1049). (Closed)
Patch Set: Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
diff --git a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
index 4c870b6da78132170f6889c61fc1014cdb2ebf83..3f6193e5f8b70c8654983f15a92280567f5ebe14 100644
--- a/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
+++ b/pkg/analysis_server/test/services/completion/dart/arglist_contributor_test.dart
@@ -95,9 +95,11 @@ class ArgListContributorTest extends DartCompletionContributorTest {
*/
void assertSuggestArgumentsAndTypes(
{Map<String, String> namedArgumentsWithTypes,
+ List<int> requiredParamIndices: const <int>[],
bool includeColon: true,
bool includeComma: false}) {
List<CompletionSuggestion> expected = new List<CompletionSuggestion>();
+ int paramIndex = 0;
namedArgumentsWithTypes.forEach((String name, String type) {
String completion = includeColon ? '$name: ' : name;
// Selection should be before any trailing commas.
@@ -105,9 +107,12 @@ class ArgListContributorTest extends DartCompletionContributorTest {
if (includeComma) {
completion = '$completion,';
}
+ int relevance = requiredParamIndices.contains(paramIndex++)
+ ? DART_RELEVANCE_NAMED_PARAMETER_REQUIRED
+ : DART_RELEVANCE_NAMED_PARAMETER;
expected.add(assertSuggest(completion,
csKind: CompletionSuggestionKind.NAMED_ARGUMENT,
- relevance: DART_RELEVANCE_NAMED_PARAMETER,
+ relevance: relevance,
paramName: name,
paramType: type,
selectionOffset: selectionOffset));
@@ -863,6 +868,18 @@ main() { new A(^, two: 'foo');}''');
completion: 'one: ', selectionOffset: 5);
}
+ test_ArgumentList_local_constructor_required_param_0() async {
+ addMetaPackageSource();
+ addTestSource('''
+import 'package:meta/meta.dart';
+class A { A({int one, @required String two: 'defaultValue'}) { } }
+main() { new A(^);}''');
+ await computeSuggestions();
+ assertSuggestArgumentsAndTypes(
+ namedArgumentsWithTypes: {'one': 'int', 'two': 'String'},
+ requiredParamIndices: [1]);
+ }
+
test_ArgumentList_local_function_1() async {
// ArgumentList MethodInvocation ExpressionStatement Block
addTestSource('''

Powered by Google App Engine
This is Rietveld 408576698