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

Unified Diff: pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Issue 1475743003: Issue 24865. Quick Fix 'Create Method' should create named parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index ce09e5a6d0e8137c4735bcc72ce2e1896103f0e9..5dc5c2df0601534fdccdf9239b89356d1e03ebd7 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -1979,6 +1979,7 @@ class FixProcessor {
// append parameters
sb.append('(');
List<Expression> arguments = argumentList.arguments;
+ bool hasNamedParameters = false;
for (int i = 0; i < arguments.length; i++) {
Expression argument = arguments[i];
// append separator
@@ -1986,8 +1987,15 @@ class FixProcessor {
sb.append(', ');
}
// append parameter
+ if (argument is NamedExpression && !hasNamedParameters) {
+ hasNamedParameters = true;
+ sb.append('{');
+ }
_appendParameterForArgument(sb, i, argument);
}
+ if (hasNamedParameters) {
+ sb.append('}');
+ }
}
void _addFix_undefinedMethod_useSimilar() {
@@ -2281,7 +2289,9 @@ class FixProcessor {
sb.append(' ');
}
// append parameter name
- {
+ if (argument is NamedExpression) {
+ sb.append(argument.name.label.name);
+ } else {
Set<String> excluded = new Set<String>();
List<String> suggestions =
_getArgumentNameSuggestions(excluded, type, argument, index);
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/correction/fix_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698