[gnome-builder] storage: move persistent map and builder to libide



commit 5acbfa60fc2730e699cac2a0a6c7abcc0a69f610
Author: Christian Hergert <chergert redhat com>
Date:   Sat Mar 24 15:40:49 2018 -0700

    storage: move persistent map and builder to libide
    
    This can be used by other plugins wanting persistent storage of
    various indexed data, so to facilitate that, move it to libide
    instead of hidden away in the code-index plugin.

 src/libide/ide.h                                           |  2 ++
 src/libide/meson.build                                     |  1 +
 .../storage}/ide-persistent-map-builder.c                  |  9 +++++++--
 .../storage}/ide-persistent-map-builder.h                  | 12 ++++++++++--
 .../code-index => libide/storage}/ide-persistent-map.c     |  8 ++++++--
 .../code-index => libide/storage}/ide-persistent-map.h     |  9 +++++++++
 src/libide/storage/meson.build                             | 14 ++++++++++++++
 src/plugins/code-index/ide-code-index-builder.c            |  1 -
 src/plugins/code-index/ide-code-index-index.c              |  1 -
 src/plugins/code-index/meson.build                         |  4 ----
 10 files changed, 49 insertions(+), 12 deletions(-)
---
diff --git a/src/libide/ide.h b/src/libide/ide.h
index d06c1c8cd..83c0c8257 100644
--- a/src/libide/ide.h
+++ b/src/libide/ide.h
@@ -162,6 +162,8 @@ G_BEGIN_DECLS
 #include "sourceview/ide-source-map.h"
 #include "sourceview/ide-source-style-scheme.h"
 #include "sourceview/ide-source-view.h"
+#include "storage/ide-persistent-map.h"
+#include "storage/ide-persistent-map-builder.h"
 #include "subprocess/ide-subprocess.h"
 #include "subprocess/ide-subprocess-launcher.h"
 #include "symbols/ide-code-indexer.h"
diff --git a/src/libide/meson.build b/src/libide/meson.build
index f6d99b57c..b3e29ded3 100644
--- a/src/libide/meson.build
+++ b/src/libide/meson.build
@@ -84,6 +84,7 @@ subdir('runtimes')
 subdir('search')
 subdir('snippets')
 subdir('sourceview')
+subdir('storage')
 subdir('subprocess')
 subdir('symbols')
 subdir('template')
diff --git a/src/plugins/code-index/ide-persistent-map-builder.c 
b/src/libide/storage/ide-persistent-map-builder.c
similarity index 97%
rename from src/plugins/code-index/ide-persistent-map-builder.c
rename to src/libide/storage/ide-persistent-map-builder.c
index de230dd1f..766d4fb89 100644
--- a/src/plugins/code-index/ide-persistent-map-builder.c
+++ b/src/libide/storage/ide-persistent-map-builder.c
@@ -1,6 +1,7 @@
 /* ide-persistent-map-builder.c
  *
  * Copyright 2017 Anoop Chandu <anoopchandu96 gmail com>
+ * Copyright 2017-2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,10 +19,12 @@
 
 #define G_LOG_DOMAIN "ide-persistent-map-builder"
 
-#include <ide.h>
+#include "config.h"
+
 #include <string.h>
 
-#include "ide-persistent-map-builder.h"
+#include "storage/ide-persistent-map-builder.h"
+#include "threading/ide-task.h"
 
 typedef struct
 {
@@ -264,6 +267,7 @@ ide_persistent_map_builder_write (IdePersistentMapBuilder  *self,
   task = ide_task_new (self, cancellable, NULL, NULL);
   ide_task_set_source_tag (task, ide_persistent_map_builder_write);
   ide_task_set_priority (task, io_priority);
+  ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
   ide_persistent_map_builder_write_worker (task, self, state, cancellable);
 
   build_state_free (state);
@@ -292,6 +296,7 @@ ide_persistent_map_builder_write_async (IdePersistentMapBuilder *self,
   task = ide_task_new (self, cancellable, callback, user_data);
   ide_task_set_priority (task, io_priority);
   ide_task_set_source_tag (task, ide_persistent_map_builder_write_async);
+  ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
   ide_task_set_task_data (task, g_steal_pointer (&self->state), build_state_free);
   ide_task_run_in_thread (task, ide_persistent_map_builder_write_worker);
 }
diff --git a/src/plugins/code-index/ide-persistent-map-builder.h 
b/src/libide/storage/ide-persistent-map-builder.h
similarity index 94%
rename from src/plugins/code-index/ide-persistent-map-builder.h
rename to src/libide/storage/ide-persistent-map-builder.h
index c4501853e..99cd59d43 100644
--- a/src/plugins/code-index/ide-persistent-map-builder.h
+++ b/src/libide/storage/ide-persistent-map-builder.h
@@ -16,36 +16,44 @@
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-#include <glib-object.h>
+#pragma once
+
 #include <gio/gio.h>
 
-#pragma once
+#include "ide-version-macros.h"
 
 G_BEGIN_DECLS
 
 #define IDE_TYPE_PERSISTENT_MAP_BUILDER (ide_persistent_map_builder_get_type ())
 
+IDE_AVAILABLE_IN_3_30
 G_DECLARE_FINAL_TYPE (IdePersistentMapBuilder, ide_persistent_map_builder, IDE, PERSISTENT_MAP_BUILDER, 
GObject)
 
+IDE_AVAILABLE_IN_3_30
 IdePersistentMapBuilder *ide_persistent_map_builder_new                (void);
+IDE_AVAILABLE_IN_3_30
 void                     ide_persistent_map_builder_insert             (IdePersistentMapBuilder  *self,
                                                                         const gchar              *key,
                                                                         GVariant                 *value,
                                                                         gboolean                  replace);
+IDE_AVAILABLE_IN_3_30
 void                     ide_persistent_map_builder_set_metadata_int64 (IdePersistentMapBuilder  *self,
                                                                         const gchar              *key,
                                                                         gint64                    value);
+IDE_AVAILABLE_IN_3_30
 gboolean                 ide_persistent_map_builder_write              (IdePersistentMapBuilder  *self,
                                                                         GFile                    
*destination,
                                                                         gint                      
io_priority,
                                                                         GCancellable             
*cancellable,
                                                                         GError                  **error);
+IDE_AVAILABLE_IN_3_30
 void                     ide_persistent_map_builder_write_async        (IdePersistentMapBuilder  *self,
                                                                         GFile                    
*destination,
                                                                         gint                      
io_priority,
                                                                         GCancellable             
*cancellable,
                                                                         GAsyncReadyCallback       callback,
                                                                         gpointer                  user_data);
+IDE_AVAILABLE_IN_3_30
 gboolean                 ide_persistent_map_builder_write_finish       (IdePersistentMapBuilder  *self,
                                                                         GAsyncResult             *result,
                                                                         GError                  **error);
diff --git a/src/plugins/code-index/ide-persistent-map.c b/src/libide/storage/ide-persistent-map.c
similarity index 97%
rename from src/plugins/code-index/ide-persistent-map.c
rename to src/libide/storage/ide-persistent-map.c
index e8bd28c0a..a4178ef2a 100644
--- a/src/plugins/code-index/ide-persistent-map.c
+++ b/src/libide/storage/ide-persistent-map.c
@@ -1,6 +1,7 @@
 /* ide-persistent-map.c
  *
  * Copyright 2017 Anoop Chandu <anoopchandu96 gmail com>
+ * Copyright 2017-2018 Christian Hergert <chergert redhat com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -18,9 +19,10 @@
 
 #define G_LOG_DOMAIN "ide-persistent-map"
 
-#include <ide.h>
+#include "config.h"
 
-#include "ide-persistent-map.h"
+#include "storage/ide-persistent-map.h"
+#include "threading/ide-task.h"
 
 typedef struct
 {
@@ -187,6 +189,7 @@ ide_persistent_map_load_file (IdePersistentMap *self,
   task = ide_task_new (self, cancellable, NULL, NULL);
   ide_task_set_source_tag (task, ide_persistent_map_load_file);
   ide_task_set_priority (task, G_PRIORITY_LOW);
+  ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
   ide_persistent_map_load_file_worker (task, self, file, cancellable);
 
   return ide_task_propagate_boolean (task, error);
@@ -211,6 +214,7 @@ ide_persistent_map_load_file_async (IdePersistentMap    *self,
   task = ide_task_new (self, cancellable, callback, user_data);
   ide_task_set_source_tag (task, ide_persistent_map_load_file_async);
   ide_task_set_priority (task, G_PRIORITY_LOW);
+  ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
   ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
   ide_task_run_in_thread (task, ide_persistent_map_load_file_worker);
 }
diff --git a/src/plugins/code-index/ide-persistent-map.h b/src/libide/storage/ide-persistent-map.h
similarity index 93%
rename from src/plugins/code-index/ide-persistent-map.h
rename to src/libide/storage/ide-persistent-map.h
index abc8b4fd3..2222f9785 100644
--- a/src/plugins/code-index/ide-persistent-map.h
+++ b/src/libide/storage/ide-persistent-map.h
@@ -20,24 +20,33 @@
 
 #include <gio/gio.h>
 
+#include "ide-version-macros.h"
+
 #define IDE_TYPE_PERSISTENT_MAP (ide_persistent_map_get_type ())
 
+IDE_AVAILABLE_IN_3_30
 G_DECLARE_FINAL_TYPE (IdePersistentMap, ide_persistent_map, IDE, PERSISTENT_MAP, GObject)
 
+IDE_AVAILABLE_IN_3_30
 IdePersistentMap *ide_persistent_map_new                        (void);
+IDE_AVAILABLE_IN_3_30
 gboolean          ide_persistent_map_load_file                  (IdePersistentMap     *self,
                                                                  GFile                *file,
                                                                  GCancellable         *cancellable,
                                                                  GError              **error);
+IDE_AVAILABLE_IN_3_30
 void              ide_persistent_map_load_file_async            (IdePersistentMap     *self,
                                                                  GFile                *file,
                                                                  GCancellable         *cancellable,
                                                                  GAsyncReadyCallback   callback,
                                                                  gpointer              user_data);
+IDE_AVAILABLE_IN_3_30
 gboolean          ide_persistent_map_load_file_finish           (IdePersistentMap     *self,
                                                                  GAsyncResult         *result,
                                                                  GError              **error);
+IDE_AVAILABLE_IN_3_30
 GVariant         *ide_persistent_map_lookup_value               (IdePersistentMap     *self,
                                                                  const gchar          *key);
+IDE_AVAILABLE_IN_3_30
 gint64            ide_persistent_map_builder_get_metadata_int64 (IdePersistentMap     *self,
                                                                  const gchar          *key);
diff --git a/src/libide/storage/meson.build b/src/libide/storage/meson.build
new file mode 100644
index 000000000..6923482a4
--- /dev/null
+++ b/src/libide/storage/meson.build
@@ -0,0 +1,14 @@
+storage_headers = [
+  'ide-persistent-map.h',
+  'ide-persistent-map-builder.h',
+]
+
+storage_sources = [
+  'ide-persistent-map.c',
+  'ide-persistent-map-builder.c',
+]
+
+libide_public_headers += files(storage_headers)
+libide_public_sources += files(storage_sources)
+
+install_headers(storage_headers, subdir: join_paths(libide_header_subdir, 'storage'))
diff --git a/src/plugins/code-index/ide-code-index-builder.c b/src/plugins/code-index/ide-code-index-builder.c
index 0a7c23925..3fabde84f 100644
--- a/src/plugins/code-index/ide-code-index-builder.c
+++ b/src/plugins/code-index/ide-code-index-builder.c
@@ -23,7 +23,6 @@
 #include <string.h>
 
 #include "ide-code-index-builder.h"
-#include "ide-persistent-map-builder.h"
 
 struct _IdeCodeIndexBuilder
 {
diff --git a/src/plugins/code-index/ide-code-index-index.c b/src/plugins/code-index/ide-code-index-index.c
index 7067f20fd..324d94629 100644
--- a/src/plugins/code-index/ide-code-index-index.c
+++ b/src/plugins/code-index/ide-code-index-index.c
@@ -23,7 +23,6 @@
 
 #include "ide-code-index-search-result.h"
 #include "ide-code-index-index.h"
-#include "ide-persistent-map.h"
 
 /*
  * This class will store index of all directories and will have a map of
diff --git a/src/plugins/code-index/meson.build b/src/plugins/code-index/meson.build
index e4b66e63c..290d8cf77 100644
--- a/src/plugins/code-index/meson.build
+++ b/src/plugins/code-index/meson.build
@@ -20,10 +20,6 @@ code_index_sources = [
   'ide-code-index-service.h',
   'ide-code-index-symbol-resolver.c',
   'ide-code-index-symbol-resolver.h',
-  'ide-persistent-map-builder.c',
-  'ide-persistent-map-builder.h',
-  'ide-persistent-map.c',
-  'ide-persistent-map.h',
 ]
 
 gnome_builder_plugins_sources += files(code_index_sources)


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