Chromium Code Reviews| 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 import 'dart:collection'; | 5 import 'dart:collection'; |
| 6 | 6 |
| 7 /// Helpers for Analyzer's Element model and corelib model. | 7 /// Helpers for Analyzer's Element model and corelib model. |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart' | 9 import 'package:analyzer/dart/ast/ast.dart' |
| 10 show | 10 show |
| 11 ConstructorDeclaration, | 11 ConstructorDeclaration, |
| 12 Expression, | 12 Expression, |
| 13 FunctionBody, | 13 FunctionBody, |
| 14 FunctionExpression, | 14 FunctionExpression, |
| 15 MethodDeclaration, | 15 MethodDeclaration, |
| 16 MethodInvocation, | 16 MethodInvocation, |
| 17 SimpleIdentifier; | 17 SimpleIdentifier; |
| 18 import 'package:analyzer/dart/element/element.dart' | 18 import 'package:analyzer/dart/element/element.dart' |
| 19 show ClassElement, Element, ExecutableElement, FunctionElement; | 19 show |
| 20 ClassElement, | |
| 21 Element, | |
| 22 ExecutableElement, | |
| 23 FunctionElement, | |
| 24 LibraryElement; | |
| 20 import 'package:analyzer/dart/element/type.dart' | 25 import 'package:analyzer/dart/element/type.dart' |
| 21 show DartType, InterfaceType, ParameterizedType; | 26 show DartType, InterfaceType, ParameterizedType; |
| 22 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; | 27 import 'package:analyzer/src/dart/element/type.dart' show DynamicTypeImpl; |
| 23 import 'package:analyzer/src/generated/constant.dart' | 28 import 'package:analyzer/src/generated/constant.dart' |
| 24 show DartObject, DartObjectImpl; | 29 show DartObject, DartObjectImpl; |
| 25 | 30 |
| 26 class Tuple2<T0, T1> { | 31 class Tuple2<T0, T1> { |
| 27 final T0 e0; | 32 final T0 e0; |
| 28 final T1 e1; | 33 final T1 e1; |
| 29 Tuple2(this.e0, this.e1); | 34 Tuple2(this.e0, this.e1); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 if (mixin != null) result.add(mixin); | 137 if (mixin != null) result.add(mixin); |
| 133 } | 138 } |
| 134 var supertype = cls.supertype; | 139 var supertype = cls.supertype; |
| 135 if (supertype == null) break; | 140 if (supertype == null) break; |
| 136 | 141 |
| 137 cls = supertype.element; | 142 cls = supertype.element; |
| 138 result.add(cls); | 143 result.add(cls); |
| 139 } | 144 } |
| 140 return result; | 145 return result; |
| 141 } | 146 } |
| 147 | |
| 148 List<ClassElement> getSuperclassesInSameLibrary(ClassElement cls) { | |
| 149 var result = <ClassElement>[]; | |
| 150 var visited = new HashSet<ClassElement>(); | |
| 151 var library = cls.library; | |
| 152 while (cls != null && visited.add(cls)) { | |
| 153 for (var mixinType in cls.mixins.reversed) { | |
|
vsm
2017/03/27 22:31:27
I think we should get nested mixins (see https://c
Jennifer Messerly
2017/03/27 23:16:27
hmmm. Those guys unfortunately break assumptions a
| |
| 154 var mixin = mixinType.element; | |
| 155 if (mixin != null && mixin.library == library) result.add(mixin); | |
| 156 } | |
| 157 var superclass = cls.supertype?.element; | |
| 158 if (superclass?.library != library) break; | |
|
vsm
2017/03/27 22:31:27
Don't we need to keep going in case we've got some
Jennifer Messerly
2017/03/27 23:16:28
Let me investigate based on the use cases. I only
| |
| 159 | |
| 160 result.add(superclass); | |
| 161 cls = superclass; | |
| 162 } | |
| 163 return result; | |
| 164 } | |
| 165 | |
| 166 List<ClassElement> getImmediateSuperclasses(ClassElement c) { | |
| 167 var result = <ClassElement>[]; | |
| 168 for (var m in c.mixins.reversed) { | |
| 169 result.add(m.element); | |
| 170 } | |
| 171 var s = c.supertype; | |
| 172 if (s != null) result.add(s.element); | |
| 173 return result; | |
| 174 } | |
| 175 | |
| 176 bool isSdkInternalRuntime(LibraryElement l) => | |
| 177 l.isInSdk && l.source.uri.toString() == 'dart:_runtime'; | |
| OLD | NEW |