Search in sources :

Example 1 with Key

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

Example 2 with Key

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

Example 3 with Key

use of org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Key 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)3 Key (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Key)3 Node (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Node)3 Value (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.Value)2 Test (org.junit.Test)1 EmptyLine (org.springframework.ide.vscode.java.properties.parser.PropertiesAst.EmptyLine)1