| 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 import '../compiler.dart' show | 7 import '../compiler.dart' show |
| 8 Compiler; | 8 Compiler; |
| 9 import '../constants/constructors.dart'; | 9 import '../constants/constructors.dart'; |
| 10 import '../constants/expressions.dart'; | 10 import '../constants/expressions.dart'; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 static const ElementKind GETTER = | 99 static const ElementKind GETTER = |
| 100 const ElementKind('getter', ElementCategory.NONE); | 100 const ElementKind('getter', ElementCategory.NONE); |
| 101 static const ElementKind SETTER = | 101 static const ElementKind SETTER = |
| 102 const ElementKind('setter', ElementCategory.NONE); | 102 const ElementKind('setter', ElementCategory.NONE); |
| 103 static const ElementKind TYPE_VARIABLE = | 103 static const ElementKind TYPE_VARIABLE = |
| 104 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); | 104 const ElementKind('type_variable', ElementCategory.TYPE_VARIABLE); |
| 105 static const ElementKind ABSTRACT_FIELD = | 105 static const ElementKind ABSTRACT_FIELD = |
| 106 const ElementKind('abstract_field', ElementCategory.VARIABLE); | 106 const ElementKind('abstract_field', ElementCategory.VARIABLE); |
| 107 static const ElementKind LIBRARY = | 107 static const ElementKind LIBRARY = |
| 108 const ElementKind('library', ElementCategory.NONE); | 108 const ElementKind('library', ElementCategory.NONE); |
| 109 static const ElementKind IMPORT = |
| 110 const ElementKind('import', ElementCategory.NONE); |
| 111 static const ElementKind EXPORT = |
| 112 const ElementKind('export', ElementCategory.NONE); |
| 109 static const ElementKind PREFIX = | 113 static const ElementKind PREFIX = |
| 110 const ElementKind('prefix', ElementCategory.PREFIX); | 114 const ElementKind('prefix', ElementCategory.PREFIX); |
| 111 static const ElementKind TYPEDEF = | 115 static const ElementKind TYPEDEF = |
| 112 const ElementKind('typedef', ElementCategory.ALIAS); | 116 const ElementKind('typedef', ElementCategory.ALIAS); |
| 113 | 117 |
| 114 static const ElementKind AMBIGUOUS = | 118 static const ElementKind AMBIGUOUS = |
| 115 const ElementKind('ambiguous', ElementCategory.NONE); | 119 const ElementKind('ambiguous', ElementCategory.NONE); |
| 116 static const ElementKind WARN_ON_USE = | 120 static const ElementKind WARN_ON_USE = |
| 117 const ElementKind('warn_on_use', ElementCategory.NONE); | 121 const ElementKind('warn_on_use', ElementCategory.NONE); |
| 118 static const ElementKind ERROR = | 122 static const ElementKind ERROR = |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 180 */ | 184 */ |
| 181 abstract class Element implements Entity { | 185 abstract class Element implements Entity { |
| 182 String get name; | 186 String get name; |
| 183 ElementKind get kind; | 187 ElementKind get kind; |
| 184 Element get enclosingElement; | 188 Element get enclosingElement; |
| 185 Iterable<MetadataAnnotation> get metadata; | 189 Iterable<MetadataAnnotation> get metadata; |
| 186 | 190 |
| 187 /// `true` if this element is a library. | 191 /// `true` if this element is a library. |
| 188 bool get isLibrary; | 192 bool get isLibrary; |
| 189 | 193 |
| 194 /// `true` if this element is an import declaration. |
| 195 bool get isImport => kind == ElementKind.IMPORT; |
| 196 |
| 197 /// `true` if this element is an export declaration. |
| 198 bool get isExport => kind == ElementKind.EXPORT; |
| 199 |
| 190 /// `true` if this element is a compilation unit. | 200 /// `true` if this element is a compilation unit. |
| 191 bool get isCompilationUnit; | 201 bool get isCompilationUnit; |
| 192 | 202 |
| 193 /// `true` if this element is defines the scope of prefix used by one or | 203 /// `true` if this element is defines the scope of prefix used by one or |
| 194 /// more import declarations. | 204 /// more import declarations. |
| 195 bool get isPrefix; | 205 bool get isPrefix; |
| 196 | 206 |
| 197 /// `true` if this element is a class declaration or a mixin application. | 207 /// `true` if this element is a class declaration or a mixin application. |
| 198 bool get isClass; | 208 bool get isClass; |
| 199 | 209 |
| (...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 825 @deprecated | 835 @deprecated |
| 826 get enclosingElement; | 836 get enclosingElement; |
| 827 | 837 |
| 828 Script get script; | 838 Script get script; |
| 829 | 839 |
| 830 void forEachLocalMember(f(Element element)); | 840 void forEachLocalMember(f(Element element)); |
| 831 | 841 |
| 832 int compareTo(CompilationUnitElement other); | 842 int compareTo(CompilationUnitElement other); |
| 833 } | 843 } |
| 834 | 844 |
| 845 abstract class ImportElement extends Element { |
| 846 Uri get uri; |
| 847 LibraryElement get importedLibrary; |
| 848 bool get isDeferred; |
| 849 PrefixElement get prefix; |
| 850 // TODO(johnniwinther): Remove this when no longer needed in source mirrors. |
| 851 Import get node; |
| 852 } |
| 853 |
| 854 abstract class ExportElement extends Element { |
| 855 Uri get uri; |
| 856 LibraryElement get exportedLibrary; |
| 857 // TODO(johnniwinther): Remove this when no longer needed in source mirrors. |
| 858 Export get node; |
| 859 } |
| 860 |
| 835 abstract class LibraryElement extends Element | 861 abstract class LibraryElement extends Element |
| 836 implements ScopeContainerElement, AnalyzableElement { | 862 implements ScopeContainerElement, AnalyzableElement { |
| 837 /** | 863 /** |
| 838 * The canonical uri for this library. | 864 * The canonical uri for this library. |
| 839 * | 865 * |
| 840 * For user libraries the canonical uri is the script uri. For platform | 866 * For user libraries the canonical uri is the script uri. For platform |
| 841 * libraries the canonical uri is of the form [:dart:x:]. | 867 * libraries the canonical uri is of the form [:dart:x:]. |
| 842 */ | 868 */ |
| 843 Uri get canonicalUri; | 869 Uri get canonicalUri; |
| 844 | 870 |
| 845 /// Returns `true` if this library is 'dart:core'. | 871 /// Returns `true` if this library is 'dart:core'. |
| 846 bool get isDartCore; | 872 bool get isDartCore; |
| 847 | 873 |
| 848 CompilationUnitElement get entryCompilationUnit; | 874 CompilationUnitElement get entryCompilationUnit; |
| 849 Link<CompilationUnitElement> get compilationUnits; | 875 Link<CompilationUnitElement> get compilationUnits; |
| 850 Iterable<LibraryTag> get tags; | 876 |
| 851 LibraryName get libraryTag; | 877 /// The import declarations in this library, including the implicit import of |
| 852 Link<Element> get exports; | 878 /// 'dart:core', if present. |
| 879 Iterable<ImportElement> get imports; |
| 880 |
| 881 /// The export declarations in this library. |
| 882 Iterable<ExportElement> get exports; |
| 853 | 883 |
| 854 /** | 884 /** |
| 855 * [:true:] if this library is part of the platform, that is, its canonical | 885 * [:true:] if this library is part of the platform, that is, its canonical |
| 856 * uri has the scheme 'dart'. | 886 * uri has the scheme 'dart'. |
| 857 */ | 887 */ |
| 858 bool get isPlatformLibrary; | 888 bool get isPlatformLibrary; |
| 859 | 889 |
| 860 /** | 890 /** |
| 861 * [:true:] if this library is from a package, that is, its canonical uri has | 891 * [:true:] if this library is from a package, that is, its canonical uri has |
| 862 * the scheme 'package'. | 892 * the scheme 'package'. |
| 863 */ | 893 */ |
| 864 bool get isPackageLibrary; | 894 bool get isPackageLibrary; |
| 865 | 895 |
| 866 /** | 896 /** |
| 867 * [:true:] if this library is a platform library whose path starts with | 897 * [:true:] if this library is a platform library whose path starts with |
| 868 * an underscore. | 898 * an underscore. |
| 869 */ | 899 */ |
| 870 bool get isInternalLibrary; | 900 bool get isInternalLibrary; |
| 871 | 901 |
| 872 bool get canUseNative; | 902 bool get canUseNative; |
| 873 bool get exportsHandled; | 903 bool get exportsHandled; |
| 874 | 904 |
| 875 LibraryElement get implementation; | 905 LibraryElement get implementation; |
| 876 | 906 |
| 877 /// Return the library element corresponding to an import or export. | |
| 878 LibraryElement getLibraryFromTag(LibraryDependency tag); | |
| 879 | |
| 880 Element find(String elementName); | 907 Element find(String elementName); |
| 881 Element findLocal(String elementName); | 908 Element findLocal(String elementName); |
| 882 Element findExported(String elementName); | 909 Element findExported(String elementName); |
| 883 void forEachExport(f(Element element)); | 910 void forEachExport(f(Element element)); |
| 884 | 911 |
| 885 /// Calls [f] for each [Element] imported into this library. | 912 /// Calls [f] for each [Element] imported into this library. |
| 886 void forEachImport(f(Element element)); | 913 void forEachImport(f(Element element)); |
| 887 | 914 |
| 888 /// Returns the imports that import element into this library. | 915 /// Returns the imports that import element into this library. |
| 889 Link<Import> getImportsFor(Element element); | 916 Iterable<ImportElement> getImportsFor(Element element); |
| 890 | 917 |
| 891 bool hasLibraryName(); | 918 /// `true` if this library has name as given through a library tag. |
| 892 String getLibraryName(); | 919 bool get hasLibraryName; |
| 893 | 920 |
| 894 /** | 921 /// The library name, which is either the name given in the library tag |
| 895 * Returns the library name (as defined by the library tag) or for script | 922 /// or the empty string if there is no library tag. |
| 896 * (which have no library tag) the script file name. The latter case is used | 923 String get libraryName; |
| 897 * to provide a 'library name' for scripts to use for instance in dartdoc. | 924 |
| 898 * | 925 /// Returns the library name (as defined by the library tag) or for script |
| 899 * Note: the returned filename is still escaped ("a%20b.dart" instead of | 926 /// (which have no library tag) the script file name. The latter case is used |
| 900 * "a b.dart"). | 927 /// to provide a 'library name' for scripts to use for instance in dartdoc. |
| 901 */ | 928 /// |
| 902 String getLibraryOrScriptName(); | 929 /// Note: the returned filename is still escaped ("a%20b.dart" instead of |
| 930 /// "a b.dart"). |
| 931 String get libraryOrScriptName; |
| 903 | 932 |
| 904 int compareTo(LibraryElement other); | 933 int compareTo(LibraryElement other); |
| 905 } | 934 } |
| 906 | 935 |
| 907 /// The implicit scope defined by a import declaration with a prefix clause. | 936 /// The implicit scope defined by a import declaration with a prefix clause. |
| 908 abstract class PrefixElement extends Element { | 937 abstract class PrefixElement extends Element { |
| 909 void addImport(Element element, Import import, DiagnosticListener listener); | |
| 910 Element lookupLocalMember(String memberName); | 938 Element lookupLocalMember(String memberName); |
| 939 |
| 911 /// Is true if this prefix belongs to a deferred import. | 940 /// Is true if this prefix belongs to a deferred import. |
| 912 bool get isDeferred; | 941 bool get isDeferred; |
| 913 void markAsDeferred(Import import); | 942 |
| 914 Import get deferredImport; | 943 /// Import that declared this deferred prefix. |
| 944 ImportElement get deferredImport; |
| 915 } | 945 } |
| 916 | 946 |
| 917 /// A type alias definition. | 947 /// A type alias definition. |
| 918 abstract class TypedefElement extends Element | 948 abstract class TypedefElement extends Element |
| 919 implements AstElement, TypeDeclarationElement, FunctionTypedElement { | 949 implements AstElement, TypeDeclarationElement, FunctionTypedElement { |
| 920 | 950 |
| 921 /// The type defined by this typedef with the type variables as its type | 951 /// The type defined by this typedef with the type variables as its type |
| 922 /// arguments. | 952 /// arguments. |
| 923 /// | 953 /// |
| 924 /// For instance `F<T>` for `typedef void F<T>(T t)`. | 954 /// For instance `F<T>` for `typedef void F<T>(T t)`. |
| (...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 bool get isDeclaredByField; | 1683 bool get isDeclaredByField; |
| 1654 | 1684 |
| 1655 /// Returns `true` if this member is abstract. | 1685 /// Returns `true` if this member is abstract. |
| 1656 bool get isAbstract; | 1686 bool get isAbstract; |
| 1657 | 1687 |
| 1658 /// If abstract, [implementation] points to the overridden concrete member, | 1688 /// If abstract, [implementation] points to the overridden concrete member, |
| 1659 /// if any. Otherwise [implementation] points to the member itself. | 1689 /// if any. Otherwise [implementation] points to the member itself. |
| 1660 Member get implementation; | 1690 Member get implementation; |
| 1661 } | 1691 } |
| 1662 | 1692 |
| OLD | NEW |