visitStringLiteral method

  1. @override
Object? visitStringLiteral(
  1. SAstNode node
)
override

Category fallback for string literals.

Implementation

@override
Object? visitStringLiteral(SAstNode node) {
  if (node is SSimpleStringLiteral) {
    return node.value;
  } else if (node is SAdjacentStrings) {
    // Handle adjacent strings like 'Hello ' 'World!'
    final buffer = StringBuffer();
    for (final stringLiteral in node.strings) {
      if (stringLiteral is SSimpleStringLiteral) {
        buffer.write(stringLiteral.value);
      } else {
        // G-DOV-1/2 FIX: Handle SStringInterpolation children within
        // SAdjacentStrings; recursively handle nested adjacent strings.
        final value = stringLiteral is SStringInterpolation
            ? visitStringInterpolation(stringLiteral)
            : visitStringLiteral(stringLiteral);
        // ghissues62: an awaited operand suspends; hand the suspension up so
        // the state machine resumes this node instead of using the request
        // as a value.
        if (value is AsyncSuspensionRequest) return value;
        buffer.write(value.toString());
      }
    }
    return buffer.toString();
  }
  throw UnimplementedD4rtException(
    'Type de StringLiteral non géré: ${node.runtimeType}',
  );
}