Possibly a lazyweb question but is it possible to report diagnostics in FIR with a dynamically computed string? For example - a string that contains more specific context/references to the code being reported. All the examples I’ve seen just maintain a static mapping of diagnostics to message strings
d
dmitriy.novozhilov
12/05/2024, 3:06 PM
You can declare your diagnostic as diagnostics with parameters (up to 4) and configure its message with these arguments
Take, for example,
as placeholders for actual arguments
In each parameter you can use whatever type you want, just provide the proper renderer for them (renderer is a basically
(T) -> String
converter)
z
Zac Sweers
12/05/2024, 3:07 PM
Ohhhhh I see I see. Thanks!
d
dmitriy.novozhilov
12/05/2024, 3:07 PM
You can even create a diagnostic with a one
String
parameter, declare its message as
"{0}"
and compute the whole message at the reporting side