mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 04:17:34 +00:00
LibJS: Remove DeprecatedString usage from Token
This commit is contained in:
parent
93674e4383
commit
cfa6b4d815
3 changed files with 9 additions and 9 deletions
|
@ -836,7 +836,7 @@ Token Lexer::next()
|
||||||
|
|
||||||
if (m_hit_invalid_unicode.has_value()) {
|
if (m_hit_invalid_unicode.has_value()) {
|
||||||
value_start = m_hit_invalid_unicode.value() - 1;
|
value_start = m_hit_invalid_unicode.value() - 1;
|
||||||
m_current_token = Token(TokenType::Invalid, "Invalid unicode codepoint in source",
|
m_current_token = Token(TokenType::Invalid, String::from_utf8("Invalid unicode codepoint in source"sv).release_value_but_fixme_should_propagate_errors(),
|
||||||
""sv, // Since the invalid unicode can occur anywhere in the current token the trivia is not correct
|
""sv, // Since the invalid unicode can occur anywhere in the current token the trivia is not correct
|
||||||
m_source.substring_view(value_start + 1, min(4u, m_source.length() - value_start - 2)),
|
m_source.substring_view(value_start + 1, min(4u, m_source.length() - value_start - 2)),
|
||||||
m_filename,
|
m_filename,
|
||||||
|
@ -849,7 +849,7 @@ Token Lexer::next()
|
||||||
} else {
|
} else {
|
||||||
m_current_token = Token(
|
m_current_token = Token(
|
||||||
token_type,
|
token_type,
|
||||||
token_message,
|
String::from_deprecated_string(token_message).release_value_but_fixme_should_propagate_errors(),
|
||||||
m_source.substring_view(trivia_start - 1, value_start - trivia_start),
|
m_source.substring_view(trivia_start - 1, value_start - trivia_start),
|
||||||
m_source.substring_view(value_start - 1, m_position - value_start),
|
m_source.substring_view(value_start - 1, m_position - value_start),
|
||||||
m_filename,
|
m_filename,
|
||||||
|
@ -893,7 +893,7 @@ Token Lexer::force_slash_as_regex()
|
||||||
|
|
||||||
m_current_token = Token(
|
m_current_token = Token(
|
||||||
token_type,
|
token_type,
|
||||||
"",
|
String {},
|
||||||
m_current_token.trivia(),
|
m_current_token.trivia(),
|
||||||
m_source.substring_view(value_start - 1, m_position - value_start),
|
m_source.substring_view(value_start - 1, m_position - value_start),
|
||||||
m_filename,
|
m_filename,
|
||||||
|
|
|
@ -4133,7 +4133,7 @@ Token Parser::consume_and_validate_numeric_literal()
|
||||||
|
|
||||||
void Parser::expected(char const* what)
|
void Parser::expected(char const* what)
|
||||||
{
|
{
|
||||||
auto message = m_state.current_token.message();
|
auto message = m_state.current_token.message().to_deprecated_string();
|
||||||
if (message.is_empty())
|
if (message.is_empty())
|
||||||
message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
|
message = DeprecatedString::formatted("Unexpected token {}. Expected {}", m_state.current_token.name(), what);
|
||||||
syntax_error(message);
|
syntax_error(message);
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <AK/DeprecatedFlyString.h>
|
#include <AK/DeprecatedFlyString.h>
|
||||||
#include <AK/DeprecatedString.h>
|
#include <AK/String.h>
|
||||||
#include <AK/StringView.h>
|
#include <AK/StringView.h>
|
||||||
#include <AK/Variant.h>
|
#include <AK/Variant.h>
|
||||||
|
|
||||||
|
@ -181,9 +181,9 @@ class Token {
|
||||||
public:
|
public:
|
||||||
Token() = default;
|
Token() = default;
|
||||||
|
|
||||||
Token(TokenType type, DeprecatedString message, StringView trivia, StringView value, StringView filename, size_t line_number, size_t line_column, size_t offset)
|
Token(TokenType type, String message, StringView trivia, StringView value, StringView filename, size_t line_number, size_t line_column, size_t offset)
|
||||||
: m_type(type)
|
: m_type(type)
|
||||||
, m_message(message)
|
, m_message(move(message))
|
||||||
, m_trivia(trivia)
|
, m_trivia(trivia)
|
||||||
, m_original_value(value)
|
, m_original_value(value)
|
||||||
, m_value(value)
|
, m_value(value)
|
||||||
|
@ -200,7 +200,7 @@ public:
|
||||||
char const* name() const;
|
char const* name() const;
|
||||||
static char const* name(TokenType);
|
static char const* name(TokenType);
|
||||||
|
|
||||||
DeprecatedString const& message() const { return m_message; }
|
String const& message() const { return m_message; }
|
||||||
StringView trivia() const { return m_trivia; }
|
StringView trivia() const { return m_trivia; }
|
||||||
StringView original_value() const { return m_original_value; }
|
StringView original_value() const { return m_original_value; }
|
||||||
StringView value() const
|
StringView value() const
|
||||||
|
@ -246,7 +246,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TokenType m_type { TokenType::Invalid };
|
TokenType m_type { TokenType::Invalid };
|
||||||
DeprecatedString m_message;
|
String m_message;
|
||||||
StringView m_trivia;
|
StringView m_trivia;
|
||||||
StringView m_original_value;
|
StringView m_original_value;
|
||||||
Variant<Empty, StringView, DeprecatedFlyString> m_value {};
|
Variant<Empty, StringView, DeprecatedFlyString> m_value {};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue