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

Side by Side Diff: pkg/dev_compiler/lib/src/compiler/element_helpers.dart

Issue 2571363002: fixes #27385, implement virtual fields in DDC (Closed)
Patch Set: rebase Created 4 years 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
OLDNEW
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 import 'dart:collection';
5 /// Helpers for Analyzer's Element model and corelib model. 6 /// Helpers for Analyzer's Element model and corelib model.
6 7
7 import 'package:analyzer/dart/ast/ast.dart' 8 import 'package:analyzer/dart/ast/ast.dart'
8 show 9 show
9 ConstructorDeclaration, 10 ConstructorDeclaration,
10 Expression, 11 Expression,
11 FunctionBody, 12 FunctionBody,
12 FunctionExpression, 13 FunctionExpression,
13 MethodDeclaration, 14 MethodDeclaration,
14 MethodInvocation, 15 MethodInvocation,
15 SimpleIdentifier; 16 SimpleIdentifier;
16 import 'package:analyzer/dart/element/element.dart' 17 import 'package:analyzer/dart/element/element.dart'
17 show Element, ExecutableElement, FunctionElement; 18 show ClassElement, Element, ExecutableElement, FunctionElement;
18 import 'package:analyzer/dart/element/type.dart' 19 import 'package:analyzer/dart/element/type.dart'
19 show DartType, InterfaceType, ParameterizedType; 20 show DartType, InterfaceType, ParameterizedType;
20 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; 21 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl;
21 import 'package:analyzer/src/generated/constant.dart' 22 import 'package:analyzer/src/generated/constant.dart'
22 show DartObject, DartObjectImpl; 23 show DartObject, DartObjectImpl;
23 24
24 class Tuple2<T0, T1> { 25 class Tuple2<T0, T1> {
25 final T0 e0; 26 final T0 e0;
26 final T1 e1; 27 final T1 e1;
27 Tuple2(this.e0, this.e1); 28 Tuple2(this.e0, this.e1);
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 /// const MyAnnotation(this.name/*, ... other params ... */); 114 /// const MyAnnotation(this.name/*, ... other params ... */);
114 /// } 115 /// }
115 /// 116 ///
116 /// @MyAnnotation('FooBar') 117 /// @MyAnnotation('FooBar')
117 /// main() { ... } 118 /// main() { ... }
118 /// 119 ///
119 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will 120 /// If we match the annotation for the `@MyAnnotation('FooBar')` this will
120 /// return the string 'FooBar'. 121 /// return the string 'FooBar'.
121 String getAnnotationName(Element element, bool match(DartObjectImpl value)) => 122 String getAnnotationName(Element element, bool match(DartObjectImpl value)) =>
122 findAnnotation(element, match)?.getField('name')?.toStringValue(); 123 findAnnotation(element, match)?.getField('name')?.toStringValue();
124
125 List<ClassElement> getSuperclasses(ClassElement cls) {
126 var result = <ClassElement>[];
127 var visited = new HashSet<ClassElement>();
128 while (cls != null && visited.add(cls)) {
129 for (var mixinType in cls.mixins.reversed) {
130 var mixin = mixinType.element;
131 if (mixin != null) result.add(mixin);
132 }
133 var supertype = cls.supertype;
134 if (supertype == null) break;
135
136 cls = supertype.element;
137 result.add(cls);
138 }
139 return result;
140 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698