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

Side by Side Diff: pkg/intl/lib/number_format.dart

Issue 13817008: Fix some warnings in pub and pkg packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes. Created 7 years, 8 months 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 part of intl; 5 part of intl;
6 /** 6 /**
7 * Provides the ability to format a number in a locale-specific way. The 7 * Provides the ability to format a number in a locale-specific way. The
8 * format is specified as a pattern using a subset of the ICU formatting 8 * format is specified as a pattern using a subset of the ICU formatting
9 * patterns. 9 * patterns.
10 * 10 *
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 format._positivePrefix = _parseAffix(); 468 format._positivePrefix = _parseAffix();
469 var trunk = _parseTrunk(); 469 var trunk = _parseTrunk();
470 format._positiveSuffix = _parseAffix(); 470 format._positiveSuffix = _parseAffix();
471 // If we have separate positive and negative patterns, now parse the 471 // If we have separate positive and negative patterns, now parse the
472 // the negative version. 472 // the negative version.
473 if (pattern.current == _NumberFormatParser._PATTERN_SEPARATOR) { 473 if (pattern.current == _NumberFormatParser._PATTERN_SEPARATOR) {
474 pattern.moveNext(); 474 pattern.moveNext();
475 format._negativePrefix = _parseAffix(); 475 format._negativePrefix = _parseAffix();
476 // Skip over the negative trunk, verifying that it's identical to the 476 // Skip over the negative trunk, verifying that it's identical to the
477 // positive trunk. 477 // positive trunk.
478 for (var each in _iterator(trunk)) { 478 for (var each in _iterable(trunk)) {
479 if (pattern.current != each && pattern.current != null) { 479 if (pattern.current != each && pattern.current != null) {
480 throw new FormatException( 480 throw new FormatException(
481 "Positive and negative trunks must be the same"); 481 "Positive and negative trunks must be the same");
482 } 482 }
483 pattern.moveNext(); 483 pattern.moveNext();
484 } 484 }
485 format._negativeSuffix = _parseAffix(); 485 format._negativeSuffix = _parseAffix();
486 } else { 486 } else {
487 // If no negative affix is specified, they share the same positive affix. 487 // If no negative affix is specified, they share the same positive affix.
488 format._negativePrefix = format._positivePrefix + format._negativePrefix; 488 format._negativePrefix = format._positivePrefix + format._negativePrefix;
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
713 default: 713 default:
714 return false; 714 return false;
715 } 715 }
716 trunk.write(ch); 716 trunk.write(ch);
717 pattern.moveNext(); 717 pattern.moveNext();
718 return true; 718 return true;
719 } 719 }
720 } 720 }
721 721
722 /** 722 /**
723 * Returns an [Iterable] on the string as a list of substrings.
724 */
725 Iterable _iterable(String s) => new _StringIterable(s);
726
727 /**
723 * Return an iterator on the string as a list of substrings. 728 * Return an iterator on the string as a list of substrings.
724 */ 729 */
725 Iterator _iterator(String s) => new _StringIterator(s); 730 Iterator _iterator(String s) => new _StringIterator(s);
726 731
732 // TODO(nweiz): remove this when issue 3780 is fixed.
733 /**
734 * Provides an Iterable that wraps [_iterator] so it can be used in a `for`
735 * loop.
736 */
737 class _StringIterable extends Iterable<String> {
738 final Iterator<String> iterator;
739
740 _StringIterable(String s)
741 : iterator = _iterator(s);
742 }
743
727 /** 744 /**
728 * Provides an iterator over a string as a list of substrings, and also 745 * Provides an iterator over a string as a list of substrings, and also
729 * gives us a lookahead of one via the [peek] method. 746 * gives us a lookahead of one via the [peek] method.
730 */ 747 */
731 class _StringIterator implements Iterator<String> { 748 class _StringIterator implements Iterator<String> {
732 String input; 749 String input;
733 var index = -1; 750 var index = -1;
734 inBounds(i) => i >= 0 && i < input.length; 751 inBounds(i) => i >= 0 && i < input.length;
735 _StringIterator(this.input); 752 _StringIterator(this.input);
736 String get current => inBounds(index) ? input[index] : null; 753 String get current => inBounds(index) ? input[index] : null;
737 754
738 bool moveNext() => inBounds(++index); 755 bool moveNext() => inBounds(++index);
739 String get peek => inBounds(index + 1) ? input[index + 1] : null; 756 String get peek => inBounds(index + 1) ? input[index + 1] : null;
740 Iterator<String> get iterator => this; 757 Iterator<String> get iterator => this;
741 } 758 }
OLDNEW
« no previous file with comments | « pkg/intl/lib/message_lookup_by_library.dart ('k') | pkg/scheduled_test/lib/src/scheduled_server/safe_http_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698