[gnome-builder/wip/libide: 141/153] libide: add getters for source ranges



commit a96385bda047e4cc62ce58a97bce40b149bd4729
Author: Christian Hergert <christian hergert me>
Date:   Thu Feb 12 16:34:14 2015 -0800

    libide: add getters for source ranges

 libide/ide-diagnostic.c |   31 +++++++++++++++++++++++++++++++
 1 files changed, 31 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-diagnostic.c b/libide/ide-diagnostic.c
index d401392..d3c5868 100644
--- a/libide/ide-diagnostic.c
+++ b/libide/ide-diagnostic.c
@@ -72,6 +72,37 @@ ide_diagnostic_get_text (IdeDiagnostic *self)
   return self->text;
 }
 
+guint
+ide_diagnostic_get_num_ranges (IdeDiagnostic *self)
+{
+  g_return_val_if_fail (self, 0);
+
+  return self->ranges ? self->ranges->len : 0;
+}
+
+/**
+ * ide_diagnostic_get_range:
+ *
+ * Retrieves the range found at @index. It is a programming error to call this
+ * function with a value greater or equal to ide_diagnostic_get_num_ranges().
+ *
+ * Returns: (transfer none) (nullable): An #IdeSourceRange
+ */
+IdeSourceRange *
+ide_diagnostic_get_range (IdeDiagnostic *self,
+                          guint          index)
+{
+  g_return_val_if_fail (self, NULL);
+
+  if (self->ranges)
+    {
+      if (index < self->ranges->len)
+        return g_ptr_array_index (self->ranges, index);
+    }
+
+  return NULL;
+}
+
 IdeDiagnostic *
 _ide_diagnostic_new (IdeDiagnosticSeverity  severity,
                      const gchar           *text)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]