MCPcopy Create free account
hub / github.com/ByConity/ByConity / writeQueryWithHighlightedErrorPositions

Function writeQueryWithHighlightedErrorPositions

src/Parsers/parseQuery.cpp:91–125  ·  view source on GitHub ↗

Hilite place of syntax error.

Source from the content-addressed store, hash-verified

89
90/// Hilite place of syntax error.
91void writeQueryWithHighlightedErrorPositions(
92 WriteBuffer & out,
93 const char * begin,
94 const char * end,
95 const Token * positions_to_hilite, /// must go in ascending order
96 size_t num_positions_to_hilite)
97{
98 const char * pos = begin;
99 for (size_t position_to_hilite_idx = 0; position_to_hilite_idx < num_positions_to_hilite; ++position_to_hilite_idx)
100 {
101 const char * current_position_to_hilite = positions_to_hilite[position_to_hilite_idx].begin;
102
103 assert(current_position_to_hilite <= end);
104 assert(current_position_to_hilite >= begin);
105
106 out.write(pos, current_position_to_hilite - pos);
107
108 if (current_position_to_hilite == end)
109 {
110 out << "\033[41;1m \033[0m";
111 return;
112 }
113 else
114 {
115 size_t bytes_to_hilite = UTF8::seqLength(*current_position_to_hilite);
116
117 /// Bright on red background.
118 out << "\033[41;1m";
119 out.write(current_position_to_hilite, bytes_to_hilite);
120 out << "\033[0m";
121 pos = current_position_to_hilite + bytes_to_hilite;
122 }
123 }
124 out.write(pos, end - pos);
125}
126
127
128void writeQueryAroundTheError(

Callers 1

writeQueryAroundTheErrorFunction · 0.85

Calls 2

seqLengthFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected