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

Unified Diff: pkg/yaml/lib/src/constructor.dart

Issue 14103026: Restructure the yaml package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/yaml/lib/src/composer.dart ('k') | pkg/yaml/lib/src/deep_equals.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/yaml/lib/src/constructor.dart
diff --git a/pkg/yaml/lib/constructor.dart b/pkg/yaml/lib/src/constructor.dart
similarity index 71%
rename from pkg/yaml/lib/constructor.dart
rename to pkg/yaml/lib/src/constructor.dart
index 73a62a86f5be30261f9221b1ab83b45648e961eb..428c476e57e6732c6a78efeddd25b9cf40dffb19 100644
--- a/pkg/yaml/lib/constructor.dart
+++ b/pkg/yaml/lib/src/constructor.dart
@@ -2,28 +2,32 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
-part of yaml;
+library constructor;
+
+import 'model.dart';
+import 'visitor.dart';
+import 'yaml_map.dart';
/// Takes a parsed and composed YAML document (what the spec calls the
/// "representation graph") and creates native Dart objects that represent that
/// document.
-class _Constructor extends _Visitor {
+class Constructor extends Visitor {
/// The root node of the representation graph.
- _Node root;
+ final Node _root;
/// Map from anchor names to the most recent Dart node with that anchor.
- Map<String, dynamic> anchors;
+ final _anchors = <String, dynamic>{};
- _Constructor(this.root) : this.anchors = {};
+ Constructor(this._root);
/// Runs the Constructor to produce a Dart object.
- construct() => root.visit(this);
+ construct() => _root.visit(this);
/// Returns the value of a scalar.
- visitScalar(_ScalarNode scalar) => scalar.value;
+ visitScalar(ScalarNode scalar) => scalar.value;
/// Converts a sequence into a List of Dart objects.
- visitSequence(_SequenceNode seq) {
+ visitSequence(SequenceNode seq) {
var anchor = getAnchor(seq);
if (anchor != null) return anchor;
var dartSeq = setAnchor(seq, []);
@@ -32,7 +36,7 @@ class _Constructor extends _Visitor {
}
/// Converts a mapping into a Map of Dart objects.
- visitMapping(_MappingNode map) {
+ visitMapping(MappingNode map) {
var anchor = getAnchor(map);
if (anchor != null) return anchor;
var dartMap = setAnchor(map, new YamlMap());
@@ -42,15 +46,15 @@ class _Constructor extends _Visitor {
/// Returns the Dart object that already represents [anchored], if such a
/// thing exists.
- getAnchor(_Node anchored) {
+ getAnchor(Node anchored) {
if (anchored.anchor == null) return null;
- if (anchors.containsKey(anchored.anchor)) return anchors[anchored.anchor];
+ if (_anchors.containsKey(anchored.anchor)) return _anchors[anchored.anchor];
}
/// Records that [value] is the Dart object representing [anchored].
- setAnchor(_Node anchored, value) {
+ setAnchor(Node anchored, value) {
if (anchored.anchor == null) return value;
- anchors[anchored.anchor] = value;
+ _anchors[anchored.anchor] = value;
return value;
}
}
« no previous file with comments | « pkg/yaml/lib/src/composer.dart ('k') | pkg/yaml/lib/src/deep_equals.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698