1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 12:17:35 +00:00

LibCpp: Use east const style in Lexer and SyntaxHighlighter

This commit is contained in:
Max Wipfli 2021-06-03 23:17:34 +02:00 committed by Ali Mohammad Pur
parent 282a623853
commit d57d7bea1c
4 changed files with 9 additions and 9 deletions

View file

@ -12,7 +12,7 @@
namespace Cpp { namespace Cpp {
Lexer::Lexer(const StringView& input) Lexer::Lexer(StringView const& input)
: m_input(input) : m_input(input)
{ {
} }
@ -48,7 +48,7 @@ static bool is_valid_nonfirst_character_of_identifier(char ch)
return is_valid_first_character_of_identifier(ch) || isdigit(ch); return is_valid_first_character_of_identifier(ch) || isdigit(ch);
} }
constexpr const char* s_known_keywords[] = { constexpr char const* s_known_keywords[] = {
"alignas", "alignas",
"alignof", "alignof",
"and", "and",
@ -125,7 +125,7 @@ constexpr const char* s_known_keywords[] = {
"xor_eq" "xor_eq"
}; };
constexpr const char* s_known_types[] = { constexpr char const* s_known_types[] = {
"ByteBuffer", "ByteBuffer",
"CircularDeque", "CircularDeque",
"CircularQueue", "CircularQueue",
@ -186,7 +186,7 @@ constexpr const char* s_known_types[] = {
"wchar_t" "wchar_t"
}; };
static bool is_keyword(const StringView& string) static bool is_keyword(StringView const& string)
{ {
static HashTable<String> keywords(array_size(s_known_keywords)); static HashTable<String> keywords(array_size(s_known_keywords));
if (keywords.is_empty()) { if (keywords.is_empty()) {
@ -195,7 +195,7 @@ static bool is_keyword(const StringView& string)
return keywords.contains(string); return keywords.contains(string);
} }
static bool is_known_type(const StringView& string) static bool is_known_type(StringView const& string)
{ {
static HashTable<String> types(array_size(s_known_types)); static HashTable<String> types(array_size(s_known_types));
if (types.is_empty()) { if (types.is_empty()) {

View file

@ -14,7 +14,7 @@ namespace Cpp {
class Lexer { class Lexer {
public: public:
Lexer(const StringView&); Lexer(StringView const&);
Vector<Token> lex(); Vector<Token> lex();

View file

@ -13,7 +13,7 @@
namespace Cpp { namespace Cpp {
static Syntax::TextStyle style_for_token_type(const Gfx::Palette& palette, Cpp::Token::Type type) static Syntax::TextStyle style_for_token_type(Gfx::Palette const& palette, Cpp::Token::Type type)
{ {
switch (type) { switch (type) {
case Cpp::Token::Type::Keyword: case Cpp::Token::Type::Keyword:
@ -55,7 +55,7 @@ bool SyntaxHighlighter::is_navigatable(void* token) const
return cpp_token == Cpp::Token::Type::IncludePath; return cpp_token == Cpp::Token::Type::IncludePath;
} }
void SyntaxHighlighter::rehighlight(const Palette& palette) void SyntaxHighlighter::rehighlight(Palette const& palette)
{ {
auto text = m_client->get_text(); auto text = m_client->get_text();
Cpp::Lexer lexer(text); Cpp::Lexer lexer(text);

View file

@ -19,7 +19,7 @@ public:
virtual bool is_navigatable(void*) const override; virtual bool is_navigatable(void*) const override;
virtual Syntax::Language language() const override { return Syntax::Language::Cpp; } virtual Syntax::Language language() const override { return Syntax::Language::Cpp; }
virtual void rehighlight(const Palette&) override; virtual void rehighlight(Palette const&) override;
protected: protected:
virtual Vector<MatchingTokenPair> matching_token_pairs() const override; virtual Vector<MatchingTokenPair> matching_token_pairs() const override;