use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node in project sts4 by spring-projects.
the class PropertiesCompletionProposalsCalculator method calculate.
/**
* Create completions proposals in the context of a properties text editor.
*/
public Collection<ICompletionProposal> calculate() throws BadLocationException {
ParseResults parseResults = parser.parse(doc.get());
Node node = parseResults.ast.findNode(offset);
if (node instanceof Value) {
return getValueCompletions((Value) node);
} else if (node instanceof Key || node instanceof EmptyLine || node == null) {
return getPropertyCompletions();
}
return Collections.emptyList();
}
use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node in project sts4 by spring-projects.
the class PropertiesAstTest method positionPair.
@Test
public void positionPair() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key = value\n" + "\t\n");
Node node = results.ast.findNode(15);
assertTrue(node instanceof KeyValuePair);
assertTrue(node.getOffset() <= 15 && 15 <= 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 positionValue.
@Test
public void positionValue() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key = value\n");
Node node = results.ast.findNode(17);
assertTrue(node instanceof Value);
assertTrue(node.getOffset() <= 17 && 17 <= node.getOffset() + node.getLength());
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 positionEmptyValue.
@Test
public void positionEmptyValue() throws Exception {
ParseResults results = parser.parse("# Comment\n" + "key =");
Node node = results.ast.findNode(16);
assertTrue(node instanceof Value);
assertTrue(node.getOffset() <= 16 && 16 <= node.getOffset() + node.getLength());
}
Aggregations