mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 18:12:02 +00:00
HiliteComparator: add Hilite alias for const char * representing hilites
This commit is contained in:
parent
2ff5d60509
commit
86edd48096
@ -2,13 +2,13 @@
|
||||
|
||||
namespace HiliteComparator {
|
||||
|
||||
[[maybe_unused]] const char * consume_hilites(const char ** ptr_ptr)
|
||||
[[maybe_unused]] Hilite consume_hilites(const char ** ptr_ptr)
|
||||
{
|
||||
const char * last_hilite = nullptr;
|
||||
while (true)
|
||||
{
|
||||
bool changed_hilite = false;
|
||||
for (const char * hilite : HILITES)
|
||||
for (Hilite hilite : HILITES)
|
||||
{
|
||||
if (std::string_view(*ptr_ptr).starts_with(hilite))
|
||||
{
|
||||
@ -55,13 +55,15 @@ bool are_equal_with_hilites(std::string_view left, std::string_view right)
|
||||
|
||||
const char * left_it = left.begin();
|
||||
const char * right_it = right.begin();
|
||||
const char * left_hilite = DB::IAST::hilite_none;
|
||||
const char * right_hilite = DB::IAST::hilite_none;
|
||||
Hilite left_hilite = DB::IAST::hilite_none;
|
||||
Hilite right_hilite = DB::IAST::hilite_none;
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Consume all prefix hilites, update the current hilite to be the last one.
|
||||
const char * last_hilite = consume_hilites(&left_it);
|
||||
Hilite last_hilite;
|
||||
|
||||
last_hilite = consume_hilites(&left_it);
|
||||
if (last_hilite != nullptr)
|
||||
left_hilite = last_hilite;
|
||||
|
||||
|
@ -5,7 +5,9 @@
|
||||
|
||||
namespace HiliteComparator {
|
||||
|
||||
const std::vector<const char *> HILITES =
|
||||
using Hilite = const char *;
|
||||
|
||||
const std::vector<Hilite> HILITES =
|
||||
{
|
||||
DB::IAST::hilite_keyword,
|
||||
DB::IAST::hilite_identifier,
|
||||
@ -16,7 +18,7 @@ const std::vector<const char *> HILITES =
|
||||
DB::IAST::hilite_none
|
||||
};
|
||||
|
||||
[[maybe_unused]] const char * consume_hilites(const char ** ptr_ptr);
|
||||
[[maybe_unused]] Hilite consume_hilites(const char ** ptr_ptr);
|
||||
|
||||
String remove_hilites(std::string_view string);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user