Tweak to colors of fix-it hints
commitdf4248fb8e21f50c381161ccf96a0f65a5b4dac7
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Aug 2016 17:59:08 +0000 (26 17:59 +0000)
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>
Fri, 26 Aug 2016 17:59:08 +0000 (26 17:59 +0000)
tree02630a9ec5362c89f24cf23ab93aa7cc50a1f297
parent377da6e4008886b3c8e0a453e662d7f1cf6ae045
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.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@239787 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/diagnostic-color.c
gcc/diagnostic-show-locus.c
gcc/doc/invoke.texi
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c