Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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.modelx; | 5 library elements.modelx; |
| 6 | 6 |
| 7 import 'dart:collection' show LinkedHashMap; | 7 import 'dart:collection' show LinkedHashMap; |
| 8 | 8 |
| 9 import 'elements.dart'; | 9 import 'elements.dart'; |
| 10 import '../../compiler.dart' as api; | 10 import '../../compiler.dart' as api; |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 887 return localScope.values.where((Element element) { | 887 return localScope.values.where((Element element) { |
| 888 // At this point [localScope] only contains members so we don't need | 888 // At this point [localScope] only contains members so we don't need |
| 889 // to check for foreign or prefix elements. | 889 // to check for foreign or prefix elements. |
| 890 return !element.name.isPrivate(); | 890 return !element.name.isPrivate(); |
| 891 }); | 891 }); |
| 892 } | 892 } |
| 893 | 893 |
| 894 bool hasLibraryName() => libraryTag != null; | 894 bool hasLibraryName() => libraryTag != null; |
| 895 | 895 |
| 896 /** | 896 /** |
| 897 * Returns the library name (as defined by the library tag) or for script | 897 * Returns the library name, which is either the name given in the library tag |
| 898 * (which have no library tag) the script file name. The latter case is used | 898 * or the empty string if there is no library tag. |
| 899 * to private 'library name' for scripts to use for instance in dartdoc. | |
| 900 */ | 899 */ |
| 901 String getLibraryOrScriptName() { | 900 String getLibraryName() { |
| 902 if (libraryTag != null) { | 901 if (libraryTag == null) return ''; |
| 903 return libraryTag.name.toString(); | 902 return libraryTag.name.toString(); |
|
ahe
2013/10/10 11:47:53
Perhaps we need to cache this value.
| |
| 904 } else { | |
| 905 // Use the file name as script name. | |
| 906 String path = canonicalUri.path; | |
| 907 return path.substring(path.lastIndexOf('/') + 1); | |
| 908 } | |
| 909 } | 903 } |
| 910 | 904 |
| 911 Scope buildScope() => new LibraryScope(this); | 905 Scope buildScope() => new LibraryScope(this); |
| 912 | 906 |
| 913 bool get isPlatformLibrary => canonicalUri.scheme == "dart"; | 907 bool get isPlatformLibrary => canonicalUri.scheme == "dart"; |
| 914 | 908 |
| 915 bool get isInternalLibrary => | 909 bool get isInternalLibrary => |
| 916 isPlatformLibrary && canonicalUri.path.startsWith('_'); | 910 isPlatformLibrary && canonicalUri.path.startsWith('_'); |
| 917 | 911 |
| 918 String toString() { | 912 String toString() { |
| 919 if (origin != null) { | 913 if (origin != null) { |
| 920 return 'patch library(${getLibraryOrScriptName()})'; | 914 return 'patch library(${getLibraryName()})'; |
| 921 } else if (patch != null) { | 915 } else if (patch != null) { |
| 922 return 'origin library(${getLibraryOrScriptName()})'; | 916 return 'origin library(${getLibraryName()})'; |
| 923 } else { | 917 } else { |
| 924 return 'library(${getLibraryOrScriptName()})'; | 918 return 'library(${getLibraryName()})'; |
| 925 } | 919 } |
| 926 } | 920 } |
| 927 | 921 |
| 928 int compareTo(LibraryElement other) { | 922 int compareTo(LibraryElement other) { |
| 929 if (this == other) return 0; | 923 if (this == other) return 0; |
| 930 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName()); | 924 return getLibraryName().compareTo(other.getLibraryName()); |
|
ahe
2013/10/10 11:47:53
All the above should probably continue to use getL
| |
| 931 } | 925 } |
| 932 } | 926 } |
| 933 | 927 |
| 934 class PrefixElementX extends ElementX implements PrefixElement { | 928 class PrefixElementX extends ElementX implements PrefixElement { |
| 935 Map<SourceString, Element> imported; | 929 Map<SourceString, Element> imported; |
| 936 Token firstPosition; | 930 Token firstPosition; |
| 937 | 931 |
| 938 PrefixElementX(SourceString prefix, Element enclosing, this.firstPosition) | 932 PrefixElementX(SourceString prefix, Element enclosing, this.firstPosition) |
| 939 : imported = new Map<SourceString, Element>(), | 933 : imported = new Map<SourceString, Element>(), |
| 940 super(prefix, ElementKind.PREFIX, enclosing); | 934 super(prefix, ElementKind.PREFIX, enclosing); |
| (...skipping 1365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2306 | 2300 |
| 2307 MetadataAnnotation ensureResolved(Compiler compiler) { | 2301 MetadataAnnotation ensureResolved(Compiler compiler) { |
| 2308 if (resolutionState == STATE_NOT_STARTED) { | 2302 if (resolutionState == STATE_NOT_STARTED) { |
| 2309 compiler.resolver.resolveMetadataAnnotation(this); | 2303 compiler.resolver.resolveMetadataAnnotation(this); |
| 2310 } | 2304 } |
| 2311 return this; | 2305 return this; |
| 2312 } | 2306 } |
| 2313 | 2307 |
| 2314 String toString() => 'MetadataAnnotation($value, $resolutionState)'; | 2308 String toString() => 'MetadataAnnotation($value, $resolutionState)'; |
| 2315 } | 2309 } |
| OLD | NEW |