Search in sources :

Example 11 with Expression

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

the class UserTagUtils method collectUserTagParameters.

private static void collectUserTagParameters(Node parent, Template template, Set<String> extistingObjectParts, Consumer<ObjectPart> collector, CancelChecker cancelChecker) {
    cancelChecker.checkCanceled();
    if (parent.getKind() == NodeKind.Expression) {
        Expression expression = (Expression) parent;
        collectUserTagParameters(expression, extistingObjectParts, collector, cancelChecker);
        return;
    } else if (parent.getKind() == NodeKind.Section) {
        Section section = (Section) parent;
        List<Parameter> parameters = section.getParameters();
        for (Parameter parameter : parameters) {
            if (parameter.isCanHaveExpression()) {
                Expression expression = parameter.getJavaTypeExpression();
                collectUserTagParameters(expression, extistingObjectParts, collector, cancelChecker);
            }
        }
    }
    List<Node> children = parent.getChildren();
    for (Node node : children) {
        collectUserTagParameters(node, template, extistingObjectParts, collector, cancelChecker);
    }
}
Also used : Expression(com.redhat.qute.parser.template.Expression) Node(com.redhat.qute.parser.template.Node) Parameter(com.redhat.qute.parser.template.Parameter) List(java.util.List) Section(com.redhat.qute.parser.template.Section)

Example 12 with Expression

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

the class Part method getParentSection.

@Override
public Section getParentSection() {
    Parts parts = getParent();
    Expression expression = parts.getParent();
    Node parent = expression.getParent();
    if (parent.getKind() == NodeKind.Parameter) {
        // Its' a parameter which belongs to a section (ex : items):
        // {#for item in items}
        // In this case we must get the parent of the parameter section
        Node ownerSection = parent.getParent();
        parent = ownerSection.getParent();
    }
    // loop for parent node to retrieve the parent section.
    while (parent != null) {
        if (parent.getKind() == NodeKind.Section) {
            return (Section) parent;
        }
        parent = parent.getParent();
    }
    return null;
}
Also used : Expression(com.redhat.qute.parser.template.Expression) Node(com.redhat.qute.parser.template.Node) Section(com.redhat.qute.parser.template.Section)

Aggregations

Expression (com.redhat.qute.parser.template.Expression)12 Node (com.redhat.qute.parser.template.Node)8 Parameter (com.redhat.qute.parser.template.Parameter)7 Range (org.eclipse.lsp4j.Range)6 Part (com.redhat.qute.parser.expression.Part)5 Section (com.redhat.qute.parser.template.Section)5 ResolvedJavaTypeInfo (com.redhat.qute.commons.ResolvedJavaTypeInfo)4 ObjectPart (com.redhat.qute.parser.expression.ObjectPart)4 List (java.util.List)4 MethodPart (com.redhat.qute.parser.expression.MethodPart)3 NamespacePart (com.redhat.qute.parser.expression.NamespacePart)3 Parts (com.redhat.qute.parser.expression.Parts)3 DiagnosticDataFactory.createDiagnostic (com.redhat.qute.services.diagnostics.DiagnosticDataFactory.createDiagnostic)3 Diagnostic (org.eclipse.lsp4j.Diagnostic)3 InvalidMethodReason (com.redhat.qute.commons.InvalidMethodReason)2 JavaMemberInfo (com.redhat.qute.commons.JavaMemberInfo)2 BadLocationException (com.redhat.qute.ls.commons.BadLocationException)2 JavaTypeInfoProvider (com.redhat.qute.parser.template.JavaTypeInfoProvider)2 LoopSection (com.redhat.qute.parser.template.sections.LoopSection)2 JavaMemberResult (com.redhat.qute.project.JavaMemberResult)2