Appearance
| 1 | namespace Logging is | |
| 2 | use Ghul.Pipes | |
| 3 | ||
| 4 | // The kinds an inlay hint belongs to, and the gate that turns each on | |
| 5 | // or off process-wide (`--inlay <kind>` / `--no-inlay <kind>` from the | |
| 6 | // driver). A disabled kind is never recorded, so it costs nothing to | |
| 7 | // collect or serve - narrowing and definition-virtuality are on by | |
| 8 | // default, and the terminator kind (one hint per inferred statement | |
| 9 | // boundary) is off unless asked for. | |
| 10 | class INLAY_KINDS is | |
| 11 | // Every slug in the narrowing family shares this prefix: | |
| 12 | // narrowing-isa, narrowing-killed, narrowing-assign, ... | |
| 13 | NARROWING: string static => "narrowing" | |
| 14 | DEFINITION_VIRTUALITY: string static => "definition-virtuality" | |
| 15 | TERMINATOR: string static => "terminator" | |
| 16 | ||
| 17 | ALL: Collections.List[string] static => | |
| 18 | Collections.LIST([NARROWING, DEFINITION_VIRTUALITY, TERMINATOR]) | |
| 19 | ||
| 20 | // The kind an inlay's code belongs to, by slug prefix. An unknown | |
| 21 | // code has no kind to gate and answers null - such a hint is | |
| 22 | // always collected. | |
| 23 | for_code(code: string?) -> string? static => | |
| 24 | if !code? then | |
| 25 | null | |
| 26 | elif code.starts_with(NARROWING) then | |
| 27 | NARROWING | |
| 28 | elif code.starts_with(DEFINITION_VIRTUALITY) then | |
| 29 | DEFINITION_VIRTUALITY | |
| 30 | elif code.starts_with(TERMINATOR) then | |
| 31 | TERMINATOR | |
| 32 | else | |
| 33 | null | |
| 34 | fi | |
| 35 | ||
| 36 | is_known(kind: string) -> bool static => ALL |> any(k => k =~ kind) | |
| 37 | si | |
| 38 | si |