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

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

Issue 2862623002: Add default implementation when fixing missing required closures (flutter-intellij#975) (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 | pkg/analysis_server/lib/src/services/correction/fix_internal.dart » ('j') | 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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 String className = classId.name; 171 String className = classId.name;
172 if (className != null && className.length > 0) { 172 if (className != null && className.length > 0) {
173 suggestion.declaringType = className; 173 suggestion.declaringType = className;
174 } 174 }
175 } 175 }
176 } 176 }
177 return suggestion; 177 return suggestion;
178 } 178 }
179 179
180 String getDefaultStringParameterValue(ParameterElement param) { 180 String getDefaultStringParameterValue(ParameterElement param) {
181 DartType type = param.type; 181 if (param != null) {
182 if (type is InterfaceType && isDartList(type)) { 182 DartType type = param.type;
183 List<DartType> typeArguments = type.typeArguments; 183 if (type is InterfaceType && isDartList(type)) {
184 StringBuffer sb = new StringBuffer(); 184 List<DartType> typeArguments = type.typeArguments;
185 if (typeArguments.length == 1) { 185 if (typeArguments.length == 1) {
186 DartType typeArg = typeArguments.first; 186 DartType typeArg = typeArguments.first;
187 if (!typeArg.isDynamic) { 187 String typeInfo = !typeArg.isDynamic ? '<${typeArg.name}>' : '';
188 sb.write('<${typeArg.name}>'); 188 return '$typeInfo[]';
189 } 189 }
190 sb.write('[]');
191 return sb.toString();
192 } 190 }
191 if (type is FunctionType) {
192 String params = type.parameters.map((p) => p.name).join(', ');
193 //TODO(pq): consider adding a `TODO:` message in generated stub
194 return '($params) {}';
195 }
196 //TODO(pq): support map literals
193 } 197 }
194 return null; 198 return null;
195 } 199 }
196 200
197 bool isDartList(DartType type) { 201 bool isDartList(DartType type) {
198 ClassElement element = type.element; 202 ClassElement element = type.element;
199 if (element != null) { 203 if (element != null) {
200 return element.name == "List" && element.library.isDartCore; 204 return element.name == "List" && element.library.isDartCore;
201 } 205 }
202 return false; 206 return false;
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 //TODO (danrubel) include type arguments 245 //TODO (danrubel) include type arguments
242 } 246 }
243 return name; 247 return name;
244 } else if (type is GenericFunctionType) { 248 } else if (type is GenericFunctionType) {
245 // TODO(brianwilkerson) Implement this. 249 // TODO(brianwilkerson) Implement this.
246 } 250 }
247 return DYNAMIC; 251 return DYNAMIC;
248 } 252 }
249 253
250 String _getDefaultValue(ParameterElement param) => 'null'; 254 String _getDefaultValue(ParameterElement param) => 'null';
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/correction/fix_internal.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698