yaml-ast-parser
Advanced tools
Comparing version 0.0.28 to 0.0.29
@@ -253,15 +253,10 @@ "use strict"; | ||
} | ||
if ('tag:yaml.org,2002:merge' === keyTag) { | ||
throw new Error("Should not happen"); | ||
var mapping = ast.newMapping(keyNode, valueNode); | ||
mapping.parent = _result; | ||
keyNode.parent = mapping; | ||
if (valueNode != null) { | ||
valueNode.parent = mapping; | ||
} | ||
else { | ||
var mapping = ast.newMapping(keyNode, valueNode); | ||
mapping.parent = _result; | ||
keyNode.parent = mapping; | ||
if (valueNode != null) { | ||
valueNode.parent = mapping; | ||
} | ||
_result.mappings.push(mapping); | ||
_result.endPosition = valueNode ? valueNode.endPosition : keyNode.endPosition + 1; | ||
} | ||
_result.mappings.push(mapping); | ||
_result.endPosition = valueNode ? valueNode.endPosition : keyNode.endPosition + 1; | ||
return _result; | ||
@@ -268,0 +263,0 @@ } |
{ | ||
"name": "yaml-ast-parser", | ||
"version": "0.0.28", | ||
"version": "0.0.29", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "scripts": { |
@@ -11,1 +11,22 @@ # yaml-ast-parser | ||
* built-in support for `!include` tag used in RAML | ||
`load` method can be used to load the tree and returns `YAMLNode` root. | ||
`YAMLNode` class is an ancestor for all node kinds. | ||
It's `kind` field determine node kind, one of `Kind` enum: `SCALAR`, `MAPPING`, `MAP`, `SEQ`, `ANCHOR_REF` or `INCLUDE_REF`. After node kind is determined, it can be casted to one of the `YAMLNode` descendants: `YAMLScalar`, `YAMLMapping`, `YamlMap`, `YAMLSequence` or `YAMLAnchorReference`. | ||
`startPosition` and `endPosition` of `YAMLNode` class provide node range. | ||
`YAMLScalar` has string `value` field. | ||
`YAMLMapping` has `YAMLScalar` `key` and `YAMLNode` `value` fields. | ||
`YAMLSequence` has `YAMLNode[]` `items` field. | ||
`YamlMap` has `YAMLMapping[]` `mappings` field. | ||
`YAMLAnchorReference` has string `referencesAnchor` and `YAMLNode` `value`. | ||
@@ -336,3 +336,4 @@ import ast=require("./yamlAST") | ||
function storeMappingPair(state:State, _result:ast.YamlMap, keyTag, keyNode:ast.YAMLNode, valueNode:ast.YAMLNode):ast.YamlMap { | ||
function storeMappingPair(state:State, _result:ast.YamlMap, keyTag, keyNode:ast.YAMLNode, | ||
valueNode:ast.YAMLNode):ast.YamlMap { | ||
var index, quantity; | ||
@@ -353,12 +354,11 @@ if (keyNode==null){ | ||
if ('tag:yaml.org,2002:merge' === keyTag) { | ||
throw new Error("Should not happen")//TODO LOOK IN IT | ||
//if (Array.isArray(valueNode)) { | ||
// for (index = 0, quantity = valueNode.length; index < quantity; index += 1) { | ||
// mergeMappings(state, _result, valueNode[index]); | ||
// } | ||
//} else { | ||
// mergeMappings(state, _result, valueNode); | ||
//} | ||
} else { | ||
// if ('tag:yaml.org,2002:merge' === keyTag) { | ||
// if (Array.isArray(valueNode)) { | ||
// for (index = 0, quantity = (<any>valueNode).length; index < quantity; index += 1) { | ||
// mergeMappings(state, _result, valueNode[index]); | ||
// } | ||
// } else { | ||
// mergeMappings(state, _result, valueNode); | ||
// } | ||
// } else { | ||
@@ -373,3 +373,3 @@ var mapping=ast.newMapping(<ast.YAMLScalar>keyNode,valueNode); | ||
_result.endPosition=valueNode? valueNode.endPosition : keyNode.endPosition+1; //FIXME.workaround should be position of ':' indeed | ||
} | ||
// } | ||
@@ -376,0 +376,0 @@ return _result; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
348060
32
6908