Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: pkg/yaml/lib/src/yaml_node_wrapper.dart

Issue 354653003: Fix busted type parameters in yaml. Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: changelog entry Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/yaml/CHANGELOG.md ('k') | pkg/yaml/pubspec.yaml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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_wrapper; 5 library yaml.yaml_node_wrapper;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:collection/collection.dart' as pkg_collection; 9 import 'package:collection/collection.dart' as pkg_collection;
10 import 'package:source_maps/source_maps.dart'; 10 import 'package:source_maps/source_maps.dart';
11 11
12 import 'null_span.dart'; 12 import 'null_span.dart';
13 import 'yaml_node.dart'; 13 import 'yaml_node.dart';
14 14
15 /// A wrapper that makes a normal Dart map behave like a [YamlMap]. 15 /// A wrapper that makes a normal Dart map behave like a [YamlMap].
16 class YamlMapWrapper extends MapBase 16 class YamlMapWrapper extends MapBase
17 with pkg_collection.UnmodifiableMapMixin<dynamic, YamlNode> 17 with pkg_collection.UnmodifiableMapMixin
18 implements YamlMap { 18 implements YamlMap {
19 final Map _dartMap; 19 final Map _dartMap;
20 20
21 final Span span; 21 final Span span;
22 22
23 final Map<dynamic, YamlNode> nodes; 23 final Map<dynamic, YamlNode> nodes;
24 24
25 Map get value => this; 25 Map get value => this;
26 26
27 Iterable get keys => _dartMap.keys; 27 Iterable get keys => _dartMap.keys;
(...skipping 26 matching lines...) Expand all
54 final Map _dartMap; 54 final Map _dartMap;
55 55
56 final Span _span; 56 final Span _span;
57 57
58 Iterable get keys => 58 Iterable get keys =>
59 _dartMap.keys.map((key) => new YamlScalar.internal(key, _span)); 59 _dartMap.keys.map((key) => new YamlScalar.internal(key, _span));
60 60
61 _YamlMapNodes(this._dartMap, this._span); 61 _YamlMapNodes(this._dartMap, this._span);
62 62
63 YamlNode operator [](Object key) { 63 YamlNode operator [](Object key) {
64 if (key is YamlScalar) key = key.value; 64 // Use "as" here because key being assigned to invalidates local type
65 // inference.
Bob Nystrom 2014/06/24 20:03:49 "local type inference" -> "type propagation"
nweiz 2014/06/24 20:04:45 Done.
66 if (key is YamlScalar) key = (key as YamlScalar).value;
65 if (!_dartMap.containsKey(key)) return null; 67 if (!_dartMap.containsKey(key)) return null;
66 return _nodeForValue(_dartMap[key], _span); 68 return _nodeForValue(_dartMap[key], _span);
67 } 69 }
68 70
69 int get hashCode => _dartMap.hashCode; 71 int get hashCode => _dartMap.hashCode;
70 72
71 operator ==(Object other) => 73 operator ==(Object other) =>
72 other is _YamlMapNodes && other._dartMap == _dartMap; 74 other is _YamlMapNodes && other._dartMap == _dartMap;
73 } 75 }
74 76
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 142
141 operator ==(Object other) => 143 operator ==(Object other) =>
142 other is _YamlListNodes && other._dartList == _dartList; 144 other is _YamlListNodes && other._dartList == _dartList;
143 } 145 }
144 146
145 YamlNode _nodeForValue(value, Span span) { 147 YamlNode _nodeForValue(value, Span span) {
146 if (value is Map) return new YamlMapWrapper._(value, span); 148 if (value is Map) return new YamlMapWrapper._(value, span);
147 if (value is List) return new YamlListWrapper._(value, span); 149 if (value is List) return new YamlListWrapper._(value, span);
148 return new YamlScalar.internal(value, span); 150 return new YamlScalar.internal(value, span);
149 } 151 }
OLDNEW
« no previous file with comments | « pkg/yaml/CHANGELOG.md ('k') | pkg/yaml/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698