mapSpan method

FileSpan mapSpan(
  1. SourceSpan target
)

Maps a span in the string generated from this interpolation to its original source.

Implementation

FileSpan mapSpan(SourceSpan target) =>
    switch ((_mapLocation(target.start), _mapLocation(target.end))) {
      (FileSpan start, FileSpan end) => start.expand(end),
      (FileSpan start, FileLocation end) => _interpolation.span.file
          .span(_expandInterpolationSpanLeft(start.start), end.offset),
      (FileLocation start, FileSpan end) => _interpolation.span.file
          .span(start.offset, _expandInterpolationSpanRight(end.end)),
      (FileLocation start, FileLocation end) =>
        _interpolation.span.file.span(start.offset, end.offset),
      _ => throw '[BUG] Unreachable'
    };