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

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

Issue 1664423002: Issue 25650. Generate unique parameter names when create a method or function. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« 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 1e148de7e269f2d1f67f0bc0ce03448d6a8a299d..ffdf72d3f9d09bd9771938cb5e016c6cbab3d4cf 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -447,7 +447,8 @@ class FixProcessor {
if (numRequired != 0) {
sb.append(', ');
}
- _appendParameterForArgument(sb, numRequired, argument);
+ _appendParameterForArgument(
+ sb, new Set<String>(), numRequired, argument);
if (numRequired != numParameters) {
sb.append(', ');
}
@@ -463,7 +464,8 @@ class FixProcessor {
sb.append(', ');
}
sb.append('[');
- _appendParameterForArgument(sb, numRequired, argument);
+ _appendParameterForArgument(
+ sb, new Set<String>(), numRequired, argument);
sb.append(']');
// add proposal
_insertBuilder(sb, targetElement);
@@ -2032,6 +2034,7 @@ class FixProcessor {
void _addFix_undefinedMethod_create_parameters(
SourceBuilder sb, ArgumentList argumentList) {
+ Set<String> usedNames = new Set<String>();
// append parameters
sb.append('(');
List<Expression> arguments = argumentList.arguments;
@@ -2047,7 +2050,7 @@ class FixProcessor {
hasNamedParameters = true;
sb.append('{');
}
- _appendParameterForArgument(sb, i, argument);
+ _appendParameterForArgument(sb, usedNames, i, argument);
}
if (hasNamedParameters) {
sb.append('}');
@@ -2333,7 +2336,7 @@ class FixProcessor {
}
void _appendParameterForArgument(
- SourceBuilder sb, int index, Expression argument) {
+ SourceBuilder sb, Set<String> excluded, int index, Expression argument) {
// append type name
DartType type = argument.bestType;
String typeSource = utils.getTypeSource(type, librariesToImport);
@@ -2348,7 +2351,6 @@ class FixProcessor {
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);
String favorite = suggestions[0];
« 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