Chromium Code Reviews| 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 class StringMatch implements Match { | 5 class StringMatch implements Match { |
| 6 const StringMatch(int this._start, | 6 const StringMatch(int this._start, |
| 7 String this.str, | 7 String this.str, |
| 8 String this.pattern); | 8 String this.pattern); |
| 9 | 9 |
| 10 int start() => _start; | 10 int start() => _start; |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 result.add(group(g)); | 25 result.add(group(g)); |
| 26 } | 26 } |
| 27 return result; | 27 return result; |
| 28 } | 28 } |
| 29 | 29 |
| 30 final int _start; | 30 final int _start; |
| 31 final String str; | 31 final String str; |
| 32 final String pattern; | 32 final String pattern; |
| 33 } | 33 } |
| 34 | 34 |
| 35 allMatchesInStringUnchecked(receiver, str) { | 35 allMatchesInStringUnchecked(receiver, str) { |
|
Lasse Reichstein Nielsen
2012/03/25 18:22:41
Could you add a comment to this method. The argume
| |
| 36 var result = new List(); | 36 var result = new List(); |
|
ngeoffray
2012/03/25 18:22:17
This should be new List<Match>()
| |
| 37 var length = receiver.length; | 37 var length = receiver.length; |
| 38 if (length === 0) { | 38 if (length === 0) { |
| 39 return result; | 39 return [receiver]; |
|
ngeoffray
2012/03/25 18:22:17
receiver being a string and the returned type of t
Lasse Reichstein Nielsen
2012/03/25 18:22:41
Is [receiver] a Match object? Because it seems we
| |
| 40 } | 40 } |
| 41 | 41 |
| 42 var strLength = str.length; | 42 var strLength = str.length; |
| 43 for (var i = 0; i < strLength;) { | 43 for (var i = 0; i < strLength;) { |
| 44 var index = str.indexOf(receiver, i); | 44 var index = str.indexOf(receiver, i); |
| 45 if (index < 0) { | 45 if (index < 0) { |
| 46 return result; | 46 return result; |
| 47 } | 47 } |
| 48 result.add(new StringMatch(index, str, receiver)); | 48 result.add(new StringMatch(index, str, receiver)); |
| 49 i = index + length; | 49 i = index + length; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 stringSplitUnchecked(receiver, pattern) { | 112 stringSplitUnchecked(receiver, pattern) { |
| 113 if (pattern is String) { | 113 if (pattern is String) { |
| 114 return JS('List', @'#.split(#)', receiver, pattern); | 114 return JS('List', @'#.split(#)', receiver, pattern); |
| 115 } else if (pattern is JSSyntaxRegExp) { | 115 } else if (pattern is JSSyntaxRegExp) { |
| 116 var re = regExpGetNative(pattern); | 116 var re = regExpGetNative(pattern); |
| 117 return JS('List', @'#.split(#)', receiver, re); | 117 return JS('List', @'#.split(#)', receiver, re); |
| 118 } else { | 118 } else { |
| 119 throw "StringImplementation.split(Pattern) UNIMPLEMENTED"; | 119 throw "StringImplementation.split(Pattern) UNIMPLEMENTED"; |
| 120 } | 120 } |
| 121 } | 121 } |
| OLD | NEW |