Support coloured messages in standard json #11507
Comments
|
We already have By the way, if we start colorizing standard JSON then I think that |
|
I'm not sure it is a good idea combining CLI options and standard json settings. |
|
color would be good |
|
@axic Do we actually need a setting inside Standard JSON? Description does not state that outright but I thought it was about colorizing JSON when it's displayed in the terminal. I.e. with But if it's supposed to work with solc-js too - do ANSI escape sequences embedded in strings inside JSON even make sense outside of the terminal? I see there are some JS libs for parsing them but if it's meant for JS tools, I think they would highly prefer some semantic markers that can be used to style them in a custom way rather than hard-coded colors. |
|
Can someone check how coloured strings would be displayed by e.g. remix or vs code? |
This is definitely not about colourising the JSON, but rather including colours in the
There are libraries which can turn ANSI escapes into HTML markup. I think Remix had something like that for some purposes, but I'm not 100% sure, @yann300? That is why this should be off by default, but tools can request it and process it.
They already have that by now using |
|
Looks like Hardhat wants to add error coloring so this could be useful to them: nomiclabs/hardhat#680. I asked if ANSI escapes would work for them. BTW, I have created a separate issue for
I just checked to see how it's formatted and expected to see some markup in there but looks like it just includes the error type and a code snippet with a marker pointing out the error: "formattedMessage": "ParserError: Source \"util.sol\" not found: File outside of allowed directories.\n --> contract.sol:1:1:\n |\n1 | import \"./util.sol\";\n | ^^^^^^^^^^^^^^^^^^^^\n\n",
"message": "Source \"util.sol\" not found: File outside of allowed directories.",I don't think it's that's easy to style unless you start actually parsing the messages. |
|
Can we talk about this in the next meeting? I as i was doing the prior work, i have some questions (/concerns). |
Do you mean also for the existing case when printing to the CLI? I think that should still be guarded by
If the IDEs are printing these messages as-is to the user, I think that does make sense - at first though I was a little scared/confused, because I may have thought that the IDE would not do that, because we provide source location offsets and the IDE could just highlight in the source code. I think enabling that by default might not be good due to existing software not expecting this (?). Instead of providing the error message twice, I'd suggest to add a boolean WRT |
|
I had a short call with @cameel, also to clarify my concerns and whether I am understanding the mission right here. I wanted to summarize now at least some thoughts we came up with in the call:
|
|
There was also a question of whether colored |
@cameel It was a typo in my message, I meant that with |
@christianparpart this issue is solely about standard json, let's please leave the CLI out of the discussion |
GUI tools can use all the other fields we have in the message. If they want nice formatting and tooltips, they should just build it themselves and ignore |
When we made the coloured output default (aka the new error message formatter), we did not enable it for standard json, only the CLI.
In the standard json we currently have all the components (
message,errorCode,sourceLocation, ...) and singleformattedMessagefield which has an output matching the CLI.We have a couple of options:
coloredFormattedMessageThe option to enable/disable it would need to be part of the settings in the input.
The text was updated successfully, but these errors were encountered: