From 25b29871cd2ac13ea45b3d3695711fa6b57c9b96 Mon Sep 17 00:00:00 2001
From: David Malcolm <dmalcolm@redhat.com>
Date: Fri, 18 Dec 2015 17:46:35 -0500
Subject: [PATCH 16/22] FIXME: tweak to colors of fix-it hints

---
 gcc/diagnostic-show-locus.c                              | 16 +++++++++++++++-
 .../gcc.dg/plugin/diagnostic-test-show-locus-color.c     | 15 +++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/gcc/diagnostic-show-locus.c b/gcc/diagnostic-show-locus.c
index e4198e9..75c49fb 100644
--- a/gcc/diagnostic-show-locus.c
+++ b/gcc/diagnostic-show-locus.c
@@ -79,7 +79,7 @@ class colorizer
 
   void set_range (int range_idx) { set_state (range_idx); }
   void set_normal_text () { set_state (STATE_NORMAL_TEXT); }
-  void set_fixit_hint () { set_state (0); }
+  void set_fixit_hint () { set_state (STATE_FIXIT_HINT); }
 
  private:
   void set_state (int state);
@@ -88,6 +88,7 @@ class colorizer
 
  private:
   static const int STATE_NORMAL_TEXT = -1;
+  static const int STATE_FIXIT_HINT  = -2;
 
   diagnostic_context *m_context;
   const diagnostic_info *m_diagnostic;
@@ -97,6 +98,8 @@ class colorizer
   const char *m_range1_cs;
   const char *m_range2_cs;
   const char *m_range_ce;
+  const char *m_fixit_hint_cs;
+  const char *m_fixit_hint_ce;
 };
 
 /* A point within a layout_range; similar to an expanded_location,
@@ -248,6 +251,9 @@ colorizer::colorizer (diagnostic_context *context,
   m_range1_cs = colorize_start (pp_show_color (context->printer), "range1");
   m_range2_cs = colorize_start (pp_show_color (context->printer), "range2");
   m_range_ce = colorize_stop (pp_show_color (context->printer));
+
+  m_fixit_hint_cs = colorize_start (pp_show_color (context->printer), "note");
+  m_fixit_hint_ce = colorize_stop (pp_show_color (context->printer));
 }
 
 /* The destructor for "colorize".  If colorization is on, print a code to
@@ -282,6 +288,10 @@ colorizer::begin_state (int state)
     case STATE_NORMAL_TEXT:
       break;
 
+    case STATE_FIXIT_HINT:
+      pp_string (m_context->printer, m_fixit_hint_cs);
+      break;
+
     case 0:
       /* Make range 0 be the same color as the "kind" text
 	 (error vs warning vs note).  */
@@ -316,6 +326,10 @@ colorizer::finish_state (int state)
     case STATE_NORMAL_TEXT:
       break;
 
+    case STATE_FIXIT_HINT:
+      pp_string (m_context->printer, m_fixit_hint_ce);
+      break;
+
     case 0:
       pp_string (m_context->printer, m_caret_ce);
       break;
diff --git a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
index ff2f4d4..99b4632 100644
--- a/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
+++ b/gcc/testsuite/gcc.dg/plugin/diagnostic-test-show-locus-color.c
@@ -160,8 +160,13 @@ void test_fixit_insert (void)
    int a[2][2] = { 0, 1 , 2, 3 }; /* { dg-warning "insertion hints" } */
 /* { dg-begin-multiline-output "" }
     int a[2][2] = { [01;35m[K0, 1[m[K , 2, 3 };
+<<<<<<< HEAD
                     [01;35m[K^~~~[m[K
                     [01;35m[K{[m[K   [01;35m[K}[m[K
+=======
+                    [01;35m[K^~~~
+                    [m[K[01;36m[K{[m[K   [01;36m[K}[m[K
+>>>>>>> 444fd9a... FIXME: tweak to colors of fix-it hints
    { dg-end-multiline-output "" } */
 #endif
 }
@@ -174,8 +179,13 @@ void test_fixit_remove (void)
   int a;; /* { dg-warning "example of a removal hint" } */
 /* { dg-begin-multiline-output "" }
    int a;[01;35m[K;[m[K
+<<<<<<< HEAD
          [01;35m[K^[m[K
          [01;35m[K-[m[K
+=======
+         [01;35m[K^
+         [m[K[01;36m[K-[m[K
+>>>>>>> 444fd9a... FIXME: tweak to colors of fix-it hints
    { dg-end-multiline-output "" } */
 #endif
 }
@@ -188,8 +198,13 @@ void test_fixit_replace (void)
   gtk_widget_showall (dlg); /* { dg-warning "example of a replacement hint" } */
 /* { dg-begin-multiline-output "" }
    [01;35m[Kgtk_widget_showall[m[K (dlg);
+<<<<<<< HEAD
    [01;35m[K^~~~~~~~~~~~~~~~~~[m[K
    [01;35m[Kgtk_widget_show_all[m[K
+=======
+   [01;35m[K^~~~~~~~~~~~~~~~~~
+   [m[K[01;36m[Kgtk_widget_show_all[m[K
+>>>>>>> 444fd9a... FIXME: tweak to colors of fix-it hints
    { dg-end-multiline-output "" } */
 #endif
 }
-- 
1.8.5.3

