| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 elements; | 5 library elements; |
| 6 | 6 |
| 7 | 7 |
| 8 import '../tree/tree.dart'; | 8 import '../tree/tree.dart'; |
| 9 import '../util/util.dart'; | 9 import '../util/util.dart'; |
| 10 import '../resolution/resolution.dart'; | 10 import '../resolution/resolution.dart'; |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 | 224 |
| 225 /// Returns true if this [Element] is a top level element. | 225 /// Returns true if this [Element] is a top level element. |
| 226 /// That is, if it is not defined within the scope of a class. | 226 /// That is, if it is not defined within the scope of a class. |
| 227 /// | 227 /// |
| 228 /// This means whether the enclosing element is a compilation unit. | 228 /// This means whether the enclosing element is a compilation unit. |
| 229 /// With the exception of [ClosureClassElement] that is considered top level | 229 /// With the exception of [ClosureClassElement] that is considered top level |
| 230 /// as all other classes. | 230 /// as all other classes. |
| 231 bool isTopLevel(); | 231 bool isTopLevel(); |
| 232 bool isAssignable(); | 232 bool isAssignable(); |
| 233 bool isNative(); | 233 bool isNative(); |
| 234 bool isDeferredLoaderGetter(); |
| 234 | 235 |
| 235 bool impliesType(); | 236 bool impliesType(); |
| 236 | 237 |
| 237 Token position(); | 238 Token position(); |
| 238 | 239 |
| 239 CompilationUnitElement getCompilationUnit(); | 240 CompilationUnitElement getCompilationUnit(); |
| 240 LibraryElement getLibrary(); | 241 LibraryElement getLibrary(); |
| 241 LibraryElement getImplementationLibrary(); | 242 LibraryElement getImplementationLibrary(); |
| 242 ClassElement getEnclosingClass(); | 243 ClassElement getEnclosingClass(); |
| 243 Element getEnclosingClassOrCompilationUnit(); | 244 Element getEnclosingClassOrCompilationUnit(); |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 325 } |
| 325 | 326 |
| 326 static bool isStaticOrTopLevel(Element element) { | 327 static bool isStaticOrTopLevel(Element element) { |
| 327 // TODO(ager): This should not be necessary when patch support has | 328 // TODO(ager): This should not be necessary when patch support has |
| 328 // been reworked. | 329 // been reworked. |
| 329 if (!Elements.isUnresolved(element) | 330 if (!Elements.isUnresolved(element) |
| 330 && element.modifiers.isStatic()) { | 331 && element.modifiers.isStatic()) { |
| 331 return true; | 332 return true; |
| 332 } | 333 } |
| 333 return !Elements.isUnresolved(element) | 334 return !Elements.isUnresolved(element) |
| 335 && !element.isAmbiguous() |
| 334 && !element.isInstanceMember() | 336 && !element.isInstanceMember() |
| 335 && !element.isPrefix() | 337 && !element.isPrefix() |
| 336 && element.enclosingElement != null | 338 && element.enclosingElement != null |
| 337 && (element.enclosingElement.kind == ElementKind.CLASS || | 339 && (element.enclosingElement.kind == ElementKind.CLASS || |
| 338 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT || | 340 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT || |
| 339 element.enclosingElement.kind == ElementKind.LIBRARY); | 341 element.enclosingElement.kind == ElementKind.LIBRARY || |
| 342 element.enclosingElement.kind == ElementKind.PREFIX); |
| 340 } | 343 } |
| 341 | 344 |
| 342 static bool isInStaticContext(Element element) { | 345 static bool isInStaticContext(Element element) { |
| 343 if (isUnresolved(element)) return true; | 346 if (isUnresolved(element)) return true; |
| 344 if (element.enclosingElement.isClosure()) { | 347 if (element.enclosingElement.isClosure()) { |
| 345 var closureClass = element.enclosingElement; | 348 var closureClass = element.enclosingElement; |
| 346 element = closureClass.methodElement; | 349 element = closureClass.methodElement; |
| 347 } | 350 } |
| 348 Element outer = element.getOutermostEnclosingMemberOrTopLevel(); | 351 Element outer = element.getOutermostEnclosingMemberOrTopLevel(); |
| 349 if (isUnresolved(outer)) return true; | 352 if (isUnresolved(outer)) return true; |
| (...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 String getLibraryOrScriptName(); | 742 String getLibraryOrScriptName(); |
| 740 | 743 |
| 741 int compareTo(LibraryElement other); | 744 int compareTo(LibraryElement other); |
| 742 } | 745 } |
| 743 | 746 |
| 744 abstract class PrefixElement extends Element { | 747 abstract class PrefixElement extends Element { |
| 745 void addImport(Element element, Import import, DiagnosticListener listener); | 748 void addImport(Element element, Import import, DiagnosticListener listener); |
| 746 Element lookupLocalMember(String memberName); | 749 Element lookupLocalMember(String memberName); |
| 747 /// Is true if this prefix belongs to a deferred import. | 750 /// Is true if this prefix belongs to a deferred import. |
| 748 bool get isDeferred; | 751 bool get isDeferred; |
| 749 void markAsDeferred(); | 752 void markAsDeferred(Import import); |
| 753 Import get deferredImport; |
| 750 } | 754 } |
| 751 | 755 |
| 752 abstract class TypedefElement extends Element | 756 abstract class TypedefElement extends Element |
| 753 implements TypeDeclarationElement { | 757 implements TypeDeclarationElement { |
| 754 TypedefType get thisType; | 758 TypedefType get thisType; |
| 755 TypedefType get rawType; | 759 TypedefType get rawType; |
| 756 DartType get alias; | 760 DartType get alias; |
| 757 FunctionSignature get functionSignature; | 761 FunctionSignature get functionSignature; |
| 758 Link<DartType> get typeVariables; | 762 Link<DartType> get typeVariables; |
| 759 | 763 |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1124 InterfaceType get declarer; | 1128 InterfaceType get declarer; |
| 1125 | 1129 |
| 1126 /// Returns `true` if this member is static. | 1130 /// Returns `true` if this member is static. |
| 1127 bool get isStatic; | 1131 bool get isStatic; |
| 1128 | 1132 |
| 1129 /// Returns `true` if this member is a getter or setter implicitly declared | 1133 /// Returns `true` if this member is a getter or setter implicitly declared |
| 1130 /// by a field. | 1134 /// by a field. |
| 1131 bool get isDeclaredByField; | 1135 bool get isDeclaredByField; |
| 1132 } | 1136 } |
| 1133 | 1137 |
| OLD | NEW |