Chromium Code Reviews| Index: sdk/lib/core/string.dart |
| diff --git a/sdk/lib/core/string.dart b/sdk/lib/core/string.dart |
| index ba07bae5264714c7523b8d493fe224d0023e7ee3..349d1d7b977377ab885ea692542a5fe70f95f379 100644 |
| --- a/sdk/lib/core/string.dart |
| +++ b/sdk/lib/core/string.dart |
| @@ -28,12 +28,6 @@ abstract class String implements Comparable<String>, Pattern { |
| external factory String.fromCharCodes(Iterable<int> charCodes); |
| /** |
| - * *Deprecated*. Use [String.fromCharCode] instead. |
| - */ |
| - @deprecated |
| - factory String.character(int charCode) => new String.fromCharCode(charCode); |
| - |
| - /** |
| * Allocates a new String for the specified [charCode]. |
| * |
| * The new string contains a single code unit if the [charCode] can be |
| @@ -72,14 +66,6 @@ abstract class String implements Comparable<String>, Pattern { |
| String operator [](int index); |
| /** |
| - * Gets the scalar character code at the given [index]. |
| - * |
| - * *This method is deprecated. Please use [codeUnitAt] instead.* |
| - */ |
| - @deprecated |
| - int charCodeAt(int index); |
| - |
| - /** |
| * Returns the 16-bit UTF-16 code unit at the given [index]. |
| */ |
| int codeUnitAt(int index); |
| @@ -219,30 +205,17 @@ abstract class String implements Comparable<String>, Pattern { |
| * are hence equivalent: |
| * |
| * string.split("") |
| - * string.codeUnits.map((unit) => new String.character(unit)) |
| + * string.codeUnits.map((unit) => new String.fromCharCode(unit)) |
| * |
| * Unless it guaranteed that the string is in the basic multilingual plane |
| * (meaning that each code unit represents a rune) it is often better to |
| * map the runes instead: |
| * |
| - * string.runes.map((rune) => new String.character(rune)) |
| + * string.runes.map((rune) => new String.fromCharCode(rune)) |
| */ |
| List<String> split(Pattern pattern); |
| /** |
| - * Returns a list of the individual code-units converted to strings. |
| - * |
| - * *Deprecated* |
| - * If you want to split on code-unit boundaries, use [split]. If you |
| - * want to split on rune boundaries, use [runes] and map the result. |
| - * |
| - * Iterable<String> characters = |
| - * string.runes.map((c) => new String.fromCharCode(c)); |
| - */ |
| - @deprecated |
| - List<String> splitChars(); |
| - |
| - /** |
| * Splits the string on the [pattern], then converts each part and each match. |
| * |
| * The pattern is used to split the string into parts and separating matches. |
| @@ -260,18 +233,9 @@ abstract class String implements Comparable<String>, Pattern { |
| String onNonMatch(String nonMatch)}); |
| /** |
| - * Returns a list of UTF-16 code units of this string. |
| - * |
| - * *This getter is deprecated. Use [codeUnits] instead.* |
| - */ |
| - List<int> get charCodes; |
| - |
| - /** |
| - * Returns an iterable of the UTF-16 code units of this string. |
| + * Returns an unmodifiable list of the UTF-16 code units of this string. |
| */ |
| - // TODO(floitsch): should it return a list? |
| - // TODO(floitsch): make it a bidirectional iterator. |
| - Iterable<int> get codeUnits; |
| + List<int> get codeUnits; |
| /** |
| * Returns an iterable of Unicode code-points of this string. |
| @@ -311,9 +275,9 @@ class Runes extends Iterable<int> { |
| throw new StateError("No elements."); |
| } |
| int length = string.length; |
| - int code = string.charCodeAt(length - 1); |
| + int code = string.codeUnitAt(length - 1); |
| if (_isTrailSurrogate(code) && string.length > 1) { |
| - int previousCode = string.charCodeAt(length - 2); |
| + int previousCode = string.codeUnitAt(length - 2); |
| if (_isLeadSurrogate(previousCode)) { |
| return _combineSurrogatePair(previousCode, code); |
| } |
| @@ -376,8 +340,8 @@ class RuneIterator implements BiDirectionalIterator<int> { |
| /** Throw an error if the index is in the middle of a surrogate pair. */ |
| void _checkSplitSurrogate(int index) { |
| if (index > 0 && index < string.length && |
| - _isLeadSurrogate(string.charCodeAt(index - 1)) && |
| - _isTrailSurrogate(string.charCodeAt(index))) { |
| + _isLeadSurrogate(string.codeUnitAt(index - 1)) && |
| + _isTrailSurrogate(string.codeUnitAt(index))) { |
| throw new ArgumentError("Index inside surrogate pair: $index"); |
| } |
| } |
| @@ -455,10 +419,10 @@ class RuneIterator implements BiDirectionalIterator<int> { |
| _currentCodePoint = null; |
| return false; |
| } |
| - int codeUnit = string.charCodeAt(_position); |
| + int codeUnit = string.codeUnitAt(_position); |
| int nextPosition = _position + 1; |
| if (_isLeadSurrogate(codeUnit) && nextPosition < string.length) { |
| - int nextCodeUnit = string.charCodeAt(nextPosition); |
| + int nextCodeUnit = string.codeUnitAt(nextPosition); |
| if (_isTrailSurrogate(nextCodeUnit)) { |
| _nextPosition = nextPosition + 1; |
| _currentCodePoint = _combineSurrogatePair(codeUnit, nextCodeUnit); |
| @@ -477,9 +441,9 @@ class RuneIterator implements BiDirectionalIterator<int> { |
| return false; |
| } |
| int position = _position - 1; |
| - int codeUnit = string.charCodeAt(position); |
| + int codeUnit = string.codeUnitAt(position); |
| if (_isTrailSurrogate(codeUnit) && position > 0) { |
| - int prevCodeUnit = string.charCodeAt(position - 1); |
| + int prevCodeUnit = string.codeUnitAt(position - 1); |
| if (_isLeadSurrogate(prevCodeUnit)) { |
| _position = position - 1; |
| _currentCodePoint = _combineSurrogatePair(prevCodeUnit, codeUnit); |
| @@ -495,12 +459,12 @@ class RuneIterator implements BiDirectionalIterator<int> { |
| /** |
| * An [Iterable] of the UTF-16 code units of a [String] in index order. |
| */ |
| -class CodeUnits extends ListIterable<int> { |
| +class CodeUnits extends UnmodifiableListBase<int> { |
|
floitsch
2013/02/19 14:03:06
I would prefer if this class is not public. It's a
Lasse Reichstein Nielsen
2013/02/20 06:38:23
Moved to _collection-dev.
|
| /** The string that this is the code units of. */ |
| - String string; |
| + String _string; |
| - CodeUnits(this.string); |
| + CodeUnits(this._string); |
| - int get length => string.length; |
| - int elementAt(int i) => string.codeUnitAt(i); |
| + int get length => _string.length; |
| + int operator[](int i) => _string.codeUnitAt(i); |
| } |