use of com.redhat.qute.parser.parameter.scanner.ParameterScanner 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;
}
Aggregations