[gnome-builder] location: add get_uri() helper
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] location: add get_uri() helper
- Date: Mon, 21 Dec 2015 08:08:26 +0000 (UTC)
commit 925e25580094f74f3b7f19ddb393c72781be12af
Author: Christian Hergert <chergert redhat com>
Date: Fri Dec 18 03:59:51 2015 -0800
location: add get_uri() helper
libide/ide-source-location.c | 24 ++++++++++++++++++++++++
libide/ide-source-location.h | 2 ++
2 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/libide/ide-source-location.c b/libide/ide-source-location.c
index 40be214..30cc7ff 100644
--- a/libide/ide-source-location.c
+++ b/libide/ide-source-location.c
@@ -166,3 +166,27 @@ ide_source_location_new (IdeFile *file,
return ret;
}
+
+/**
+ * ide_source_location_get_uri:
+ * @self: (in): A #IdeSourceLocation.
+ *
+ * Returns: (transfer full): A newly allocated #IdeUri.
+ */
+IdeUri *
+ide_source_location_get_uri (IdeSourceLocation *self)
+{
+ GFile *file;
+ IdeUri *ret;
+ gchar *fragment;
+
+ g_return_val_if_fail (self != NULL, NULL);
+
+ file = ide_file_get_file (self->file);
+ ret = ide_uri_new_from_file (file);
+ fragment = g_strdup_printf ("L%u_%u", self->line, self->line_offset);
+ ide_uri_set_fragment (ret, fragment);
+ g_free (fragment);
+
+ return ret;
+}
diff --git a/libide/ide-source-location.h b/libide/ide-source-location.h
index a2e37f5..34f0238 100644
--- a/libide/ide-source-location.h
+++ b/libide/ide-source-location.h
@@ -20,6 +20,7 @@
#define IDE_SOURCE_LOCATION_H
#include "ide-types.h"
+#include "ide-uri.h"
G_BEGIN_DECLS
@@ -36,6 +37,7 @@ guint ide_source_location_get_line (IdeSourceLocation *self)
guint ide_source_location_get_line_offset (IdeSourceLocation *self);
guint ide_source_location_get_offset (IdeSourceLocation *self);
IdeFile *ide_source_location_get_file (IdeSourceLocation *self);
+IdeUri *ide_source_location_get_uri (IdeSourceLocation *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (IdeSourceLocation, ide_source_location_unref)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]