| OLD | NEW |
| 1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2016, 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 /// Helpers for Analyzer's Element model and corelib model. | 5 /// Helpers for Analyzer's Element model and corelib model. |
| 6 | 6 |
| 7 import 'package:analyzer/dart/ast/ast.dart' | 7 import 'package:analyzer/dart/ast/ast.dart' |
| 8 show | 8 show |
| 9 ConstructorDeclaration, | 9 ConstructorDeclaration, |
| 10 Expression, | 10 Expression, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 show DartObject, DartObjectImpl; | 22 show DartObject, DartObjectImpl; |
| 23 | 23 |
| 24 class Tuple2<T0, T1> { | 24 class Tuple2<T0, T1> { |
| 25 final T0 e0; | 25 final T0 e0; |
| 26 final T1 e1; | 26 final T1 e1; |
| 27 Tuple2(this.e0, this.e1); | 27 Tuple2(this.e0, this.e1); |
| 28 } | 28 } |
| 29 | 29 |
| 30 /*=T*/ fillDynamicTypeArgs/*<T extends DartType>*/(/*=T*/ t) { | 30 /*=T*/ fillDynamicTypeArgs/*<T extends DartType>*/(/*=T*/ t) { |
| 31 if (t is ParameterizedType) { | 31 if (t is ParameterizedType) { |
| 32 var pt = t as ParameterizedType; | |
| 33 var dyn = new List<DartType>.filled( | 32 var dyn = new List<DartType>.filled( |
| 34 pt.typeArguments.length, DynamicTypeImpl.instance); | 33 t.typeArguments.length, DynamicTypeImpl.instance); |
| 35 return pt.substitute2(dyn, pt.typeArguments) as dynamic/*=T*/; | 34 return t.substitute2(dyn, t.typeArguments) as dynamic/*=T*/; |
| 36 } | 35 } |
| 37 return t; | 36 return t; |
| 38 } | 37 } |
| 39 | 38 |
| 40 /// Given an annotated [node] and a [test] function, returns the first matching | 39 /// Given an annotated [node] and a [test] function, returns the first matching |
| 41 /// constant valued annotation. | 40 /// constant valued annotation. |
| 42 /// | 41 /// |
| 43 /// For example if we had the ClassDeclaration node for `FontElement`: | 42 /// For example if we had the ClassDeclaration node for `FontElement`: |
| 44 /// | 43 /// |
| 45 /// @js.JS('HTMLFontElement') | 44 /// @js.JS('HTMLFontElement') |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 /// const MyAnnotation(this.name/*, ... other params ... */); | 113 /// const MyAnnotation(this.name/*, ... other params ... */); |
| 115 /// } | 114 /// } |
| 116 /// | 115 /// |
| 117 /// @MyAnnotation('FooBar') | 116 /// @MyAnnotation('FooBar') |
| 118 /// main() { ... } | 117 /// main() { ... } |
| 119 /// | 118 /// |
| 120 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will | 119 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will |
| 121 /// return the string 'FooBar'. | 120 /// return the string 'FooBar'. |
| 122 String getAnnotationName(Element element, bool match(DartObjectImpl value)) => | 121 String getAnnotationName(Element element, bool match(DartObjectImpl value)) => |
| 123 findAnnotation(element, match)?.getField('name')?.toStringValue(); | 122 findAnnotation(element, match)?.getField('name')?.toStringValue(); |
| OLD | NEW |