Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(723)

Unified Diff: pkg/compiler/lib/src/elements/names.dart

Issue 1313893004: Move isPrivateName and isPublicName to Name. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/elements/names.dart
diff --git a/pkg/compiler/lib/src/elements/names.dart b/pkg/compiler/lib/src/elements/names.dart
index 38e094595e6ad5a8b10186aca69310370a6cf591..514729c8f61fe9516aa8eb06c883b59337403e9c 100644
--- a/pkg/compiler/lib/src/elements/names.dart
+++ b/pkg/compiler/lib/src/elements/names.dart
@@ -46,8 +46,15 @@ abstract class Name {
/// privacy into account.
bool isSimilarTo(Name other);
int get similarHashCode;
-
+
LibraryElement get library;
+
+
+ /// Returns `true` when [s] is private if used as an identifier.
+ static bool isPrivateName(String s) => !s.isEmpty && s.codeUnitAt(0) == $_;
+
+ /// Returns `true` when [s] is public if used as an identifier.
+ static bool isPublicName(String s) => !isPrivateName(s);
}
class PublicName implements Name {
@@ -74,7 +81,7 @@ class PublicName implements Name {
bool isSimilarTo(Name other) =>
text == other.text && isSetter == other.isSetter;
int get similarHashCode => text.hashCode + 11 * isSetter.hashCode;
-
+
LibraryElement get library => null;
String toString() => isSetter ? '$text=' : text;
« no previous file with comments | « pkg/compiler/lib/src/elements/modelx.dart ('k') | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698