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
- // @dart=2.9
6
-
7
5
// See the Mustachio README at tool/mustachio/README.md for high-level
8
6
// documentation.
9
7
@@ -50,7 +48,7 @@ class MustachioParser {
50
48
/// [sectionKey] , the end tag is treated as plain text, not a tag.
51
49
/// * if [sectionKey] is null, the end tag is treated as plain text, not a
52
50
/// tag.
53
- List <MustachioNode > _parseBlock ({String /*?*/ sectionKey}) {
51
+ List <MustachioNode > _parseBlock ({String ? sectionKey}) {
54
52
var children = < MustachioNode > [];
55
53
var textStartIndex = _index;
56
54
var textEndIndex = _index;
@@ -128,7 +126,7 @@ class MustachioParser {
128
126
trimTextRight ();
129
127
}
130
128
addTextNode (textStartIndex, textEndIndex);
131
- children.add (result.node);
129
+ children.add (result.node! );
132
130
textStartIndex = _index;
133
131
continue ;
134
132
}
@@ -193,7 +191,7 @@ class MustachioParser {
193
191
///
194
192
/// [_index] should be at the character immediately following the `>`
195
193
/// character which opens a possible partial tag.
196
- _TagParseResult _parsePartial ({@ required int tagStartIndex}) {
194
+ _TagParseResult _parsePartial ({required int tagStartIndex}) {
197
195
var startIndex = _index;
198
196
int endIndex;
199
197
while (true ) {
@@ -229,7 +227,7 @@ class MustachioParser {
229
227
/// [_index] should be at the character immediately following the `#`
230
228
/// character which opens a possible section tag.
231
229
_TagParseResult _parseSection (
232
- {@ required bool invert, @ required int tagStartIndex}) {
230
+ {required bool invert, required int tagStartIndex}) {
233
231
var parsedKey = _parseKey ();
234
232
if (parsedKey.type == _KeyParseResultType .notKey) {
235
233
return _TagParseResult .notTag;
@@ -239,6 +237,7 @@ class MustachioParser {
239
237
240
238
var children = _parseBlock (sectionKey: parsedKey.joinedNames);
241
239
var span = _sourceFile.span (tagStartIndex, _index);
240
+ var parsedKeySpan = parsedKey.span! ;
242
241
243
242
if (parsedKey.names.length > 1 ) {
244
243
// Desugar section with dots into nested sections.
@@ -252,7 +251,7 @@ class MustachioParser {
252
251
// [three] section is the singular child node of the [two] section, and
253
252
// the [two] section is the singular child of the [one] section.
254
253
var lastName = parsedKey.names.last;
255
- var keySpanEndOffset = parsedKey.span .end.offset;
254
+ var keySpanEndOffset = parsedKeySpan .end.offset;
256
255
var lastNameSpan = _sourceFile.span (
257
256
keySpanEndOffset - lastName.length, keySpanEndOffset);
258
257
var section = Section ([lastName], children,
@@ -262,7 +261,7 @@ class MustachioParser {
262
261
// To find the start offset of the ith name, take the length of all of
263
262
// the names 0 through `i - 1` re-joined with '.', and a final '.' at
264
263
// the end.
265
- var sectionKeyStartOffset = parsedKey.span .start.offset +
264
+ var sectionKeyStartOffset = parsedKeySpan .start.offset +
266
265
(i == 0 ? 0 : parsedKey.names.take (i).join ('.' ).length + 1 );
267
266
var keySpan = _sourceFile.span (
268
267
sectionKeyStartOffset, sectionKeyStartOffset + sectionKey.length);
@@ -273,7 +272,7 @@ class MustachioParser {
273
272
}
274
273
275
274
return _TagParseResult .ok (Section (parsedKey.names, children,
276
- invert: invert, span: span, keySpan: parsedKey.span ));
275
+ invert: invert, span: span, keySpan: parsedKeySpan ));
277
276
}
278
277
279
278
/// Tries to parse an end tag at [_index] .
@@ -295,7 +294,7 @@ class MustachioParser {
295
294
///
296
295
/// [_index] should be at the character immediately following the `{{`
297
296
/// characters which open a possible variable tag.
298
- _TagParseResult _parseVariable ({@ required int tagStartIndex}) {
297
+ _TagParseResult _parseVariable ({required int tagStartIndex}) {
299
298
var escape = true ;
300
299
if (_thisChar == $lbrace) {
301
300
escape = false ;
@@ -311,7 +310,7 @@ class MustachioParser {
311
310
312
311
var span = _sourceFile.span (tagStartIndex, _index);
313
312
return _TagParseResult .ok (Variable (parsedKey.names,
314
- escape: escape, span: span, keySpan: parsedKey.span));
313
+ escape: escape, span: span, keySpan: parsedKey.span! ));
315
314
}
316
315
317
316
/// Tries to parse a key at [_index] .
@@ -436,7 +435,7 @@ class Text implements MustachioNode {
436
435
@override
437
436
final SourceSpan span;
438
437
439
- Text (this .content, {@ required this .span});
438
+ Text (this .content, {required this .span});
440
439
441
440
@override
442
441
String toString () => 'Text["$content "]' ;
@@ -457,7 +456,7 @@ class Variable with HasMultiNamedKey implements MustachioNode {
457
456
final SourceSpan keySpan;
458
457
459
458
Variable (this .key,
460
- {@ required this .escape, @ required this .span, @ required this .keySpan});
459
+ {required this .escape, required this .span, required this .keySpan});
461
460
462
461
@override
463
462
String toString () => 'Variable[$key , escape=$escape ]' ;
@@ -481,7 +480,7 @@ class Section with HasMultiNamedKey implements MustachioNode {
481
480
final SourceSpan keySpan;
482
481
483
482
Section (this .key, this .children,
484
- {@ required this .invert, @ required this .span, @ required this .keySpan});
483
+ {required this .invert, required this .span, required this .keySpan});
485
484
486
485
@override
487
486
String toString () => 'Section[$key , invert=$invert ]' ;
@@ -497,7 +496,7 @@ class Partial implements MustachioNode {
497
496
498
497
final SourceSpan keySpan;
499
498
500
- Partial (this .key, {@ required this .span, @ required this .keySpan});
499
+ Partial (this .key, {required this .span, required this .keySpan});
501
500
}
502
501
503
502
/// An enumeration of types of tag parse results.
@@ -519,10 +518,10 @@ class _TagParseResult {
519
518
/// This field is `null` if EOF was reached, or if a tag was not parsed
520
519
/// (perhaps it started out like a tag, but was malformed, and so is read as
521
520
/// text).
522
- final MustachioNode /*?*/ node;
521
+ final MustachioNode ? node;
523
522
524
523
/// The key of an end tag, if an end tag was parsed.
525
- final String /*?*/ endTagKey;
524
+ final String ? endTagKey;
526
525
527
526
_TagParseResult (this .type, this .node, this .endTagKey);
528
527
@@ -564,12 +563,12 @@ class _KeyParseResult {
564
563
565
564
/// The source span from where this key was parsed, if this represents a
566
565
/// parsed key, othwerwise `null` .
567
- final SourceSpan /*?*/ span;
566
+ final SourceSpan ? span;
568
567
569
568
const _KeyParseResult ._(this .type, this .names, {this .span});
570
569
571
570
factory _KeyParseResult (_KeyParseResultType type, String key,
572
- {@ required SourceSpan span}) {
571
+ {required SourceSpan span}) {
573
572
if (key == '.' ) {
574
573
return _KeyParseResult ._(type, [key], span: span);
575
574
} else {
0 commit comments