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

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

Issue 2862623002: Add default implementation when fixing missing required closures (flutter-intellij#975) (Closed)
Patch Set: Created 3 years, 8 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/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 1332bbe12838502d532ce39b843f0e3670c00251..15119852ffc8b3714d1bc49716fa0d0ed1e35c9c 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -14,6 +14,7 @@ import 'package:analysis_server/protocol/protocol_generated.dart'
hide AnalysisError, Element, ElementKind;
import 'package:analysis_server/src/protocol_server.dart'
show doSourceChange_addElementEdit, doSourceChange_addSourceEdit;
+import 'package:analysis_server/src/services/completion/dart/utilities.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/correction/flutter_util.dart';
import 'package:analysis_server/src/services/correction/levenshtein.dart';
@@ -635,8 +636,11 @@ class FixProcessor {
sb.append(', ');
}
- // In the future consider better values than null for specific element types.
- sb.append('$paramName: null');
+ List<ParameterElement> parameters = targetElement.parameters;
+ ParameterElement element =
+ parameters.firstWhere((p) => p.name == paramName, orElse: () => null);
+ String defaultValue = getDefaultStringParameterValue(element);
+ sb.append('$paramName: $defaultValue'); // TODO(pq): add trailing comma
_insertBuilder(sb, null);
_addFix(DartFixKind.ADD_MISSING_REQUIRED_ARGUMENT, [paramName]);

Powered by Google App Engine
This is Rietveld 408576698