1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 02:38:13 +00:00

LibCpp: Modify Token::to_string() to include more information

Token::to_string() now includes not only the token's type, but also its
text and span in the document.
This commit is contained in:
Itamar 2021-05-21 14:39:42 +03:00 committed by Andreas Kling
parent cdea9f5339
commit 0c9db38e8f
4 changed files with 18 additions and 12 deletions

View file

@ -5,6 +5,7 @@
*/
#include "Token.h"
#include <AK/String.h>
namespace Cpp {
@ -24,4 +25,15 @@ bool Position::operator<=(const Position& other) const
{
return !(*this > other);
}
String Token::to_string() const
{
return String::formatted("{} {}:{}-{}:{} ({})", type_to_string(m_type), start().line, start().column, end().line, end().column, text());
}
String Token::type_as_string() const
{
return type_to_string(m_type);
}
}