| OLD | NEW |
| 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 patch class Symbol { | 5 patch class Symbol { |
| 6 /* patch */ const Symbol(String name) | 6 /* patch */ const Symbol(String name) |
| 7 : this._name = _validate(name); | 7 : this._name = _validate(name); |
| 8 | 8 |
| 9 static final RegExp _validationPattern = | 9 static final RegExp _validationPattern = |
| 10 new RegExp(r'^(?:[a-zA-Z$][a-zA-Z$0-9_]*\.)*(?:[a-zA-Z$][a-zA-Z$0-9_]*=?|' | 10 new RegExp(r'^(?:[a-zA-Z$][a-zA-Z$0-9_]*\.)*(?:[a-zA-Z$][a-zA-Z$0-9_]*=?|' |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 r'>=|' | 24 r'>=|' |
| 25 r'>|' | 25 r'>|' |
| 26 r'<=|' | 26 r'<=|' |
| 27 r'<|' | 27 r'<|' |
| 28 r'&|' | 28 r'&|' |
| 29 r'\^|' | 29 r'\^|' |
| 30 r'\|' | 30 r'\|' |
| 31 r')$'); | 31 r')$'); |
| 32 | 32 |
| 33 static _validate(String name) { | 33 static _validate(String name) { |
| 34 if (name is! String) throw new ArgumentError('name must be a String'); | |
| 35 if (name.isEmpty) return name; | 34 if (name.isEmpty) return name; |
| 36 if (name.startsWith('_')) { | 35 if (name.startsWith('_')) { |
| 37 throw new ArgumentError('"$name" is a private identifier'); | 36 throw new ArgumentError('"$name" is a private identifier'); |
| 38 } | 37 } |
| 39 if (!_validationPattern.hasMatch(name)) { | 38 if (!_validationPattern.hasMatch(name)) { |
| 40 throw new ArgumentError( | 39 throw new ArgumentError( |
| 41 '"$name" is not an identifier or an empty String'); | 40 '"$name" is not an identifier or an empty String'); |
| 42 } | 41 } |
| 43 return name; | 42 return name; |
| 44 } | 43 } |
| 45 } | 44 } |
| OLD | NEW |