createQueryVar function

Expression createQueryVar(
  1. BaseParameterAnnotation annotation,
  2. ServerParam param
)

Implementation

Expression createQueryVar(
  BaseParameterAnnotation annotation,
  ServerParam param,
) {
  if (annotation is! ServerQueryAnnotation) {
    throw ArgumentError('Invalid annotation type: ${annotation.runtimeType}');
  }

  var queryVar = refer('context').property('request');

  if (annotation.all) {
    queryVar = queryVar.property('queryParametersAll');
  } else {
    queryVar = queryVar.property('queryParameters');
  }

  return queryVar.index(literalString(annotation.name ?? param.name));
}