| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 library analyzer.src.dart.element.element; | 5 library analyzer.src.dart.element.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 6220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6231 | 6231 |
| 6232 @override | 6232 @override |
| 6233 void appendTo(StringBuffer buffer) { | 6233 void appendTo(StringBuffer buffer) { |
| 6234 buffer.write(displayName); | 6234 buffer.write(displayName); |
| 6235 super.appendTo(buffer); | 6235 super.appendTo(buffer); |
| 6236 } | 6236 } |
| 6237 | 6237 |
| 6238 @override | 6238 @override |
| 6239 MethodDeclaration computeNode() => | 6239 MethodDeclaration computeNode() => |
| 6240 getNodeMatching((node) => node is MethodDeclaration); | 6240 getNodeMatching((node) => node is MethodDeclaration); |
| 6241 |
| 6242 @override |
| 6243 FunctionType getReifiedType(DartType objectType) { |
| 6244 // Collect the covariant parameters. Do this first so we don't allocate |
| 6245 // anything in the common case where there are none. |
| 6246 Set<String> covariantNames; |
| 6247 for (ParameterElement parameter in parameters) { |
| 6248 if (parameter.isCovariant) { |
| 6249 covariantNames ??= new Set(); |
| 6250 covariantNames.add(parameter.name); |
| 6251 } |
| 6252 } |
| 6253 |
| 6254 if (covariantNames == null) return type; |
| 6255 |
| 6256 List<ParameterElement> covariantParameters = parameters.map((parameter) { |
| 6257 if (!covariantNames.contains(parameter.name)) { |
| 6258 return parameter; |
| 6259 } |
| 6260 |
| 6261 return new ParameterElementImpl.synthetic( |
| 6262 parameter.name, objectType, parameter.parameterKind); |
| 6263 }).toList(); |
| 6264 |
| 6265 return new FunctionElementImpl.synthetic(covariantParameters, returnType) |
| 6266 .type; |
| 6267 } |
| 6241 } | 6268 } |
| 6242 | 6269 |
| 6243 /** | 6270 /** |
| 6244 * The constants for all of the modifiers defined by the Dart language and for a | 6271 * The constants for all of the modifiers defined by the Dart language and for a |
| 6245 * few additional flags that are useful. | 6272 * few additional flags that are useful. |
| 6246 * | 6273 * |
| 6247 * Clients may not extend, implement or mix-in this class. | 6274 * Clients may not extend, implement or mix-in this class. |
| 6248 */ | 6275 */ |
| 6249 class Modifier implements Comparable<Modifier> { | 6276 class Modifier implements Comparable<Modifier> { |
| 6250 /** | 6277 /** |
| (...skipping 2271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8522 | 8549 |
| 8523 @override | 8550 @override |
| 8524 void visitElement(Element element) { | 8551 void visitElement(Element element) { |
| 8525 int offset = element.nameOffset; | 8552 int offset = element.nameOffset; |
| 8526 if (offset != -1) { | 8553 if (offset != -1) { |
| 8527 map[offset] = element; | 8554 map[offset] = element; |
| 8528 } | 8555 } |
| 8529 super.visitElement(element); | 8556 super.visitElement(element); |
| 8530 } | 8557 } |
| 8531 } | 8558 } |
| OLD | NEW |