@@ -27,8 +27,9 @@ abstract class YamlNode {
2727 /// [SourceSpan.message] can be used to produce a human-friendly message about
2828 /// this node.
2929 SourceSpan get span => _span;
30+ SourceSpan _span;
3031
31- late SourceSpan _span;
32+ YamlNode ._( this . _span) ;
3233
3334 /// The inner value of this node.
3435 ///
@@ -83,9 +84,8 @@ class YamlMap extends YamlNode with collection.MapMixin, UnmodifiableMapMixin {
8384
8485 /// Users of the library should not use this constructor.
8586 YamlMap .internal (Map <dynamic , YamlNode > nodes, SourceSpan span, this .style)
86- : nodes = UnmodifiableMapView <dynamic , YamlNode >(nodes) {
87- _span = span;
88- }
87+ : nodes = UnmodifiableMapView <dynamic , YamlNode >(nodes),
88+ super ._(span);
8989
9090 @override
9191 dynamic operator [](key) => nodes[key]? .value;
@@ -134,9 +134,8 @@ class YamlList extends YamlNode with collection.ListMixin {
134134
135135 /// Users of the library should not use this constructor.
136136 YamlList .internal (List <YamlNode > nodes, SourceSpan span, this .style)
137- : nodes = UnmodifiableListView <YamlNode >(nodes) {
138- _span = span;
139- }
137+ : nodes = UnmodifiableListView <YamlNode >(nodes),
138+ super ._(span);
140139
141140 @override
142141 dynamic operator [](int index) => nodes[index].value;
@@ -162,21 +161,20 @@ class YamlScalar extends YamlNode {
162161 /// [sourceUrl] is passed, it's used as the [SourceSpan.sourceUrl] .
163162 ///
164163 /// [sourceUrl] may be either a [String] , a [Uri] , or `null` .
165- YamlScalar .wrap (this .value, {sourceUrl, this .style = ScalarStyle .ANY }) {
164+ YamlScalar .wrap (this .value, {sourceUrl, this .style = ScalarStyle .ANY })
165+ : super ._(NullSpan (sourceUrl)) {
166166 ArgumentError .checkNotNull (style, 'style' );
167- _span = NullSpan (sourceUrl);
168167 }
169168
170169 /// Users of the library should not use this constructor.
171- YamlScalar .internal (this .value, ScalarEvent scalar) : style = scalar.style {
172- _span = scalar.span;
173- }
170+ YamlScalar .internal (this .value, ScalarEvent scalar)
171+ : style = scalar.style,
172+ super ._(scalar.span);
174173
175174 /// Users of the library should not use this constructor.
176175 YamlScalar .internalWithSpan (this .value, SourceSpan span)
177- : style = ScalarStyle .ANY {
178- _span = span;
179- }
176+ : style = ScalarStyle .ANY ,
177+ super ._(span);
180178
181179 @override
182180 String toString () => value.toString ();
0 commit comments