parseInterpolation method Null safety

Interpolation? parseInterpolation()

Implementation

Interpolation? parseInterpolation() {
  if (!next(asDSX ? TokenType.lCurly : TokenType.lDoubleCurly)) return null;
  var doubleCurlyL = _current;

  var expression = parseExpression(0);

  if (expression == null) {
    errors.add(JaelError(JaelErrorSeverity.error,
        'Missing expression in interpolation.', doubleCurlyL.span));
    return null;
  }

  if (!next(asDSX ? TokenType.rCurly : TokenType.rDoubleCurly)) {
    var expected = asDSX ? '}' : '}}';
    errors.add(JaelError(JaelErrorSeverity.error,
        'Missing closing "$expected" in interpolation.', expression.span));
    return null;
  }

  return Interpolation(doubleCurlyL, expression, _current);
}