On Mon, 26 Jan 2026 11:58:07 GMT, Maurizio Cimadamore <[email protected]>
wrote:
>> src/jdk.compiler/share/classes/com/sun/tools/javac/util/AbstractDiagnosticFormatter.java
>> line 237:
>>
>>> 235:
>>> StringUtils.toLowerCase(tag.name()));
>>> 236: }
>>> 237: else if (arg instanceof BindingPattern bp) {
>>
>> Have you tried playing with the Formattable interface? This is used by
>> diagnostic formatters as an escape hatch to provide custom formatting -- but
>> probably that's not good enough, as Formattable expects to just map an
>> object into a string w/o the help of a formatter -- which is clearly not the
>> case here. Maybe just having an abstract `String
>> format(AbstractDiagnosticFormatter)` in PatternDescription could be enough
>> -- then the code here doesn't have to worry about all possible cases.
>
> That said, in Rich formatter we also need to preprocess, so perhaps keeping
> the code as is here would be more symmetric...
I suppose overall I'm not entirely sure if, at this point, pattern descriptions
should be pattern descriptions, or already translated into some kind of
fragment -- because the code in formatters can deal with fragments recursively
very well -- but can do less so with objects.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27256#discussion_r2727338487