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

Side by Side Diff: sdk/lib/internal/symbol.dart

Issue 2754013002: Format all dart: library files (Closed)
Patch Set: Format all dart: library files Created 3 years, 9 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 unified diff | Download patch
« no previous file with comments | « sdk/lib/internal/sort.dart ('k') | sdk/lib/io/bytes_builder.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 part of dart._internal; 5 part of dart._internal;
6 6
7 /** 7 /**
8 * Implementation of [core.Symbol]. This class uses the same name as 8 * Implementation of [core.Symbol]. This class uses the same name as
9 * a core class so a user can't tell the difference. 9 * a core class so a user can't tell the difference.
10 * 10 *
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
88 // which matches any identifier. 88 // which matches any identifier.
89 89
90 /** 90 /**
91 * RegExp that validates a non-empty symbol. 91 * RegExp that validates a non-empty symbol.
92 * 92 *
93 * Private symbols are accepted. 93 * Private symbols are accepted.
94 * 94 *
95 * The empty symbol is handled before this regexp is used, and is not 95 * The empty symbol is handled before this regexp is used, and is not
96 * accepted. 96 * accepted.
97 */ 97 */
98 static final RegExp symbolPattern = new RegExp( 98 static final RegExp symbolPattern =
99 '^(?:$operatorRE\$|$identifierRE(?:=?\$|[.](?!\$)))+?\$'); 99 new RegExp('^(?:$operatorRE\$|$identifierRE(?:=?\$|[.](?!\$)))+?\$');
100 100
101 external const Symbol(String name); 101 external const Symbol(String name);
102 102
103 /** 103 /**
104 * Platform-private method used by the mirror system to create 104 * Platform-private method used by the mirror system to create
105 * otherwise invalid names. 105 * otherwise invalid names.
106 */ 106 */
107 const Symbol.unvalidated(this._name); 107 const Symbol.unvalidated(this._name);
108 108
109 // This is called by dart2js. 109 // This is called by dart2js.
110 Symbol.validated(String name) 110 Symbol.validated(String name) : this._name = validatePublicSymbol(name);
111 : this._name = validatePublicSymbol(name);
112 111
113 bool operator ==(other) => other is Symbol && _name == other._name; 112 bool operator ==(other) => other is Symbol && _name == other._name;
114 113
115 external int get hashCode; 114 external int get hashCode;
116 115
117 external toString(); 116 external toString();
118 117
119 /// Platform-private accessor which cannot be called from user libraries. 118 /// Platform-private accessor which cannot be called from user libraries.
120 static String getName(Symbol symbol) => symbol._name; 119 static String getName(Symbol symbol) => symbol._name;
121 120
122 static String validatePublicSymbol(String name) { 121 static String validatePublicSymbol(String name) {
123 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name; 122 if (name.isEmpty || publicSymbolPattern.hasMatch(name)) return name;
124 if (name.startsWith('_')) { 123 if (name.startsWith('_')) {
125 // There may be other private parts in a qualified name than the first 124 // There may be other private parts in a qualified name than the first
126 // one, but this is a common case that deserves a specific error 125 // one, but this is a common case that deserves a specific error
127 // message. 126 // message.
128 throw new ArgumentError('"$name" is a private identifier'); 127 throw new ArgumentError('"$name" is a private identifier');
129 } 128 }
130 throw new ArgumentError( 129 throw new ArgumentError('"$name" is not a valid (qualified) symbol name');
131 '"$name" is not a valid (qualified) symbol name');
132 } 130 }
133 131
134 /** 132 /**
135 * Checks whether name is a valid symbol name. 133 * Checks whether name is a valid symbol name.
136 * 134 *
137 * This test allows both private and non-private symbols. 135 * This test allows both private and non-private symbols.
138 */ 136 */
139 static bool isValidSymbol(String name) { 137 static bool isValidSymbol(String name) {
140 return (name.isEmpty || symbolPattern.hasMatch(name)); 138 return (name.isEmpty || symbolPattern.hasMatch(name));
141 } 139 }
142 } 140 }
OLDNEW
« no previous file with comments | « sdk/lib/internal/sort.dart ('k') | sdk/lib/io/bytes_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698