aboutsummaryrefslogtreecommitdiff
path: root/libcpp
diff options
context:
space:
mode:
Diffstat (limited to 'libcpp')
-rw-r--r--libcpp/ChangeLog13
-rw-r--r--libcpp/include/line-map.h34
-rw-r--r--libcpp/line-map.c54
3 files changed, 101 insertions, 0 deletions
diff --git a/libcpp/ChangeLog b/libcpp/ChangeLog
index 37825f5..a753033 100644
--- a/libcpp/ChangeLog
+++ b/libcpp/ChangeLog
@@ -1,3 +1,16 @@
+2016-08-30 David Malcolm <dmalcolm@redhat.com>
+
+ * include/line-map.h (rich_location::add_fixit_insert): Add
+ comments. Add overload omitting the source_location param.
+ (rich_location::add_fixit_remove): Add comments. Add overloads
+ omitting the range, and accepting a source_location.
+ (rich_location::add_fixit_replace): Likewise.
+ * line-map.c (rich_location::add_fixit_insert): Add comments. Add
+ overload omitting the source_location param.
+ (rich_location::add_fixit_remove): Add comments. Add overloads
+ omitting the range, and accepting a source_location.
+ (rich_location::add_fixit_replace): Likewise.
+
2016-08-26 David Malcolm <dmalcolm@redhat.com>
* include/line-map.h (get_pure_location): New decl.
diff --git a/libcpp/include/line-map.h b/libcpp/include/line-map.h
index d9c31de..122e474 100644
--- a/libcpp/include/line-map.h
+++ b/libcpp/include/line-map.h
@@ -1401,13 +1401,47 @@ class rich_location
override_column (int column);
/* Fix-it hints. */
+
+ /* Methods for adding insertion fix-it hints. */
+
+ /* Suggest inserting NEW_CONTENT at the primary range's caret. */
+ void
+ add_fixit_insert (const char *new_content);
+
+ /* Suggest inserting NEW_CONTENT at WHERE. */
void
add_fixit_insert (source_location where,
const char *new_content);
+ /* Methods for adding removal fix-it hints. */
+
+ /* Suggest removing the content covered by range 0. */
+ void
+ add_fixit_remove ();
+
+ /* Suggest removing the content covered between the start and finish
+ of WHERE. */
+ void
+ add_fixit_remove (source_location where);
+
+ /* Suggest removing the content covered by SRC_RANGE. */
void
add_fixit_remove (source_range src_range);
+ /* Methods for adding "replace" fix-it hints. */
+
+ /* Suggest replacing the content covered by range 0 with NEW_CONTENT. */
+ void
+ add_fixit_replace (const char *new_content);
+
+ /* Suggest replacing the content between the start and finish of
+ WHERE with NEW_CONTENT. */
+ void
+ add_fixit_replace (source_location where,
+ const char *new_content);
+
+ /* Suggest replacing the content covered by SRC_RANGE with
+ NEW_CONTENT. */
void
add_fixit_replace (source_range src_range,
const char *new_content);
diff --git a/libcpp/line-map.c b/libcpp/line-map.c
index f5b1586..3189326 100644
--- a/libcpp/line-map.c
+++ b/libcpp/line-map.c
@@ -2092,6 +2092,17 @@ rich_location::set_range (line_maps * /*set*/, unsigned int idx,
m_have_expanded_location = false;
}
+/* Methods for adding insertion fix-it hints. */
+
+/* Add a fixit-hint, suggesting insertion of NEW_CONTENT
+ at the primary range's caret location. */
+
+void
+rich_location::add_fixit_insert (const char *new_content)
+{
+ add_fixit_insert (get_loc (), new_content);
+}
+
/* Add a fixit-hint, suggesting insertion of NEW_CONTENT
at WHERE. */
@@ -2109,6 +2120,27 @@ rich_location::add_fixit_insert (source_location where,
= new fixit_insert (where, new_content);
}
+/* Methods for adding removal fix-it hints. */
+
+/* Add a fixit-hint, suggesting removal of the content covered
+ by range 0. */
+
+void
+rich_location::add_fixit_remove ()
+{
+ add_fixit_remove (get_loc ());
+}
+
+/* Add a fixit-hint, suggesting removal of the content between
+ the start and finish of WHERE. */
+
+void
+rich_location::add_fixit_remove (source_location where)
+{
+ source_range range = get_range_from_loc (m_line_table, where);
+ add_fixit_remove (range);
+}
+
/* Add a fixit-hint, suggesting removal of the content at
SRC_RANGE. */
@@ -2156,6 +2188,28 @@ column_before_p (line_maps *set, source_location a, source_location b)
return column_b == column_a + 1;
}
+/* Add a fixit-hint, suggesting replacement of the content covered
+ by range 0 with NEW_CONTENT. */
+
+void
+rich_location::add_fixit_replace (const char *new_content)
+{
+ add_fixit_replace (get_loc (), new_content);
+}
+
+/* Methods for adding "replace" fix-it hints. */
+
+/* Add a fixit-hint, suggesting replacement of the content between
+ the start and finish of WHERE with NEW_CONTENT. */
+
+void
+rich_location::add_fixit_replace (source_location where,
+ const char *new_content)
+{
+ source_range range = get_range_from_loc (m_line_table, where);
+ add_fixit_replace (range, new_content);
+}
+
/* Add a fixit-hint, suggesting replacement of the content at
SRC_RANGE with NEW_CONTENT. */