| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 /// Mixins that implement convenience methods on [Element] subclasses. | 5 /// Mixins that implement convenience methods on [Element] subclasses. |
| 6 | 6 |
| 7 library elements.common; | 7 library elements.common; |
| 8 | 8 |
| 9 import '../common/names.dart' show Identifiers, Names, Uris; | 9 import '../common/names.dart' show Identifiers, Names, Uris; |
| 10 import '../core_types.dart' show CoreClasses; | 10 import '../core_types.dart' show CoreClasses; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 175 | 175 |
| 176 String get libraryOrScriptName { | 176 String get libraryOrScriptName { |
| 177 if (hasLibraryName) { | 177 if (hasLibraryName) { |
| 178 return libraryName; | 178 return libraryName; |
| 179 } else { | 179 } else { |
| 180 // Use the file name as script name. | 180 // Use the file name as script name. |
| 181 String path = canonicalUri.path; | 181 String path = canonicalUri.path; |
| 182 return path.substring(path.lastIndexOf('/') + 1); | 182 return path.substring(path.lastIndexOf('/') + 1); |
| 183 } | 183 } |
| 184 } | 184 } |
| 185 | |
| 186 int compareTo(LibraryElement other) { | |
| 187 if (this == other) return 0; | |
| 188 return libraryOrScriptName.compareTo(other.libraryOrScriptName); | |
| 189 } | |
| 190 } | 185 } |
| 191 | 186 |
| 192 abstract class CompilationUnitElementCommon implements CompilationUnitElement { | 187 abstract class CompilationUnitElementCommon implements CompilationUnitElement { |
| 193 int compareTo(CompilationUnitElement other) { | |
| 194 if (this == other) return 0; | |
| 195 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); | |
| 196 } | |
| 197 } | 188 } |
| 198 | 189 |
| 199 abstract class ClassElementCommon implements ClassElement { | 190 abstract class ClassElementCommon implements ClassElement { |
| 200 @override | 191 @override |
| 201 Link<DartType> get allSupertypes => allSupertypesAndSelf.supertypes; | 192 Link<DartType> get allSupertypes => allSupertypesAndSelf.supertypes; |
| 202 | 193 |
| 203 @override | 194 @override |
| 204 int get hierarchyDepth => allSupertypesAndSelf.maxDepth; | 195 int get hierarchyDepth => allSupertypesAndSelf.maxDepth; |
| 205 | 196 |
| 206 @override | 197 @override |
| (...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 645 @override | 636 @override |
| 646 bool get isBoolFromEnvironmentConstructor { | 637 bool get isBoolFromEnvironmentConstructor { |
| 647 return fromEnvironmentState == _FromEnvironmentState.BOOL; | 638 return fromEnvironmentState == _FromEnvironmentState.BOOL; |
| 648 } | 639 } |
| 649 | 640 |
| 650 @override | 641 @override |
| 651 bool get isStringFromEnvironmentConstructor { | 642 bool get isStringFromEnvironmentConstructor { |
| 652 return fromEnvironmentState == _FromEnvironmentState.STRING; | 643 return fromEnvironmentState == _FromEnvironmentState.STRING; |
| 653 } | 644 } |
| 654 } | 645 } |
| OLD | NEW |