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()));
}
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());
}
Aggregations