| OLD | NEW |
| 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 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 182 DartType type = param.type; | 182 DartType type = param.type; |
| 183 if (type is InterfaceType && isDartList(type)) { | 183 if (type is InterfaceType && isDartList(type)) { |
| 184 List<DartType> typeArguments = type.typeArguments; | 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 String typeInfo = !typeArg.isDynamic ? '<${typeArg.name}>' : ''; | 187 String typeInfo = !typeArg.isDynamic ? '<${typeArg.name}>' : ''; |
| 188 return '$typeInfo[]'; | 188 return '$typeInfo[]'; |
| 189 } | 189 } |
| 190 } | 190 } |
| 191 if (type is FunctionType) { | 191 if (type is FunctionType) { |
| 192 String params = type.parameters.map((p) => p.name).join(', '); | 192 String params = type.parameters |
| 193 .map((p) => '${getTypeString(p.type)}${p.name}') |
| 194 .join(', '); |
| 193 //TODO(pq): consider adding a `TODO:` message in generated stub | 195 //TODO(pq): consider adding a `TODO:` message in generated stub |
| 194 return '($params) {}'; | 196 return '($params) {}'; |
| 195 } | 197 } |
| 196 //TODO(pq): support map literals | 198 //TODO(pq): support map literals |
| 197 } | 199 } |
| 198 return null; | 200 return null; |
| 199 } | 201 } |
| 200 | 202 |
| 203 String getTypeString(DartType type) => type.isDynamic ? '' : '${type.name} '; |
| 204 |
| 201 bool isDartList(DartType type) { | 205 bool isDartList(DartType type) { |
| 202 ClassElement element = type.element; | 206 ClassElement element = type.element; |
| 203 if (element != null) { | 207 if (element != null) { |
| 204 return element.name == "List" && element.library.isDartCore; | 208 return element.name == "List" && element.library.isDartCore; |
| 205 } | 209 } |
| 206 return false; | 210 return false; |
| 207 } | 211 } |
| 208 | 212 |
| 209 /** | 213 /** |
| 210 * Return `true` if the @deprecated annotation is present on the given [node]. | 214 * Return `true` if the @deprecated annotation is present on the given [node]. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (typeArgs != null) { | 248 if (typeArgs != null) { |
| 245 //TODO (danrubel) include type arguments | 249 //TODO (danrubel) include type arguments |
| 246 } | 250 } |
| 247 return name; | 251 return name; |
| 248 } else if (type is GenericFunctionType) { | 252 } else if (type is GenericFunctionType) { |
| 249 // TODO(brianwilkerson) Implement this. | 253 // TODO(brianwilkerson) Implement this. |
| 250 } | 254 } |
| 251 return DYNAMIC; | 255 return DYNAMIC; |
| 252 } | 256 } |
| 253 | 257 |
| 258 //TODO(pq): fix to use getDefaultStringParameterValue() |
| 254 String _getDefaultValue(ParameterElement param) => 'null'; | 259 String _getDefaultValue(ParameterElement param) => 'null'; |
| OLD | NEW |