Search in sources :

Example 6 with ParameterDeclaration

use of com.redhat.qute.parser.template.ParameterDeclaration in project quarkus-ls by redhat-developer.

the class QuteHover method doHover.

public CompletableFuture<Hover> doHover(Template template, Position position, SharedSettings settings, CancelChecker cancelChecker) {
    cancelChecker.checkCanceled();
    HoverRequest hoverRequest = null;
    try {
        hoverRequest = new HoverRequest(template, position, settings);
    } catch (BadLocationException e) {
        LOGGER.log(Level.SEVERE, "Failed creating HoverRequest", e);
        return NO_HOVER;
    }
    Node node = hoverRequest.getNode();
    if (node == null) {
        return NO_HOVER;
    }
    switch(node.getKind()) {
        case Section:
            // - Start end tag definition
            Section section = (Section) node;
            return doHoverForSection(section, template, hoverRequest, cancelChecker);
        case ParameterDeclaration:
            ParameterDeclaration parameterDeclaration = (ParameterDeclaration) node;
            return doHoverForParameterDeclaration(parameterDeclaration, template, hoverRequest, cancelChecker);
        case ExpressionPart:
            Part part = (Part) node;
            return doHoverForExpressionPart(part, template, hoverRequest, cancelChecker);
        case Parameter:
            Parameter parameter = (Parameter) node;
            return doHoverForParameter(parameter, template, hoverRequest);
        default:
            return NO_HOVER;
    }
}
Also used : HoverRequest(com.redhat.qute.services.hover.HoverRequest) NamespacePart(com.redhat.qute.parser.expression.NamespacePart) Part(com.redhat.qute.parser.expression.Part) Node(com.redhat.qute.parser.template.Node) Parameter(com.redhat.qute.parser.template.Parameter) LoopSection(com.redhat.qute.parser.template.sections.LoopSection) Section(com.redhat.qute.parser.template.Section) BadLocationException(com.redhat.qute.ls.commons.BadLocationException) ParameterDeclaration(com.redhat.qute.parser.template.ParameterDeclaration)

Example 7 with ParameterDeclaration

use of com.redhat.qute.parser.template.ParameterDeclaration in project quarkus-ls by redhat-developer.

the class QuteSearchUtils method searchReferencedObjects.

// ------------------- Search referenced objects
/**
 * Search referenced object of the given node.
 *
 * @param node          the origin node.
 * @param offset        the offset.
 * @param collector     the collector to collect node and range.
 * @param includeNode   true if the origin node must be collected and false
 *                      otherwise.
 * @param cancelChecker the cancel checker.
 */
public static void searchReferencedObjects(Node node, int offset, BiConsumer<Node, Range> collector, boolean includeNode, CancelChecker cancelChecker) {
    switch(node.getKind()) {
        case ParameterDeclaration:
            {
                ParameterDeclaration parameterDeclaration = (ParameterDeclaration) node;
                if (parameterDeclaration.isInJavaTypeName(offset)) {
                    // {@org.acme.It|em item}
                    RangeOffset rangeOffset = parameterDeclaration.getJavaTypeNameRange(offset);
                    if (rangeOffset != null) {
                        Range range = QutePositionUtility.createRange(rangeOffset, node.getOwnerTemplate());
                        collector.accept(parameterDeclaration, range);
                    }
                } else if (parameterDeclaration.isInAlias(offset)) {
                    // {@org.acme.Item it|em}
                    String alias = parameterDeclaration.getAlias();
                    if (includeNode) {
                        Range range = QutePositionUtility.selectAlias(parameterDeclaration);
                        collector.accept(parameterDeclaration, range);
                    }
                    searchReferencedObjects(alias, PartNameMatcher.BOTH, node, collector, cancelChecker);
                }
                break;
            }
        case Parameter:
            {
                Parameter parameter = (Parameter) node;
                if (includeNode) {
                    Range range = QutePositionUtility.selectParameterName(parameter);
                    collector.accept(parameter, range);
                }
                String alias = parameter.getName();
                searchReferencedObjects(alias, PartNameMatcher.ONLY_NAME, parameter.getParent(), collector, cancelChecker);
                break;
            }
        default:
            break;
    }
}
Also used : RangeOffset(com.redhat.qute.parser.template.RangeOffset) Parameter(com.redhat.qute.parser.template.Parameter) Range(org.eclipse.lsp4j.Range) ParameterDeclaration(com.redhat.qute.parser.template.ParameterDeclaration)

Aggregations

ParameterDeclaration (com.redhat.qute.parser.template.ParameterDeclaration)7 Range (org.eclipse.lsp4j.Range)6 Parameter (com.redhat.qute.parser.template.Parameter)4 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)3 Node (com.redhat.qute.parser.template.Node)3 Section (com.redhat.qute.parser.template.Section)3 LoopSection (com.redhat.qute.parser.template.sections.LoopSection)3 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)2 Part (com.redhat.qute.parser.expression.Part)2 Expression (com.redhat.qute.parser.template.Expression)2 RangeOffset (com.redhat.qute.parser.template.RangeOffset)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 JavaFieldInfo (com.redhat.qute.commons.JavaFieldInfo)1 JavaMemberInfo (com.redhat.qute.commons.JavaMemberInfo)1 JavaMethodInfo (com.redhat.qute.commons.JavaMethodInfo)1 JavaParameterInfo (com.redhat.qute.commons.JavaParameterInfo)1 JavaTypeInfo (com.redhat.qute.commons.JavaTypeInfo)1 BadLocationException (com.redhat.qute.ls.commons.BadLocationException)1 SnippetsBuilder (com.redhat.qute.ls.commons.SnippetsBuilder)1