Search in sources :

Example 11 with YamlPath

use of org.springframework.ide.vscode.commons.yaml.path.YamlPath in project sts4 by spring-projects.

the class YamlStructureParserTest method testTraverseSeq.

@Test
public void testTraverseSeq() throws Exception {
    MockYamlEditor editor = new MockYamlEditor("foo:\n" + "- - - - a\n" + "    - c\n" + "- e");
    SRootNode root = editor.parseStructure();
    YamlPath path;
    path = pathWith(0, "foo", 0, 0, 0, 0);
    assertEquals("SEQ(6): - a\n", path.traverse((SNode) root).toString());
    path = pathWith(0, "foo", -1);
    assertNull(path.traverse((SNode) root));
    path = pathWith(0, "foo", 1);
    assertEquals("SEQ(0): - e\n", path.traverse((SNode) root).toString());
    path = pathWith(0, "foo", 2);
    assertNull(path.traverse((SNode) root));
}
Also used : YamlPath(org.springframework.ide.vscode.commons.yaml.path.YamlPath) SRootNode(org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SRootNode) SNode(org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode) Test(org.junit.Test)

Example 12 with YamlPath

use of org.springframework.ide.vscode.commons.yaml.path.YamlPath in project sts4 by spring-projects.

the class YamlStructureParserTest method findAndTraversPathPath.

private void findAndTraversPathPath(MockYamlEditor editor, String snippet) throws Exception {
    SRootNode root = editor.parseStructure();
    SNode node = root.find(editor.startOf(snippet));
    assertNotNull(node);
    YamlPath path = node.getPath();
    SNode actualNode = path.traverse((SNode) root);
    assertEquals(node, actualNode);
}
Also used : YamlPath(org.springframework.ide.vscode.commons.yaml.path.YamlPath) SRootNode(org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SRootNode) SNode(org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode)

Aggregations

YamlPath (org.springframework.ide.vscode.commons.yaml.path.YamlPath)12 YamlFileAST (org.springframework.ide.vscode.commons.yaml.ast.YamlFileAST)4 SNode (org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SNode)4 SRootNode (org.springframework.ide.vscode.commons.yaml.structure.YamlStructureParser.SRootNode)4 Test (org.junit.Test)3 Node (org.yaml.snakeyaml.nodes.Node)3 MappingNode (org.yaml.snakeyaml.nodes.MappingNode)2 StemcellModel (org.springframework.ide.vscode.bosh.models.StemcellModel)1 QuickfixData (org.springframework.ide.vscode.commons.languageserver.quickfix.Quickfix.QuickfixData)1 IntegerRange (org.springframework.ide.vscode.commons.util.IntegerRange)1 Renderable (org.springframework.ide.vscode.commons.util.Renderable)1 ValueParseException (org.springframework.ide.vscode.commons.util.ValueParseException)1 DocumentRegion (org.springframework.ide.vscode.commons.util.text.DocumentRegion)1 IRegion (org.springframework.ide.vscode.commons.util.text.IRegion)1 NodeRef (org.springframework.ide.vscode.commons.yaml.ast.NodeRef)1 YamlAssistContext (org.springframework.ide.vscode.commons.yaml.completion.YamlAssistContext)1 SNodeDynamicSchemaContext (org.springframework.ide.vscode.commons.yaml.schema.SNodeDynamicSchemaContext)1 Constraint (org.springframework.ide.vscode.commons.yaml.schema.constraints.Constraint)1 YamlDocument (org.springframework.ide.vscode.commons.yaml.structure.YamlDocument)1 ScalarNode (org.yaml.snakeyaml.nodes.ScalarNode)1