use of org.springframework.ide.vscode.java.properties.parser.ParseResults 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.ParseResults in project sts4 by spring-projects.
the class PropertiesAstTest method positionEmptyLine.
@Test
public void positionEmptyLine() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key = value\n" + "\t\n");
Node node = results.ast.findNode(23);
assertTrue(node instanceof EmptyLine);
assertTrue(node.getOffset() <= 23 && 23 <= node.getOffset() + node.getLength());
node = results.ast.findNode(24);
assertTrue(node instanceof EmptyLine);
assertTrue(node.getOffset() <= 24 && 24 <= node.getOffset() + node.getLength());
}
use of org.springframework.ide.vscode.java.properties.parser.ParseResults in project sts4 by spring-projects.
the class PropertiesAstTest method positionValueEofAtEnd.
@Test
public void positionValueEofAtEnd() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key = value");
Node node = results.ast.findNode(22);
assertTrue(node instanceof Value);
assertTrue(node.getOffset() <= 22 && 22 <= node.getOffset() + node.getLength());
node = results.ast.findNode(16);
assertTrue(node instanceof Value);
assertTrue(node.getOffset() <= 16 && 16 <= node.getOffset() + node.getLength());
}
use of org.springframework.ide.vscode.java.properties.parser.ParseResults 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());
}
use of org.springframework.ide.vscode.java.properties.parser.ParseResults in project sts4 by spring-projects.
the class PropertiesAstTest method testLines3.
@Test
public void testLines3() throws Exception {
ParseResults results = parser.parse("# Comment\n\nkey = value 1 \n \t \t \n\t\t\n");
assertTrue(results.syntaxErrors.isEmpty());
assertTrue(results.problems.isEmpty());
assertEquals(5, results.ast.getAllNodes().size());
assertEquals(1, results.ast.getNodes(Comment.class).size());
assertEquals(1, results.ast.getNodes(KeyValuePair.class).size());
assertEquals(3, results.ast.getNodes(EmptyLine.class).size());
}
Aggregations