| OLD | NEW |
| 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 library yaml.yaml_node; | 5 library yaml.yaml_node; |
| 6 | 6 |
| 7 import 'dart:collection' as collection; | 7 import 'dart:collection' as collection; |
| 8 | 8 |
| 9 import 'package:collection/collection.dart'; | 9 import 'package:collection/collection.dart'; |
| 10 import 'package:source_span/source_span.dart'; | 10 import 'package:source_span/source_span.dart'; |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 /// [sourceUrl] may be either a [String], a [Uri], or `null`. | 110 /// [sourceUrl] may be either a [String], a [Uri], or `null`. |
| 111 factory YamlList({sourceUrl}) => | 111 factory YamlList({sourceUrl}) => |
| 112 new YamlListWrapper(const [], sourceUrl); | 112 new YamlListWrapper(const [], sourceUrl); |
| 113 | 113 |
| 114 /// Wraps a Dart list so that it can be accessed (recursively) like a | 114 /// Wraps a Dart list so that it can be accessed (recursively) like a |
| 115 /// [YamlList]. | 115 /// [YamlList]. |
| 116 /// | 116 /// |
| 117 /// Any [SourceSpan]s returned by this list or its children will be dummies | 117 /// Any [SourceSpan]s returned by this list or its children will be dummies |
| 118 /// without useful location information. However, they will have a reasonable | 118 /// without useful location information. However, they will have a reasonable |
| 119 /// implementation of [SourceSpan.getLocationMessage]. If [sourceUrl] is | 119 /// implementation of [SourceSpan.getLocationMessage]. If [sourceUrl] is |
| 120 /// passed, it's used as the [Span.sourceUrl]. | 120 /// passed, it's used as the [SourceSpan.sourceUrl]. |
| 121 /// | 121 /// |
| 122 /// [sourceUrl] may be either a [String], a [Uri], or `null`. | 122 /// [sourceUrl] may be either a [String], a [Uri], or `null`. |
| 123 factory YamlList.wrap(List dartList, {sourceUrl}) => | 123 factory YamlList.wrap(List dartList, {sourceUrl}) => |
| 124 new YamlListWrapper(dartList, sourceUrl); | 124 new YamlListWrapper(dartList, sourceUrl); |
| 125 | 125 |
| 126 /// Users of the library should not use this constructor. | 126 /// Users of the library should not use this constructor. |
| 127 YamlList.internal(List<YamlNode> nodes, this.span) | 127 YamlList.internal(List<YamlNode> nodes, this.span) |
| 128 : nodes = new UnmodifiableListView<YamlNode>(nodes); | 128 : nodes = new UnmodifiableListView<YamlNode>(nodes); |
| 129 | 129 |
| 130 operator [](int index) => nodes[index].value; | 130 operator [](int index) => nodes[index].value; |
| 131 | 131 |
| 132 operator []=(int index, value) { | 132 operator []=(int index, value) { |
| 133 throw new UnsupportedError("Cannot modify an unmodifiable List"); | 133 throw new UnsupportedError("Cannot modify an unmodifiable List"); |
| 134 } | 134 } |
| 135 } | 135 } |
| 136 | 136 |
| 137 /// A wrapped scalar value parsed from YAML. | 137 /// A wrapped scalar value parsed from YAML. |
| 138 class YamlScalar extends YamlNode { | 138 class YamlScalar extends YamlNode { |
| 139 final SourceSpan span; | 139 final SourceSpan span; |
| 140 | 140 |
| 141 final value; | 141 final value; |
| 142 | 142 |
| 143 /// Wraps a Dart value in a [YamlScalar]. | 143 /// Wraps a Dart value in a [YamlScalar]. |
| 144 /// | 144 /// |
| 145 /// This scalar's [span] won't have useful location information. However, it | 145 /// This scalar's [span] won't have useful location information. However, it |
| 146 /// will have a reasonable implementation of [SourceSpan.message]. If | 146 /// will have a reasonable implementation of [SourceSpan.message]. If |
| 147 /// [sourceUrl] is passed, it's used as the [Span.sourceUrl]. | 147 /// [sourceUrl] is passed, it's used as the [SourceSpan.sourceUrl]. |
| 148 /// | 148 /// |
| 149 /// [sourceUrl] may be either a [String], a [Uri], or `null`. | 149 /// [sourceUrl] may be either a [String], a [Uri], or `null`. |
| 150 YamlScalar.wrap(this.value, {sourceUrl}) | 150 YamlScalar.wrap(this.value, {sourceUrl}) |
| 151 : span = new NullSpan(sourceUrl); | 151 : span = new NullSpan(sourceUrl); |
| 152 | 152 |
| 153 /// Users of the library should not use this constructor. | 153 /// Users of the library should not use this constructor. |
| 154 YamlScalar.internal(this.value, this.span); | 154 YamlScalar.internal(this.value, this.span); |
| 155 | 155 |
| 156 String toString() => value.toString(); | 156 String toString() => value.toString(); |
| 157 } | 157 } |
| OLD | NEW |