How to use the yaml-ast-parser.Kind.SEQ function in yaml-ast-parser

To help you get started, we’ve selected a few yaml-ast-parser examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AEB-labs / cruddl / src / schema / schema-builder.ts View on Github external
const mapNode = node as YamlMap;
            const mergedMap = ([] as { path: ReadonlyArray<(string | number)>, node: YAMLNode }[]).concat(...(mapNode.mappings.map(
                (childNode) => extractAllPaths(childNode, [...curPath]))));
            return [...mergedMap];
        case Kind.MAPPING:
            const mappingNode = node as YAMLMapping;
            if (mappingNode.value) {
                return [
                    { path: [...curPath, mappingNode.key.value], node: mappingNode },
                    ...extractAllPaths(mappingNode.value, [...curPath, mappingNode.key.value])
                ];
            }
            break;
        case Kind.SCALAR:
            const scalarNode = node as YAMLScalar;
            if (scalarNode.parent && scalarNode.parent.kind == Kind.SEQ) {
                return [{ path: curPath, node: scalarNode }];
            } else {
                return [{ path: curPath, node: scalarNode.parent }];
            }
        case Kind.SEQ:
            const seqNode = node as YAMLSequence;
            const mergedSequence = ([] as { path: ReadonlyArray<(string | number)>, node: YAMLNode }[]).concat(...(seqNode.items.map(
                (childNode, index) => extractAllPaths(childNode, [...curPath, index]))));
            return [...mergedSequence];
        case Kind.INCLUDE_REF:
        case Kind.ANCHOR_REF:
            const refNode = node as YAMLAnchorReference;
            return extractAllPaths(refNode.value, [...curPath]);
    }
    return [{ path: curPath, node: node }];
}
github replicatedhq / replicated-lint / src / ast.ts View on Github external
function isSeq(node: YAMLNode) {
  return node.kind === Kind.SEQ;
}
github redhat-developer / yaml-language-server / src / languageService / services / validationService.ts View on Github external
private testForParentType(parentNodeType, itemsList, currentNode, parentNode){
    if(itemsList.indexOf(currentNode) !== -1){
      if(parentNodeType === 'array'){
        return parentNode.kind !== Kind.SEQ;
      }else if(parentNodeType === undefined ){
        return parentNode.kind !== Kind.MAP;
      }else if(parentNodeType === "object"){
        return parentNode.kind !== Kind.MAP;
      }
    }
    return false;
  }