use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node 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.PropertiesAst.Node 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.PropertiesAst.Node 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.PropertiesAst.Node in project sts4 by spring-projects.
the class PropertiesAstTest method positionKey.
@Test
public void positionKey() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key = value\n" + "\t\n");
Node node = results.ast.findNode(10);
assertTrue(node instanceof Key);
assertTrue(node.getOffset() <= 10 && 10 <= node.getOffset() + node.getLength());
node = results.ast.findNode(12);
assertTrue(node instanceof Key);
assertTrue(node.getOffset() <= 12 && 12 <= node.getOffset() + node.getLength());
node = results.ast.findNode(13);
assertTrue(node instanceof Key);
assertTrue(node.getOffset() <= 13 && 13 <= node.getOffset() + node.getLength());
}
use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node in project sts4 by spring-projects.
the class PropertiesHoverCalculator method calculate.
Tuple2<Renderable, IRegion> calculate() {
ParseResults parseResults = parser.parse(doc.get());
Node node = parseResults.ast.findNode(offset);
if (node instanceof Value) {
return getValueHover((Value) node);
} else if (node instanceof Key) {
return getPropertyHover((Key) node);
}
return null;
}
Aggregations