use of com.redhat.qute.parser.template.Parameter 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);
}
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class QuteSearchUtils method searchDeclaredObjectInParameter.
private static Parameter searchDeclaredObjectInParameter(ObjectPart part, CancelChecker cancelChecker) {
String partName = part.getPartName();
Node parent = part.getParentSection();
while (parent != null) {
if (parent.getKind() == NodeKind.Section) {
Section section = (Section) parent;
switch(section.getSectionKind()) {
case EACH:
case FOR:
LoopSection iterableSection = (LoopSection) section;
if (!iterableSection.isInElseBlock(part.getStart())) {
String alias = iterableSection.getAlias();
if (partName.equals(alias) || section.isMetadata(partName)) {
// - or the metadata of the section (ex : item_count)
return iterableSection.getAliasParameter();
}
}
break;
case LET:
case SET:
List<Parameter> parameters = section.getParameters();
for (Parameter parameter : parameters) {
if (partName.equals(parameter.getName())) {
return parameter;
}
}
break;
default:
}
}
parent = parent.getParent();
}
return null;
}
use of com.redhat.qute.parser.template.Parameter 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;
}
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class QuteSearchUtils method searchDeclaredObject.
// ------------------- Search declared object
/**
* Search the declared object of the given object part.
*
* @param part the object part.
* @param collector the collector used to collect node and range.
* @param includeNode true if the origin part must be collected and false
* otherwise.
* @param cancelChecker the cancel checker.
*/
public static void searchDeclaredObject(ObjectPart part, BiConsumer<Node, Range> collector, boolean includeNode, CancelChecker cancelChecker) {
if (includeNode) {
Range range = QutePositionUtility.createRange(part);
collector.accept(part, range);
}
String namespace = part.getNamespace();
if (NamespacePart.DATA_NAMESPACE.equals(namespace)) {
searchDeclaredObjectInParameterDeclaration(part, collector);
} else {
Parameter parameter = searchDeclaredObjectInParameter(part, cancelChecker);
if (parameter != null) {
Range targetRange = QutePositionUtility.selectParameterName(parameter);
collector.accept(parameter, targetRange);
} else {
searchDeclaredObjectInParameterDeclaration(part, collector);
}
}
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class WithSection method accept0.
@Override
protected void accept0(ASTVisitor visitor) {
boolean visitChildren = visitor.visit(this);
if (visitChildren) {
List<Parameter> parameters = getParameters();
for (Parameter parameter : parameters) {
acceptChild(visitor, parameter);
}
acceptChildren(visitor, getChildren());
}
visitor.endVisit(this);
}
Aggregations