| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 _interceptors; | 5 part of _interceptors; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * The interceptor class for [String]. The compiler recognizes this | 8 * The interceptor class for [String]. The compiler recognizes this |
| 9 * class as an interceptor, and changes references to [:this:] to | 9 * class as an interceptor, and changes references to [:this:] to |
| 10 * actually use the receiver of the method, which is generated as an extra | 10 * actually use the receiver of the method, which is generated as an extra |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 String splitMapJoin(Pattern from, | 67 String splitMapJoin(Pattern from, |
| 68 {String onMatch(Match match), | 68 {String onMatch(Match match), |
| 69 String onNonMatch(String nonMatch)}) { | 69 String onNonMatch(String nonMatch)}) { |
| 70 return stringReplaceAllFuncUnchecked(this, from, onMatch, onNonMatch); | 70 return stringReplaceAllFuncUnchecked(this, from, onMatch, onNonMatch); |
| 71 } | 71 } |
| 72 | 72 |
| 73 String replaceFirst(Pattern from, String to, [int startIndex = 0]) { | 73 String replaceFirst(Pattern from, String to, [int startIndex = 0]) { |
| 74 checkString(to); | 74 checkString(to); |
| 75 checkInt(startIndex); | 75 checkInt(startIndex); |
| 76 if (startIndex < 0 || startIndex > this.length) { | 76 RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex"); |
| 77 throw new RangeError.range(startIndex, 0, this.length); | |
| 78 } | |
| 79 return stringReplaceFirstUnchecked(this, from, to, startIndex); | 77 return stringReplaceFirstUnchecked(this, from, to, startIndex); |
| 80 } | 78 } |
| 81 | 79 |
| 80 String replaceFirstMapped(Pattern from, String replace(Match match), |
| 81 [int startIndex = 0]) { |
| 82 checkNull(replace); |
| 83 checkInt(startIndex); |
| 84 RangeError.checkValueInInterval(startIndex, 0, this.length, "startIndex"); |
| 85 return stringReplaceFirstMappedUnchecked(this, from, replace, startIndex); |
| 86 } |
| 87 |
| 82 List<String> split(Pattern pattern) { | 88 List<String> split(Pattern pattern) { |
| 83 checkNull(pattern); | 89 checkNull(pattern); |
| 84 if (pattern is String) { | 90 if (pattern is String) { |
| 85 return JS('JSExtendableArray', r'#.split(#)', this, pattern); | 91 return JS('JSExtendableArray', r'#.split(#)', this, pattern); |
| 86 } else if (pattern is JSSyntaxRegExp && regExpCaptureCount(pattern) == 0) { | 92 } else if (pattern is JSSyntaxRegExp && regExpCaptureCount(pattern) == 0) { |
| 87 var re = regExpGetNative(pattern); | 93 var re = regExpGetNative(pattern); |
| 88 return JS('JSExtendableArray', r'#.split(#)', this, re); | 94 return JS('JSExtendableArray', r'#.split(#)', this, re); |
| 89 } else { | 95 } else { |
| 90 return _defaultSplit(pattern); | 96 return _defaultSplit(pattern); |
| 91 } | 97 } |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 Type get runtimeType => String; | 455 Type get runtimeType => String; |
| 450 | 456 |
| 451 int get length => JS('int', r'#.length', this); | 457 int get length => JS('int', r'#.length', this); |
| 452 | 458 |
| 453 String operator [](int index) { | 459 String operator [](int index) { |
| 454 if (index is !int) throw new ArgumentError(index); | 460 if (index is !int) throw new ArgumentError(index); |
| 455 if (index >= length || index < 0) throw new RangeError.value(index); | 461 if (index >= length || index < 0) throw new RangeError.value(index); |
| 456 return JS('String', '#[#]', this, index); | 462 return JS('String', '#[#]', this, index); |
| 457 } | 463 } |
| 458 } | 464 } |
| OLD | NEW |