| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 part of elements; | 5 part of elements; |
| 6 | 6 |
| 7 /// A [Name] represents the abstraction of a Dart identifier which takes privacy | 7 /// A [Name] represents the abstraction of a Dart identifier which takes privacy |
| 8 /// and setter into account. | 8 /// and setter into account. |
| 9 // TODO(johnniwinther): Try to share logic with [Selector]. | 9 // TODO(johnniwinther): Try to share logic with [Selector]. |
| 10 abstract class Name { | 10 abstract class Name { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 /// Returns `true` if this name is private. | 42 /// Returns `true` if this name is private. |
| 43 bool get isPrivate; | 43 bool get isPrivate; |
| 44 | 44 |
| 45 /// Returns `true` if this name is the same as [other] not taking the library | 45 /// Returns `true` if this name is the same as [other] not taking the library |
| 46 /// privacy into account. | 46 /// privacy into account. |
| 47 bool isSimilarTo(Name other); | 47 bool isSimilarTo(Name other); |
| 48 int get similarHashCode; | 48 int get similarHashCode; |
| 49 | 49 |
| 50 LibraryElement get library; | 50 LibraryElement get library; |
| 51 | 51 |
| 52 | |
| 53 /// Returns `true` when [s] is private if used as an identifier. | 52 /// Returns `true` when [s] is private if used as an identifier. |
| 54 static bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_; | 53 static bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_; |
| 55 | 54 |
| 56 /// Returns `true` when [s] is public if used as an identifier. | 55 /// Returns `true` when [s] is public if used as an identifier. |
| 57 static bool isPublicName(String s) => !isPrivateName(s); | 56 static bool isPublicName(String s) => !isPrivateName(s); |
| 58 } | 57 } |
| 59 | 58 |
| 60 class PublicName implements Name { | 59 class PublicName implements Name { |
| 61 final String text; | 60 final String text; |
| 62 final bool isSetter; | 61 final bool isSetter; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } | 99 } |
| 101 | 100 |
| 102 bool isAccessibleFrom(LibraryElement element) => library == element; | 101 bool isAccessibleFrom(LibraryElement element) => library == element; |
| 103 | 102 |
| 104 bool get isPrivate => true; | 103 bool get isPrivate => true; |
| 105 | 104 |
| 106 int get hashCode => super.hashCode + 13 * library.hashCode; | 105 int get hashCode => super.hashCode + 13 * library.hashCode; |
| 107 | 106 |
| 108 bool operator ==(other) { | 107 bool operator ==(other) { |
| 109 if (other is! PrivateName) return false; | 108 if (other is! PrivateName) return false; |
| 110 return super==(other) && library == other.library; | 109 return super == (other) && library == other.library; |
| 111 } | 110 } |
| 112 | 111 |
| 113 String toString() => '${library.libraryName}#${super.toString()}'; | 112 String toString() => '${library.libraryName}#${super.toString()}'; |
| 114 } | 113 } |
| OLD | NEW |