diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-08-26 17:59:08 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-08-26 17:59:08 +0000 |
commit | d41e76cf758505ba1bc22ca88cf6d1f626298def (patch) | |
tree | 02630a9ec5362c89f24cf23ab93aa7cc50a1f297 /gcc/diagnostic-color.c | |
parent | 524a4c966c0e8f719887e7b84b5e1c7686e8872d (diff) |
Tweak to colors of fix-it hints
Previous, fix-it hints were printed using the color of the severity
of the diagnostic (magenta for warnings, red for errors, cyan for
notes).
This patch updates fix-it hints so that replacement text is printed in
green, to better distinguish the suggested improvement from
the current code. For example:
spellcheck-fields.cc:52:13: error: 'struct s' has no member named 'colour'; did you mean 'color'?
return ptr->colour; <<< RED
^~~~~~ <<< RED
color <<< GREEN
It makes sense for the underlinings that indicate deletions to
be printed in red, so the patch changes that also. For example:
diagnostic-test-show-locus-color.c:179:9: warning: example of a removal hint
int a;; <<< MAGENTA
^ <<< MAGENTA
- <<< RED
gcc/ChangeLog:
* diagnostic-color.c (color_dict): Add "fixit-insert" and
"fixit-delete".
(parse_gcc_colors): Update description of default GCC_COLORS.
* diagnostic-show-locus.c (colorizer::set_fixit_hint): Delete.
(colorizer::set_fixit_insert): New method.
(colorizer::set_fixit_delete): New method.
(colorizer::get_color_by_name): New method.
(colorizer::STATE_FIXIT_INSERT): New constant.
(colorizer::STATE_FIXIT_DELETE): New constant.
(class colorizer): Drop "_cs" suffix from fields. Delete "_ce"
fields in favor of new field "m_stop_color". Add fields
"m_fixit_insert" and "m_fixit_delete".
(colorizer::colorizer): Update for above changes. Replace
colorize_start calls with calls to get_color_by_name.
(colorizer::begin_state): Handle STATE_FIXIT_INSERT and
STATE_FIXIT_DELETE. Update for field renamings.
(colorizer::finish_state): Simplify by using m_stop_color,
rather than multiple identical "*_ce" fields.
(colorizer::get_color_by_name): New method.
(layout::print_any_fixits): Print insertions and replacements
using the "fixit-insert" color, and deletions using the
"fixit-delete" color.
* doc/invoke.texi (-fdiagnostics-color): Update description of
default GCC_COLORS, and of the supported capabilities.
gcc/testsuite/ChangeLog:
* gcc.dg/plugin/diagnostic-test-show-locus-color.c
(test_fixit_insert): Update expected output.
(test_fixit_remove): Likewise.
(test_fixit_replace): Likewise.
From-SVN: r239787
Diffstat (limited to 'gcc/diagnostic-color.c')
-rw-r--r-- | gcc/diagnostic-color.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/gcc/diagnostic-color.c b/gcc/diagnostic-color.c index f76c87ba1fa..42aa1b60226 100644 --- a/gcc/diagnostic-color.c +++ b/gcc/diagnostic-color.c @@ -168,6 +168,8 @@ static struct color_cap color_dict[] = { "range2", SGR_SEQ (COLOR_FG_BLUE), 6, false }, { "locus", SGR_SEQ (COLOR_BOLD), 5, false }, { "quote", SGR_SEQ (COLOR_BOLD), 5, false }, + { "fixit-insert", SGR_SEQ (COLOR_FG_GREEN), 12, false }, + { "fixit-delete", SGR_SEQ (COLOR_FG_RED), 12, false }, { NULL, NULL, 0, false } }; @@ -196,7 +198,9 @@ colorize_stop (bool show_color) } /* Parse GCC_COLORS. The default would look like: - GCC_COLORS='error=01;31:warning=01;35:note=01;36:range1=32:range2=34;locus=01:quote=01' + GCC_COLORS='error=01;31:warning=01;35:note=01;36:\ + range1=32:range2=34:locus=01:quote=01:\ + fixit-insert=32:fixit-delete=31' No character escaping is needed or supported. */ static bool parse_gcc_colors (void) |