use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class QuteProject method collectInsert.
private void collectInsert(String insertParamater, Node parent, Template template, List<QuteIndex> indexes) {
if (parent.getKind() == NodeKind.Section) {
Section section = (Section) parent;
if (section.getSectionKind() == SectionKind.INSERT) {
Parameter parameter = section.getParameterAtIndex(0);
if (parameter != null) {
try {
if (insertParamater == null || insertParamater.equals(parameter.getValue())) {
Position position = template.positionAt(parameter.getStart());
Path path = createPath(template.getUri());
QuteTemplateIndex templateIndex = new QuteTemplateIndex(path, template.getTemplateId());
QuteIndex index = new QuteIndex("insert", parameter.getValue(), position, SectionKind.INSERT, templateIndex);
indexes.add(index);
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
}
}
List<Node> children = parent.getChildren();
for (Node node : children) {
collectInsert(insertParamater, node, template, indexes);
}
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class IfSection 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);
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class IncludeSection 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);
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class ParameterParser method parse.
public static List<Parameter> parse(ParametersContainer expression, boolean methodParameters, CancelChecker cancelChecker) {
if (cancelChecker == null) {
cancelChecker = DEFAULT_CANCEL_CHECKER;
}
Template template = expression.getOwnerTemplate();
String text = template.getText();
int start = expression.getStartParametersOffset();
int end = expression.getEndParametersOffset();
ParameterScanner scanner = ParameterScanner.createScanner(text, start, end, methodParameters);
TokenType token = scanner.scan();
List<Parameter> parameters = new ArrayList<>();
Parameter currentParameter = null;
while (token != TokenType.EOS) {
cancelChecker.checkCanceled();
int tokenOffset = scanner.getTokenOffset();
int tokenEnd = scanner.getTokenEnd();
switch(token) {
case Whitespace:
currentParameter = null;
break;
case ParameterName:
currentParameter = new Parameter(tokenOffset, tokenEnd);
currentParameter.setParameterParent(expression);
parameters.add(currentParameter);
break;
case ParameterValue:
if (currentParameter != null) {
// current parameter can be null when parameter name is not defined
// ex : {#let =123} (instead of {#let name=123})
currentParameter.setStartValue(tokenOffset);
currentParameter.setEndValue(tokenEnd);
}
break;
default:
}
token = scanner.scan();
}
return parameters;
}
use of com.redhat.qute.parser.template.Parameter in project quarkus-ls by redhat-developer.
the class CustomSection 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