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

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart

Issue 2771123002: Arglist `children:` default value gen fixes. (Closed)
Patch Set: Remove unneeded assignment. Created 3 years, 9 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/lib/src/services/completion/dart/utilities.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/completion/dart/arglist_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
index 872051ee9d40e24343a78803ab5b7acb702f941f..0ff94078bede7019a50065631bd586079b6c7f93 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/arglist_contributor.dart
@@ -272,12 +272,11 @@ class ArgListContributor extends DartCompletionContributor {
String defaultValue = _getDefaultValue(parameter, request.ideOptions);
if (defaultValue != null) {
- //TODO(pq): unify with `utilities.dart`
StringBuffer sb = new StringBuffer();
sb.write('${parameter.name}: ');
int offset = sb.length;
sb.write(defaultValue);
- suggestion.defaultArgumentListString = defaultValue;
+ suggestion.defaultArgumentListString = sb.toString();
suggestion.defaultArgumentListTextRanges = [
offset,
defaultValue.length
@@ -288,28 +287,13 @@ class ArgListContributor extends DartCompletionContributor {
}
}
- //TODO(pq): move and unify w/ `utilities.dart`
String _getDefaultValue(ParameterElement param, IdeOptions options) {
if (options?.generateFlutterWidgetChildrenBoilerPlate == true) {
Element element = param.enclosingElement;
if (element is ConstructorElement) {
ClassElement classElement = element.enclosingElement;
- if (isFlutterWidget(classElement)) {
- if (param.name == 'children') {
- DartType type = param.type;
- if (type is InterfaceType && isDartList(type)) {
- List<DartType> typeArguments = type.typeArguments;
- StringBuffer sb = new StringBuffer();
- if (typeArguments.length == 1) {
- DartType typeArg = typeArguments.first;
- if (!typeArg.isDynamic) {
- sb.write('<${typeArg.name}>');
- }
- sb.write('[]');
- return sb.toString();
- }
- }
- }
+ if (isFlutterWidget(classElement) && param.name == 'children') {
+ return getDefaultStringParameterValue(param);
}
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/dart/utilities.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698