Search in sources :

Example 1 with Comment

use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Comment in project sts4 by spring-projects.

the class PropertiesAntlrParserTest method testCommentLine.

private void testCommentLine(String text, String expectedComment) {
    ParseResults results = parser.parse(text);
    assertTrue(results.syntaxErrors.isEmpty());
    assertTrue(results.problems.isEmpty());
    assertEquals(1, results.ast.getAllNodes().size());
    List<Comment> commentLines = results.ast.getNodes(Comment.class);
    assertEquals(1, commentLines.size());
    Comment comment = commentLines.get(0);
    assertEquals(expectedComment, text.substring(comment.getOffset(), comment.getOffset() + comment.getLength()));
}
Also used : Comment(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Comment) ParseResults(org.springframework.ide.vscode.java.properties.parser.ParseResults)

Example 2 with Comment

use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Comment in project sts4 by spring-projects.

the class PropertiesAstTest method positionComment.

@Test
public void positionComment() throws Exception {
    ParseResults results = parser.parse("# Comment\n" + "key  = value\n");
    Node node = results.ast.findNode(7);
    assertTrue(node instanceof Comment);
    assertTrue(node.getOffset() <= 7 && 7 <= node.getOffset() + node.getLength());
    node = results.ast.findNode(9);
    assertTrue(node instanceof Comment);
    assertTrue(node.getOffset() <= 9 && 9 <= node.getOffset() + node.getLength());
    node = results.ast.findNode(0);
    assertTrue(node instanceof Comment);
    assertTrue(node.getOffset() <= 0 && 0 <= node.getOffset() + node.getLength());
}
Also used : Comment(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Comment) Node(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node) ParseResults(org.springframework.ide.vscode.java.properties.parser.ParseResults) Test(org.junit.Test)

Aggregations

ParseResults (org.springframework.ide.vscode.java.properties.parser.ParseResults)2 Comment (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Comment)2 Test (org.junit.Test)1 Node (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node)1