MCPcopy Create free account
hub / github.com/PRQL/prql / highlight

Function highlight

prqlc/prqlc/src/cli/highlight.rs:8–20  ·  view source on GitHub ↗

Highlight PRQL code printed to the terminal.

(tokens: &Tokens)

Source from the content-addressed store, hash-verified

6
7/// Highlight PRQL code printed to the terminal.
8pub(crate) fn highlight(tokens: &Tokens) -> String {
9 let mut output = String::new();
10 let mut last = 0;
11
12 for token in &tokens.0 {
13 let diff = token.span.start - last;
14 last = token.span.end;
15 output.push_str(&" ".repeat(diff));
16 output.push_str(&highlight_token_kind(&token.kind));
17 }
18
19 output
20}
21
22fn highlight_token_kind(token: &TokenKind) -> String {
23 // LineWrap is recursive with TokenKind, so we needed to split this function

Callers 1

executeMethod · 0.85

Calls 1

highlight_token_kindFunction · 0.85

Tested by

no test coverage detected