Search in sources :

Example 1 with EmptyLine

use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.EmptyLine 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());
}
Also used : Node(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node) EmptyLine(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.EmptyLine) ParseResults(org.springframework.ide.vscode.java.properties.parser.ParseResults) Test(org.junit.Test)

Example 2 with EmptyLine

use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.EmptyLine 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();
}
Also used : Node(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node) Value(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Value) EmptyLine(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.EmptyLine) ParseResults(org.springframework.ide.vscode.java.properties.parser.ParseResults) Key(org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Key)

Aggregations

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