| 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'; |
| 11 | 11 |
| 12 import '../dart2jslib.dart' show InterfaceType, | 12 import '../dart2jslib.dart' show InterfaceType, |
| 13 DartType, | 13 DartType, |
| 14 TypeVariableType, | 14 TypeVariableType, |
| 15 TypedefType, | 15 TypedefType, |
| 16 DualKind, | 16 DualKind, |
| 17 MessageKind, | 17 MessageKind, |
| 18 DiagnosticListener, | 18 DiagnosticListener, |
| 19 Script, | 19 Script, |
| 20 FunctionType, | 20 FunctionType, |
| 21 Selector, | 21 Selector, |
| 22 Constant, | 22 Constant, |
| 23 Compiler, | 23 Compiler, |
| 24 Backend, | 24 Backend, |
| 25 isPrivateName; | 25 isPrivateName; |
| 26 | 26 |
| 27 import '../dart_types.dart'; | 27 import '../dart_types.dart'; |
| 28 import '../helpers/helpers.dart'; |
| 28 | 29 |
| 29 import '../scanner/scannerlib.dart' show Token, | 30 import '../scanner/scannerlib.dart' show Token, |
| 30 isUserDefinableOperator, | 31 isUserDefinableOperator, |
| 31 isMinusOperator; | 32 isMinusOperator; |
| 32 | 33 |
| 33 import '../ordered_typeset.dart' show OrderedTypeSet; | 34 import '../ordered_typeset.dart' show OrderedTypeSet; |
| 34 | 35 |
| 35 import 'visitor.dart' show ElementVisitor; | 36 import 'visitor.dart' show ElementVisitor; |
| 36 | 37 |
| 37 part 'names.dart'; | 38 part 'names.dart'; |
| (...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 453 | 454 |
| 454 static bool isInstanceField(Element element) { | 455 static bool isInstanceField(Element element) { |
| 455 return !Elements.isUnresolved(element) | 456 return !Elements.isUnresolved(element) |
| 456 && element.isInstanceMember | 457 && element.isInstanceMember |
| 457 && (identical(element.kind, ElementKind.FIELD) | 458 && (identical(element.kind, ElementKind.FIELD) |
| 458 || identical(element.kind, ElementKind.GETTER) | 459 || identical(element.kind, ElementKind.GETTER) |
| 459 || identical(element.kind, ElementKind.SETTER)); | 460 || identical(element.kind, ElementKind.SETTER)); |
| 460 } | 461 } |
| 461 | 462 |
| 462 static bool isStaticOrTopLevel(Element element) { | 463 static bool isStaticOrTopLevel(Element element) { |
| 463 // TODO(ager): This should not be necessary when patch support has | 464 // TODO(johnniwinther): Clean this up. This currently returns true for a |
| 464 // been reworked. | 465 // PartialConstructorElement, SynthesizedConstructorElementX, and |
| 465 if (!Elements.isUnresolved(element) | 466 // TypeVariableElementX though neither `element.isStatic` nor |
| 466 && element.isStatic) { | 467 // `element.isTopLevel` is true. |
| 467 return true; | 468 if (Elements.isUnresolved(element)) return false; |
| 468 } | 469 if (element.isStatic || element.isTopLevel) return true; |
| 469 return !Elements.isUnresolved(element) | 470 return !element.isAmbiguous |
| 470 && !element.isAmbiguous | |
| 471 && !element.isInstanceMember | 471 && !element.isInstanceMember |
| 472 && !element.isPrefix | 472 && !element.isPrefix |
| 473 && element.enclosingElement != null | 473 && element.enclosingElement != null |
| 474 && (element.enclosingElement.kind == ElementKind.CLASS || | 474 && (element.enclosingElement.kind == ElementKind.CLASS || |
| 475 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT || | 475 element.enclosingElement.kind == ElementKind.COMPILATION_UNIT || |
| 476 element.enclosingElement.kind == ElementKind.LIBRARY || | 476 element.enclosingElement.kind == ElementKind.LIBRARY || |
| 477 element.enclosingElement.kind == ElementKind.PREFIX); | 477 element.enclosingElement.kind == ElementKind.PREFIX); |
| 478 } | 478 } |
| 479 | 479 |
| 480 static bool isInStaticContext(Element element) { | 480 static bool isInStaticContext(Element element) { |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 848 | 848 |
| 849 abstract class LibraryElement extends Element | 849 abstract class LibraryElement extends Element |
| 850 implements ScopeContainerElement, AnalyzableElement { | 850 implements ScopeContainerElement, AnalyzableElement { |
| 851 /** | 851 /** |
| 852 * The canonical uri for this library. | 852 * The canonical uri for this library. |
| 853 * | 853 * |
| 854 * For user libraries the canonical uri is the script uri. For platform | 854 * For user libraries the canonical uri is the script uri. For platform |
| 855 * libraries the canonical uri is of the form [:dart:x:]. | 855 * libraries the canonical uri is of the form [:dart:x:]. |
| 856 */ | 856 */ |
| 857 Uri get canonicalUri; | 857 Uri get canonicalUri; |
| 858 |
| 859 /// Returns `true` if this library is 'dart:core'. |
| 860 bool get isDartCore; |
| 861 |
| 858 CompilationUnitElement get entryCompilationUnit; | 862 CompilationUnitElement get entryCompilationUnit; |
| 859 Link<CompilationUnitElement> get compilationUnits; | 863 Link<CompilationUnitElement> get compilationUnits; |
| 860 Iterable<LibraryTag> get tags; | 864 Iterable<LibraryTag> get tags; |
| 861 LibraryName get libraryTag; | 865 LibraryName get libraryTag; |
| 862 Link<Element> get exports; | 866 Link<Element> get exports; |
| 863 | 867 |
| 864 /** | 868 /** |
| 865 * [:true:] if this library is part of the platform, that is, its canonical | 869 * [:true:] if this library is part of the platform, that is, its canonical |
| 866 * uri has the scheme 'dart'. | 870 * uri has the scheme 'dart'. |
| 867 */ | 871 */ |
| (...skipping 684 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1552 bool get isDeclaredByField; | 1556 bool get isDeclaredByField; |
| 1553 | 1557 |
| 1554 /// Returns `true` if this member is abstract. | 1558 /// Returns `true` if this member is abstract. |
| 1555 bool get isAbstract; | 1559 bool get isAbstract; |
| 1556 | 1560 |
| 1557 /// If abstract, [implementation] points to the overridden concrete member, | 1561 /// If abstract, [implementation] points to the overridden concrete member, |
| 1558 /// if any. Otherwise [implementation] points to the member itself. | 1562 /// if any. Otherwise [implementation] points to the member itself. |
| 1559 Member get implementation; | 1563 Member get implementation; |
| 1560 } | 1564 } |
| 1561 | 1565 |
| OLD | NEW |