[code-reflection] RFR: OpWriter.ColoringOption proposal [v3]
Paul Sandoz
psandoz at openjdk.org
Mon Sep 8 18:36:35 UTC 2025
On Mon, 8 Sep 2025 17:57:03 GMT, Adam Sotona <asotona at openjdk.org> wrote:
>> I propose `OpWriter` enables simple ANSI coloring based on `jdk.incubator.code.extern.OpWriter.COLOR` system property.
>>
>> ANSI coloring sample:
>> <img width="989" height="746" alt="ansi-coloring" src="https://github.com/user-attachments/assets/2025bcbe-6c6c-48ab-8ed5-67ff88b47fe6" />
>
> Adam Sotona has updated the pull request incrementally with one additional commit since the last revision:
>
> removed ColoringOption
> ANSI coloring is triggered by jdk.incubator.code.extern.OpWriter.COLOR property
Internal property is good, avoiding any API changes.
src/jdk.incubator.code/share/classes/jdk/incubator/code/extern/OpWriter.java line 342:
> 340:
> 341: static BiFunction<Class<? extends CodeItem>, String, String> getDyer() {
> 342: return Boolean.getBoolean("jdk.incubator.code.extern.OpWriter.COLOR") ? (itemType, text) -> "\033[3" +
Pull this out as a static final boolean.
src/jdk.incubator.code/share/classes/jdk/incubator/code/extern/OpWriter.java line 346:
> 344: itemType == Block.class ? '5': // purple
> 345: itemType == TypeElement.class ? '2': '1') // green : red
> 346: + "m" + text + "\033[0m" : (_, text) -> text;
Can you format to make the returning of the two functions clearer otherwise it is really hard to see where the first ends and the second starts e.g.:
return COLOR
? (itemType, text) -> ...
: (_, text) -> text;
-------------
PR Review: https://git.openjdk.org/babylon/pull/546#pullrequestreview-3197673168
PR Review Comment: https://git.openjdk.org/babylon/pull/546#discussion_r2331050519
PR Review Comment: https://git.openjdk.org/babylon/pull/546#discussion_r2331056218
More information about the babylon-dev
mailing list