| 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 | 9 import '../common/names.dart' show |
| 10 Names, | 10 Names, |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 @override | 126 @override |
| 127 bool get isPlatformLibrary => canonicalUri.scheme == 'dart'; | 127 bool get isPlatformLibrary => canonicalUri.scheme == 'dart'; |
| 128 | 128 |
| 129 @override | 129 @override |
| 130 bool get isPackageLibrary => canonicalUri.scheme == 'package'; | 130 bool get isPackageLibrary => canonicalUri.scheme == 'package'; |
| 131 | 131 |
| 132 @override | 132 @override |
| 133 bool get isInternalLibrary => | 133 bool get isInternalLibrary => |
| 134 isPlatformLibrary && canonicalUri.path.startsWith('_'); | 134 isPlatformLibrary && canonicalUri.path.startsWith('_'); |
| 135 | 135 |
| 136 String getLibraryOrScriptName() { | 136 String get libraryOrScriptName { |
| 137 if (hasLibraryName()) { | 137 if (hasLibraryName) { |
| 138 return getLibraryName(); | 138 return libraryName; |
| 139 } else { | 139 } else { |
| 140 // Use the file name as script name. | 140 // Use the file name as script name. |
| 141 String path = canonicalUri.path; | 141 String path = canonicalUri.path; |
| 142 return path.substring(path.lastIndexOf('/') + 1); | 142 return path.substring(path.lastIndexOf('/') + 1); |
| 143 } | 143 } |
| 144 } | 144 } |
| 145 | 145 |
| 146 int compareTo(LibraryElement other) { | 146 int compareTo(LibraryElement other) { |
| 147 if (this == other) return 0; | 147 if (this == other) return 0; |
| 148 return getLibraryOrScriptName().compareTo(other.getLibraryOrScriptName()); | 148 return libraryOrScriptName.compareTo(other.libraryOrScriptName); |
| 149 } | 149 } |
| 150 } | 150 } |
| 151 | 151 |
| 152 abstract class CompilationUnitElementCommon implements CompilationUnitElement { | 152 abstract class CompilationUnitElementCommon implements CompilationUnitElement { |
| 153 int compareTo(CompilationUnitElement other) { | 153 int compareTo(CompilationUnitElement other) { |
| 154 if (this == other) return 0; | 154 if (this == other) return 0; |
| 155 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); | 155 return '${script.readableUri}'.compareTo('${other.script.readableUri}'); |
| 156 } | 156 } |
| 157 } | 157 } |
| 158 | 158 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 // this signature must not have more required parameters. Having more | 490 // this signature must not have more required parameters. Having more |
| 491 // optional parameters is not a problem, they simply are never provided | 491 // optional parameters is not a problem, they simply are never provided |
| 492 // by call sites of a call to a method with the other signature. | 492 // by call sites of a call to a method with the other signature. |
| 493 int otherTotalCount = signature.parameterCount; | 493 int otherTotalCount = signature.parameterCount; |
| 494 return requiredParameterCount <= otherTotalCount | 494 return requiredParameterCount <= otherTotalCount |
| 495 && parameterCount >= otherTotalCount; | 495 && parameterCount >= otherTotalCount; |
| 496 } | 496 } |
| 497 return true; | 497 return true; |
| 498 } | 498 } |
| 499 } | 499 } |
| OLD | NEW |