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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/dart/utilities.dart

Issue 2844323004: Fix null default value access (#29512). (Closed)
Patch Set: Created 3 years, 7 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /** 5 /**
6 * A collection of utility methods used by completion contributors. 6 * A collection of utility methods used by completion contributors.
7 */ 7 */
8 import 'package:analysis_server/protocol/protocol_generated.dart' as protocol 8 import 'package:analysis_server/protocol/protocol_generated.dart' as protocol
9 show Element, ElementKind; 9 show Element, ElementKind;
10 import 'package:analysis_server/src/ide_options.dart'; 10 import 'package:analysis_server/src/ide_options.dart';
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 sb.write(defaultValue); 69 sb.write(defaultValue);
70 ranges.addAll([offset, defaultValue.length]); 70 ranges.addAll([offset, defaultValue.length]);
71 } 71 }
72 } 72 }
73 73
74 if (options?.generateFlutterWidgetChildrenBoilerPlate == true) { 74 if (options?.generateFlutterWidgetChildrenBoilerPlate == true) {
75 if (element is ConstructorElement) { 75 if (element is ConstructorElement) {
76 if (isFlutterWidget(element.enclosingElement)) { 76 if (isFlutterWidget(element.enclosingElement)) {
77 for (ParameterElement param in element.parameters) { 77 for (ParameterElement param in element.parameters) {
78 if (param.name == 'children') { 78 if (param.name == 'children') {
79 String defaultValue = getDefaultStringParameterValue(param); 79 String defaultValue = getDefaultStringParameterValue(param) ?? '';
Brian Wilkerson 2017/04/28 18:20:26 Or just fix `getDefaultStringParameterValue` to ne
pquitslund 2017/04/28 18:24:25 We use `null` as a sentinel elsewhere (in arglist_
80 if (sb.isNotEmpty) { 80 if (sb.isNotEmpty) {
81 sb.write(', '); 81 sb.write(', ');
82 } 82 }
83 sb.write('children: '); 83 sb.write('children: ');
84 offset = sb.length; 84 offset = sb.length;
85 sb.write(defaultValue); 85 sb.write(defaultValue);
86 ranges.addAll([offset, defaultValue.length]); 86 ranges.addAll([offset, defaultValue.length]);
87 } 87 }
88 } 88 }
89 } 89 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 //TODO (danrubel) include type arguments 241 //TODO (danrubel) include type arguments
242 } 242 }
243 return name; 243 return name;
244 } else if (type is GenericFunctionType) { 244 } else if (type is GenericFunctionType) {
245 // TODO(brianwilkerson) Implement this. 245 // TODO(brianwilkerson) Implement this.
246 } 246 }
247 return DYNAMIC; 247 return DYNAMIC;
248 } 248 }
249 249
250 String _getDefaultValue(ParameterElement param) => 'null'; 250 String _getDefaultValue(ParameterElement param) => 'null';
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698