2
2
// for details. All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
5
- import " characters.dart" ;
6
- import " grapheme_clusters/breaks.dart" ;
7
- import " grapheme_clusters/constants.dart" ;
5
+ import ' characters.dart' ;
6
+ import ' grapheme_clusters/breaks.dart' ;
7
+ import ' grapheme_clusters/constants.dart' ;
8
8
import 'grapheme_clusters/table.dart' ;
9
9
10
10
/// The grapheme clusters of a string.
@@ -28,23 +28,23 @@ final class StringCharacters extends Iterable<String> implements Characters {
28
28
29
29
@override
30
30
String get first => string.isEmpty
31
- ? throw StateError (" No element" )
31
+ ? throw StateError (' No element' )
32
32
: string.substring (
33
33
0 , Breaks (string, 0 , string.length, stateSoTNoBreak).nextBreak ());
34
34
35
35
@override
36
36
String get last => string.isEmpty
37
- ? throw StateError (" No element" )
37
+ ? throw StateError (' No element' )
38
38
: string.substring (
39
39
BackBreaks (string, string.length, 0 , stateEoTNoBreak).nextBreak ());
40
40
41
41
@override
42
42
String get single {
43
- if (string.isEmpty) throw StateError (" No element" );
43
+ if (string.isEmpty) throw StateError (' No element' );
44
44
var firstEnd =
45
45
Breaks (string, 0 , string.length, stateSoTNoBreak).nextBreak ();
46
46
if (firstEnd == string.length) return string;
47
- throw StateError (" Too many elements" );
47
+ throw StateError (' Too many elements' );
48
48
}
49
49
50
50
@override
@@ -74,9 +74,9 @@ final class StringCharacters extends Iterable<String> implements Characters {
74
74
}
75
75
76
76
@override
77
- String join ([String separator = "" ]) {
78
- if (separator == "" ) return string;
79
- return _explodeReplace (string, 0 , string.length, separator, "" );
77
+ String join ([String separator = '' ]) {
78
+ if (separator == '' ) return string;
79
+ return _explodeReplace (string, 0 , string.length, separator, '' );
80
80
}
81
81
82
82
@override
@@ -91,12 +91,12 @@ final class StringCharacters extends Iterable<String> implements Characters {
91
91
cursor = next;
92
92
}
93
93
if (orElse != null ) return orElse ();
94
- throw StateError (" No element" );
94
+ throw StateError (' No element' );
95
95
}
96
96
97
97
@override
98
98
String elementAt (int index) {
99
- RangeError .checkNotNegative (index, " index" );
99
+ RangeError .checkNotNegative (index, ' index' );
100
100
var count = 0 ;
101
101
if (string.isNotEmpty) {
102
102
var breaks = Breaks (string, 0 , string.length, stateSoTNoBreak);
@@ -108,7 +108,7 @@ final class StringCharacters extends Iterable<String> implements Characters {
108
108
start = end;
109
109
}
110
110
}
111
- throw RangeError .index (index, this , " index" , null , count);
111
+ throw RangeError .index (index, this , ' index' , null , count);
112
112
}
113
113
114
114
@override
@@ -209,7 +209,7 @@ final class StringCharacters extends Iterable<String> implements Characters {
209
209
210
210
@override
211
211
Characters skip (int count) {
212
- RangeError .checkNotNegative (count, " count" );
212
+ RangeError .checkNotNegative (count, ' count' );
213
213
return _skip (count);
214
214
}
215
215
@@ -221,7 +221,7 @@ final class StringCharacters extends Iterable<String> implements Characters {
221
221
222
222
@override
223
223
Characters take (int count) {
224
- RangeError .checkNotNegative (count, " count" );
224
+ RangeError .checkNotNegative (count, ' count' );
225
225
return _take (count);
226
226
}
227
227
@@ -233,9 +233,9 @@ final class StringCharacters extends Iterable<String> implements Characters {
233
233
234
234
@override
235
235
Characters getRange (int start, [int ? end]) {
236
- RangeError .checkNotNegative (start, " start" );
236
+ RangeError .checkNotNegative (start, ' start' );
237
237
if (end == null ) return _skip (start);
238
- if (end < start) throw RangeError .range (end, start, null , " end" );
238
+ if (end < start) throw RangeError .range (end, start, null , ' end' );
239
239
if (end == start) return Characters .empty;
240
240
if (start == 0 ) return _take (end);
241
241
if (string.isEmpty) return this ;
@@ -254,10 +254,10 @@ final class StringCharacters extends Iterable<String> implements Characters {
254
254
while (position > 0 ) {
255
255
position-- ;
256
256
start = breaks.nextBreak ();
257
- if (start < 0 ) throw StateError (" No element" );
257
+ if (start < 0 ) throw StateError (' No element' );
258
258
}
259
259
var end = breaks.nextBreak ();
260
- if (end < 0 ) throw StateError (" No element" );
260
+ if (end < 0 ) throw StateError (' No element' );
261
261
if (start == 0 && end == string.length) return this ;
262
262
return StringCharacters (string.substring (start, end));
263
263
}
@@ -311,7 +311,7 @@ final class StringCharacters extends Iterable<String> implements Characters {
311
311
312
312
@override
313
313
Characters skipLast (int count) {
314
- RangeError .checkNotNegative (count, " count" );
314
+ RangeError .checkNotNegative (count, ' count' );
315
315
if (count == 0 ) return this ;
316
316
if (string.isNotEmpty) {
317
317
var breaks = BackBreaks (string, string.length, 0 , stateEoTNoBreak);
@@ -351,7 +351,7 @@ final class StringCharacters extends Iterable<String> implements Characters {
351
351
352
352
@override
353
353
Characters takeLast (int count) {
354
- RangeError .checkNotNegative (count, " count" );
354
+ RangeError .checkNotNegative (count, ' count' );
355
355
if (count == 0 ) return Characters .empty;
356
356
if (string.isNotEmpty) {
357
357
var breaks = BackBreaks (string, string.length, 0 , stateEoTNoBreak);
@@ -446,7 +446,7 @@ class StringCharacterRange implements CharacterRange {
446
446
factory StringCharacterRange .at (String string, int startIndex,
447
447
[int ? endIndex]) {
448
448
RangeError .checkValidRange (
449
- startIndex, endIndex, string.length, " startIndex" , " endIndex" );
449
+ startIndex, endIndex, string.length, ' startIndex' , ' endIndex' );
450
450
return _expandRange (string, startIndex, endIndex ?? startIndex);
451
451
}
452
452
@@ -501,7 +501,7 @@ class StringCharacterRange implements CharacterRange {
501
501
}
502
502
}
503
503
state = move (state, category);
504
- if (state & stateNoBreak == 0 && -- count == 0 ) {
504
+ if (state & maskBreak != flagNoBreak && -- count == 0 ) {
505
505
_move (newStart, index);
506
506
return true ;
507
507
}
@@ -513,7 +513,7 @@ class StringCharacterRange implements CharacterRange {
513
513
_move (newStart, _end);
514
514
return true ;
515
515
} else {
516
- throw RangeError .range (count, 0 , null , " count" );
516
+ throw RangeError .range (count, 0 , null , ' count' );
517
517
}
518
518
}
519
519
@@ -530,7 +530,7 @@ class StringCharacterRange implements CharacterRange {
530
530
bool moveBack ([int count = 1 ]) => _retractStart (count, _start);
531
531
532
532
bool _retractStart (int count, int newEnd) {
533
- RangeError .checkNotNegative (count, " count" );
533
+ RangeError .checkNotNegative (count, ' count' );
534
534
var breaks = _backBreaksFromStart ();
535
535
var start = _start;
536
536
while (count > 0 ) {
@@ -578,7 +578,7 @@ class StringCharacterRange implements CharacterRange {
578
578
579
579
@override
580
580
bool dropFirst ([int count = 1 ]) {
581
- RangeError .checkNotNegative (count, " count" );
581
+ RangeError .checkNotNegative (count, ' count' );
582
582
if (_start == _end) return count == 0 ;
583
583
var breaks = Breaks (_string, _start, _end, stateSoTNoBreak);
584
584
while (count > 0 ) {
@@ -636,7 +636,7 @@ class StringCharacterRange implements CharacterRange {
636
636
637
637
@override
638
638
bool dropLast ([int count = 1 ]) {
639
- RangeError .checkNotNegative (count, " count" );
639
+ RangeError .checkNotNegative (count, ' count' );
640
640
var breaks = BackBreaks (_string, _end, _start, stateEoTNoBreak);
641
641
while (count > 0 ) {
642
642
var nextBreak = breaks.nextBreak ();
0 commit comments