toString method

  1. @override
String toString()
override

Returns a pretty representation of this token for error messages.

Implementation

@override
String toString() {
  var kindText = TokenKind.kindToString(kind);
  var actualText = text.trim();
  if (kindText != actualText) {
    if (actualText.length > 10) {
      actualText = '${actualText.substring(0, 8)}...';
    }
    return '$kindText($actualText)';
  } else {
    return kindText;
  }
}