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

Side by Side Diff: runtime/lib/string_base.dart

Issue 11275042: Renaming IndexOutOfRangeException to RangeError. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 1 month 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 | Annotate | Revision Log
OLDNEW
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 /** 5 /**
6 * [_StringBase] contains common methods used by concrete String 6 * [_StringBase] contains common methods used by concrete String
7 * implementations, e.g., _OneByteString. 7 * implementations, e.g., _OneByteString.
8 */ 8 */
9 class _StringBase { 9 class _StringBase {
10 10
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 return index; 137 return index;
138 } 138 }
139 } 139 }
140 return -1; 140 return -1;
141 } 141 }
142 142
143 String substring(int startIndex, [int endIndex]) { 143 String substring(int startIndex, [int endIndex]) {
144 if (endIndex === null) endIndex = this.length; 144 if (endIndex === null) endIndex = this.length;
145 145
146 if ((startIndex < 0) || (startIndex > this.length)) { 146 if ((startIndex < 0) || (startIndex > this.length)) {
147 throw new IndexOutOfRangeException(startIndex); 147 throw new RangeError(startIndex);
148 } 148 }
149 if ((endIndex < 0) || (endIndex > this.length)) { 149 if ((endIndex < 0) || (endIndex > this.length)) {
150 throw new IndexOutOfRangeException(endIndex); 150 throw new RangeError(endIndex);
151 } 151 }
152 if (startIndex > endIndex) { 152 if (startIndex > endIndex) {
153 throw new IndexOutOfRangeException(startIndex); 153 throw new RangeError(startIndex);
154 } 154 }
155 return _substringUnchecked(startIndex, endIndex); 155 return _substringUnchecked(startIndex, endIndex);
156 } 156 }
157 157
158 String _substringUnchecked(int startIndex, int endIndex) 158 String _substringUnchecked(int startIndex, int endIndex)
159 native "StringBase_substringUnchecked"; 159 native "StringBase_substringUnchecked";
160 160
161 String trim() { 161 String trim() {
162 final int len = this.length; 162 final int len = this.length;
163 int first = 0; 163 int first = 0;
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
462 String this.str, 462 String this.str,
463 String this.pattern); 463 String this.pattern);
464 464
465 int start() => _start; 465 int start() => _start;
466 int end() => _start + pattern.length; 466 int end() => _start + pattern.length;
467 String operator[](int g) => group(g); 467 String operator[](int g) => group(g);
468 int groupCount() => 0; 468 int groupCount() => 0;
469 469
470 String group(int group) { 470 String group(int group) {
471 if (group != 0) { 471 if (group != 0) {
472 throw new IndexOutOfRangeException(group); 472 throw new RangeError(group);
473 } 473 }
474 return pattern; 474 return pattern;
475 } 475 }
476 476
477 List<String> groups(List<int> groups) { 477 List<String> groups(List<int> groups) {
478 List<String> result = new List<String>(); 478 List<String> result = new List<String>();
479 for (int g in groups) { 479 for (int g in groups) {
480 result.add(group(g)); 480 result.add(group(g));
481 } 481 }
482 return result; 482 return result;
483 } 483 }
484 484
485 final int _start; 485 final int _start;
486 final String str; 486 final String str;
487 final String pattern; 487 final String pattern;
488 } 488 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698