visitStringInterpolation method

  1. @override
Object? visitStringInterpolation(
  1. SStringInterpolation node
)
override

Implementation

@override
Object? visitStringInterpolation(SStringInterpolation node) {
  final buffer = StringBuffer();
  for (final element in node.elements) {
    if (element is SInterpolationString) {
      buffer.write(element.value);
    } else if (element is SInterpolationExpression) {
      final value = element.expression!.accept<Object?>(this);
      // If the value is an async suspension, propagate it upward
      if (value is AsyncSuspensionRequest) {
        return value;
      }
      buffer.write(stringify(value)); // Use stringify helper
    } else {
      // Should not happen based on AST structure
      throw StateD4rtException(
        'Unknown interpolation element: ${element.runtimeType}',
      );
    }
  }
  return buffer.toString();
}