Search in sources :

Example 1 with DefinitionRequest

use of com.redhat.qute.services.definition.DefinitionRequest in project quarkus-ls by redhat-developer.

the class QuteDefinition method findDefinition.

public CompletableFuture<List<? extends LocationLink>> findDefinition(Template template, Position position, CancelChecker cancelChecker) {
    try {
        DefinitionRequest definitionRequest = new DefinitionRequest(template, position);
        Node node = definitionRequest.getNode();
        if (node == null) {
            return NO_DEFINITION;
        }
        int offset = definitionRequest.getOffset();
        switch(node.getKind()) {
            case Section:
                // - Java data model definition
                return findDefinitionFromSection(offset, (Section) node, template, cancelChecker);
            case ParameterDeclaration:
                // Return Java class definition
                return findDefinitionFromParameterDeclaration(offset, (ParameterDeclaration) node, template);
            case Expression:
                return findDefinitionFromExpression(offset, (Expression) node, template, cancelChecker);
            case ExpressionPart:
                Part part = (Part) node;
                return findDefinitionFromPart(part, template, cancelChecker);
            default:
                // no definitions
                return NO_DEFINITION;
        }
    } catch (BadLocationException e) {
        LOGGER.log(Level.SEVERE, "Failed creating DefinitionRequest", e);
        return NO_DEFINITION;
    }
}
Also used : DefinitionRequest(com.redhat.qute.services.definition.DefinitionRequest) ObjectPart(com.redhat.qute.parser.expression.ObjectPart) MethodPart(com.redhat.qute.parser.expression.MethodPart) NamespacePart(com.redhat.qute.parser.expression.NamespacePart) Part(com.redhat.qute.parser.expression.Part) PropertyPart(com.redhat.qute.parser.expression.PropertyPart) Node(com.redhat.qute.parser.template.Node) BadLocationException(com.redhat.qute.ls.commons.BadLocationException)

Aggregations

BadLocationException (com.redhat.qute.ls.commons.BadLocationException)1 MethodPart (com.redhat.qute.parser.expression.MethodPart)1 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)1 ObjectPart (com.redhat.qute.parser.expression.ObjectPart)1 Part (com.redhat.qute.parser.expression.Part)1 PropertyPart (com.redhat.qute.parser.expression.PropertyPart)1 Node (com.redhat.qute.parser.template.Node)1 DefinitionRequest (com.redhat.qute.services.definition.DefinitionRequest)1