toStringWithData method

dynamic toStringWithData(
  1. dynamic withCursorAt
)

Implementation

toStringWithData(withCursorAt) {
  stringifySymbolSequence(e) {
    return e is Map && e.containsKey('literal')
        ? jsonEncode(e['literal'])
        : e is Map && e.containsKey('type')
            ? '%' + e['type']
            : e.toString();
  }

  var symbolSequence = (withCursorAt == null)
      ? this.symbols.map(stringifySymbolSequence).join(' ')
      : (this
              .symbols
              .take(withCursorAt - 1 < 0 ? 0 : withCursorAt - 1)
              .map(stringifySymbolSequence)
              .join(' ') +
          " ● " +
          this
              .symbols
              .take(withCursorAt)
              .map(stringifySymbolSequence)
              .join(' '));
  return this.name + " → " + symbolSequence;
}