@@ -12,26 +12,26 @@ import 'string_scanner.dart';
1212import 'utils.dart' ;
1313
1414/// A subclass of [LineScanner] that exposes matched ranges as source map
15- /// [Span ] s.
15+ /// [FileSpan ] s.
1616class SpanScanner extends StringScanner implements LineScanner {
1717 /// The source of the scanner.
1818 ///
19- /// This caches line break information and is used to generate [Span ] s.
19+ /// This caches line break information and is used to generate [FileSpan ] s.
2020 final SourceFile _sourceFile;
2121
2222 int get line => _sourceFile.getLine (position);
2323 int get column => _sourceFile.getColumn (position);
2424
25- LineScannerState get state => new _SpanScannerState (this , position);
25+ LineScannerState get state => _SpanScannerState (this , position);
2626
2727 set state (LineScannerState state) {
2828 if (state is ! _SpanScannerState ||
2929 ! identical ((state as _SpanScannerState )._scanner, this )) {
30- throw new ArgumentError ("The given LineScannerState was not returned by "
30+ throw ArgumentError ("The given LineScannerState was not returned by "
3131 "this LineScanner." );
3232 }
3333
34- this . position = state.position;
34+ position = state.position;
3535 }
3636
3737 /// The [FileSpan] for [lastMatch] .
@@ -57,7 +57,7 @@ class SpanScanner extends StringScanner implements LineScanner {
5757 /// [FileSpan] s as well as for error reporting. It can be a [String] , a
5858 /// [Uri] , or `null` .
5959 SpanScanner (String string, {sourceUrl, int position})
60- : _sourceFile = new SourceFile .fromString (string, url: sourceUrl),
60+ : _sourceFile = SourceFile .fromString (string, url: sourceUrl),
6161 super (string, sourceUrl: sourceUrl, position: position);
6262
6363 /// Creates a new [SpanScanner] that eagerly computes line and column numbers.
@@ -76,9 +76,9 @@ class SpanScanner extends StringScanner implements LineScanner {
7676
7777 /// Creates a new [SpanScanner] that scans within [span] .
7878 ///
79- /// This scans through [span.text] , but emits new spans from [span.file] in
79+ /// This scans through [span] ` .text, but emits new spans from [span]` .file` in
8080 /// their appropriate relative positions. The [string] field contains only
81- /// [span.text] , and [position] , [line] , and [column] are all relative to the
81+ /// [span] ` .text` , and [position] , [line] , and [column] are all relative to the
8282 /// span.
8383 factory SpanScanner .within (FileSpan span) = RelativeSpanScanner ;
8484
@@ -103,13 +103,11 @@ class SpanScanner extends StringScanner implements LineScanner {
103103 validateErrorArgs (string, match, position, length);
104104
105105 if (match == null && position == null && length == null ) match = lastMatch;
106- if (position == null ) {
107- position = match == null ? this .position : match.start;
108- }
109- if (length == null ) length = match == null ? 0 : match.end - match.start;
106+ position ?? = match == null ? this .position : match.start;
107+ length ?? = match == null ? 0 : match.end - match.start;
110108
111109 var span = _sourceFile.span (position, position + length);
112- throw new StringScannerException (message, span, string);
110+ throw StringScannerException (message, span, string);
113111 }
114112}
115113
0 commit comments