[gnome-builder: 64/139] clang: port to libide-foundry and libide-code
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder: 64/139] clang: port to libide-foundry and libide-code
- Date: Thu, 10 Jan 2019 04:22:42 +0000 (UTC)
commit 6028b15baf55049ac23af013fda649e4139af4c2
Author: Christian Hergert <chergert redhat com>
Date: Wed Jan 9 17:06:00 2019 -0800
clang: port to libide-foundry and libide-code
This ports the clang plugin to use the new abstractions and concepts in
the libide-foundry and libide-code static libraries. It continues to use
a subprocess to perform operations.
src/plugins/clang/clang-plugin.c | 15 ++-
src/plugins/clang/clang.gresource.xml | 2 +-
src/plugins/clang/clang.plugin | 24 ++--
src/plugins/clang/gnome-builder-clang.c | 4 +-
src/plugins/clang/ide-clang-client.c | 73 ++++++-------
src/plugins/clang/ide-clang-client.h | 2 +-
src/plugins/clang/ide-clang-code-index-entries.c | 2 +-
src/plugins/clang/ide-clang-code-index-entries.h | 2 +-
src/plugins/clang/ide-clang-code-indexer.c | 18 ++-
src/plugins/clang/ide-clang-code-indexer.h | 2 +-
src/plugins/clang/ide-clang-completion-item.c | 25 +++--
src/plugins/clang/ide-clang-completion-item.h | 3 +-
src/plugins/clang/ide-clang-completion-provider.c | 17 ++-
src/plugins/clang/ide-clang-completion-provider.h | 2 +-
src/plugins/clang/ide-clang-diagnostic-provider.c | 20 ++--
src/plugins/clang/ide-clang-diagnostic-provider.h | 2 +-
src/plugins/clang/ide-clang-highlighter.c | 21 ++--
src/plugins/clang/ide-clang-highlighter.h | 2 +-
src/plugins/clang/ide-clang-preferences-addin.c | 3 +-
src/plugins/clang/ide-clang-proposals.c | 23 ++--
src/plugins/clang/ide-clang-proposals.h | 2 +-
src/plugins/clang/ide-clang-rename-provider.c | 43 ++++----
src/plugins/clang/ide-clang-rename-provider.h | 2 +-
src/plugins/clang/ide-clang-symbol-node.c | 26 ++---
src/plugins/clang/ide-clang-symbol-node.h | 5 +-
src/plugins/clang/ide-clang-symbol-resolver.c | 81 +++++++-------
src/plugins/clang/ide-clang-symbol-resolver.h | 2 +-
src/plugins/clang/ide-clang-symbol-tree.c | 10 +-
src/plugins/clang/ide-clang-symbol-tree.h | 7 +-
src/plugins/clang/ide-clang-util.h | 30 ++---
src/plugins/clang/ide-clang.c | 127 +++++++++-------------
src/plugins/clang/ide-clang.h | 2 +-
src/plugins/clang/meson.build | 31 +++---
33 files changed, 301 insertions(+), 329 deletions(-)
---
diff --git a/src/plugins/clang/clang-plugin.c b/src/plugins/clang/clang-plugin.c
index fe27dbff8..c8cac1bba 100644
--- a/src/plugins/clang/clang-plugin.c
+++ b/src/plugins/clang/clang-plugin.c
@@ -18,8 +18,14 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
+#define G_LOG_DOMAIN "clang-plugin"
+
+#include "config.h"
+
#include <libpeas/peas.h>
-#include <ide.h>
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-gui.h>
#include "ide-clang-client.h"
#include "ide-clang-code-indexer.h"
@@ -33,8 +39,8 @@
#include "ide-clang-symbol-resolver.h"
#include "ide-clang-symbol-tree.h"
-void
-ide_clang_register_types (PeasObjectModule *module)
+_IDE_EXTERN void
+_ide_clang_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
IDE_TYPE_CODE_INDEXER,
@@ -45,9 +51,6 @@ ide_clang_register_types (PeasObjectModule *module)
peas_object_module_register_extension_type (module,
IDE_TYPE_SYMBOL_RESOLVER,
IDE_TYPE_CLANG_SYMBOL_RESOLVER);
- peas_object_module_register_extension_type (module,
- IDE_TYPE_SERVICE,
- IDE_TYPE_CLANG_CLIENT);
peas_object_module_register_extension_type (module,
IDE_TYPE_DIAGNOSTIC_PROVIDER,
IDE_TYPE_CLANG_DIAGNOSTIC_PROVIDER);
diff --git a/src/plugins/clang/clang.gresource.xml b/src/plugins/clang/clang.gresource.xml
index a2a31083f..0514f91bb 100644
--- a/src/plugins/clang/clang.gresource.xml
+++ b/src/plugins/clang/clang.gresource.xml
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<gresources>
- <gresource prefix="/org/gnome/builder/plugins">
+ <gresource prefix="/plugins/clang">
<file>clang.plugin</file>
</gresource>
</gresources>
diff --git a/src/plugins/clang/clang.plugin b/src/plugins/clang/clang.plugin
index a016adc73..9dbcfa80e 100644
--- a/src/plugins/clang/clang.plugin
+++ b/src/plugins/clang/clang.plugin
@@ -1,17 +1,19 @@
[Plugin]
-Module=clang-plugin
-Name=Clang
-Description=Provides integration with Clang
Authors=Christian Hergert <christian hergert me>
-Copyright=Copyright © 2015 Christian Hergert
Builtin=true
-Embedded=ide_clang_register_types
+Copyright=Copyright © 2015 Christian Hergert
+Description=Provides integration with Clang
+Depends=editor;
+Embedded=_ide_clang_register_types
+Hidden=true
+Module=clang
+Name=Clang
+X-Code-Indexer-Languages-Priority=100
+X-Code-Indexer-Languages=c,chdr,cpp,cpphdr,objc
X-Completion-Provider-Languages=c,chdr,cpp,cpphdr,objc
-X-Highlighter-Languages=c,chdr,cpp,cpphdr,objc
+X-Diagnostic-Provider-Languages-Priority=100
+X-Diagnostic-Provider-Languages=c,chdr,cpp,cpphdr,objc
X-Highlighter-Languages-Priority=100
-X-Symbol-Resolver-Languages=c,chdr,cpp,cpphdr,objc
+X-Highlighter-Languages=c,chdr,cpp,cpphdr,objc
X-Symbol-Resolver-Languages-Priority=100
-X-Diagnostic-Provider-Languages=c,chdr,cpp,cpphdr,objc
-X-Diagnostic-Provider-Languages-Priority=100
-X-Code-Indexer-Languages=c,chdr,cpp,cpphdr,objc
-X-Code-Indexer-Languages-Priority=100
+X-Symbol-Resolver-Languages=c,chdr,cpp,cpphdr,objc
diff --git a/src/plugins/clang/gnome-builder-clang.c b/src/plugins/clang/gnome-builder-clang.c
index 99fbedf7c..f16de61c1 100644
--- a/src/plugins/clang/gnome-builder-clang.c
+++ b/src/plugins/clang/gnome-builder-clang.c
@@ -29,7 +29,7 @@
#include <gio/gunixoutputstream.h>
#include <glib-unix.h>
#include <jsonrpc-glib.h>
-#include <ide.h>
+#include <libide-code.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
@@ -422,7 +422,7 @@ handle_diagnose_cb (IdeClang *clang,
return;
}
- IDE_PTR_ARRAY_SET_FREE_FUNC (diagnostics, ide_diagnostic_unref);
+ IDE_PTR_ARRAY_SET_FREE_FUNC (diagnostics, ide_object_unref_and_destroy);
g_variant_builder_init (&builder, G_VARIANT_TYPE ("aa{sv}"));
diff --git a/src/plugins/clang/ide-clang-client.c b/src/plugins/clang/ide-clang-client.c
index 8dbf346bb..07eb43934 100644
--- a/src/plugins/clang/ide-clang-client.c
+++ b/src/plugins/clang/ide-clang-client.c
@@ -25,6 +25,9 @@
#include <gio/gunixinputstream.h>
#include <gio/gunixoutputstream.h>
#include <glib-unix.h>
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-vcs.h>
#include <jsonrpc-glib.h>
#include "ide-clang-client.h"
@@ -58,10 +61,7 @@ typedef struct
gulong cancel_id;
} Call;
-static void service_iface_init (IdeServiceInterface *iface);
-
-G_DEFINE_TYPE_EXTENDED (IdeClangClient, ide_clang_client, IDE_TYPE_OBJECT, 0,
- G_IMPLEMENT_INTERFACE (IDE_TYPE_SERVICE, service_iface_init))
+G_DEFINE_TYPE (IdeClangClient, ide_clang_client, IDE_TYPE_OBJECT)
static void
call_free (gpointer data)
@@ -104,7 +104,7 @@ ide_clang_client_sync_buffers (IdeClangClient *self)
*/
context = ide_object_get_context (IDE_OBJECT (self));
- ufs = ide_context_get_unsaved_files (context);
+ ufs = ide_unsaved_files_from_context (context);
ar = ide_unsaved_files_to_array (ufs);
IDE_PTR_ARRAY_SET_FREE_FUNC (ar, ide_unsaved_file_unref);
@@ -297,8 +297,7 @@ ide_clang_client_buffer_saved (IdeClangClient *self,
IdeBuffer *buffer,
IdeBufferManager *bufmgr)
{
- IdeFile *file;
- GFile *gfile;
+ GFile *file;
g_assert (IDE_IS_CLANG_CLIENT (self));
g_assert (IDE_BUFFER (buffer));
@@ -311,20 +310,20 @@ ide_clang_client_buffer_saved (IdeClangClient *self,
*/
file = ide_buffer_get_file (buffer);
- gfile = ide_file_get_file (file);
if (self->seq_by_file != NULL)
- g_hash_table_remove (self->seq_by_file, gfile);
+ g_hash_table_remove (self->seq_by_file, file);
/* skip if thereis no peer */
if (self->rpc_client == NULL)
return;
- if (gfile != NULL)
- ide_clang_client_set_buffer_async (self, gfile, NULL, NULL, NULL, NULL);
+ if (file != NULL)
+ ide_clang_client_set_buffer_async (self, file, NULL, NULL, NULL, NULL);
}
static void
-ide_clang_client_constructed (GObject *object)
+ide_clang_client_parent_set (IdeObject *object,
+ IdeObject *parent)
{
IdeClangClient *self = (IdeClangClient *)object;
g_autoptr(IdeSubprocessLauncher) launcher = NULL;
@@ -334,10 +333,16 @@ ide_clang_client_constructed (GObject *object)
IdeVcs *vcs;
GFile *workdir;
+ g_assert (IDE_IS_CLANG_CLIENT (self));
+ g_assert (!parent || IDE_IS_OBJECT (parent));
+
+ if (parent == NULL)
+ return;
+
context = ide_object_get_context (IDE_OBJECT (self));
- bufmgr = ide_context_get_buffer_manager (context);
- vcs = ide_context_get_vcs (context);
- workdir = ide_vcs_get_working_directory (vcs);
+ bufmgr = ide_buffer_manager_from_context (context);
+ vcs = ide_vcs_from_context (context);
+ workdir = ide_vcs_get_workdir (vcs);
self->root_uri = g_object_ref (workdir);
@@ -376,12 +381,10 @@ ide_clang_client_constructed (GObject *object)
G_CALLBACK (ide_clang_client_buffer_saved),
self,
G_CONNECT_SWAPPED);
-
- G_OBJECT_CLASS (ide_clang_client_parent_class)->constructed (object);
}
static void
-ide_clang_client_dispose (GObject *object)
+ide_clang_client_destroy (IdeObject *object)
{
IdeClangClient *self = (IdeClangClient *)object;
GList *queued;
@@ -418,7 +421,7 @@ ide_clang_client_dispose (GObject *object)
g_list_free_full (queued, g_object_unref);
- G_OBJECT_CLASS (ide_clang_client_parent_class)->dispose (object);
+ IDE_OBJECT_CLASS (ide_clang_client_parent_class)->destroy (object);
}
static void
@@ -442,10 +445,12 @@ static void
ide_clang_client_class_init (IdeClangClientClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ IdeObjectClass *i_object_class = IDE_OBJECT_CLASS (klass);
- object_class->constructed = ide_clang_client_constructed;
- object_class->dispose = ide_clang_client_dispose;
object_class->finalize = ide_clang_client_finalize;
+
+ i_object_class->parent_set = ide_clang_client_parent_set;
+ i_object_class->destroy = ide_clang_client_destroy;;
}
static void
@@ -817,7 +822,7 @@ ide_clang_client_find_nearest_scope_cb (GObject *object,
else
ide_task_return_pointer (task,
g_steal_pointer (&ret),
- (GDestroyNotify)ide_symbol_unref);
+ g_object_unref);
}
void
@@ -912,7 +917,7 @@ ide_clang_client_locate_symbol_cb (GObject *object,
else
ide_task_return_pointer (task,
g_steal_pointer (&ret),
- (GDestroyNotify)ide_symbol_unref);
+ g_object_unref);
}
void
@@ -985,20 +990,18 @@ ide_clang_client_get_symbol_tree_cb (GObject *object,
g_autoptr(GVariant) reply = NULL;
g_autoptr(IdeTask) task = user_data;
g_autoptr(GError) error = NULL;
- IdeContext *context;
GFile *file;
g_assert (IDE_IS_CLANG_CLIENT (self));
g_assert (G_IS_ASYNC_RESULT (result));
g_assert (IDE_IS_TASK (task));
- context = ide_object_get_context (IDE_OBJECT (self));
file = ide_task_get_task_data (task);
if (!ide_clang_client_call_finish (self, result, &reply, &error))
ide_task_return_error (task, g_steal_pointer (&error));
else
- ide_task_return_object (task, ide_clang_symbol_tree_new (context, file, reply));
+ ide_task_return_object (task, ide_clang_symbol_tree_new (file, reply));
}
void
@@ -1082,7 +1085,7 @@ ide_clang_client_diagnose_cb (GObject *object,
return;
}
- ret = ide_diagnostics_new (NULL);
+ ret = ide_diagnostics_new ();
g_variant_iter_init (&iter, reply);
@@ -1098,7 +1101,7 @@ ide_clang_client_diagnose_cb (GObject *object,
ide_task_return_pointer (task,
g_steal_pointer (&ret),
- (GDestroyNotify) ide_diagnostics_unref);
+ g_object_unref);
}
void
@@ -1400,17 +1403,3 @@ ide_clang_client_set_buffer_finish (IdeClangClient *self,
return ide_task_propagate_boolean (IDE_TASK (result), error);
}
-
-static void
-ide_clang_client_stop (IdeService *service)
-{
- g_assert (IDE_IS_CLANG_CLIENT (service));
-
- g_object_run_dispose (G_OBJECT (service));
-}
-
-static void
-service_iface_init (IdeServiceInterface *iface)
-{
- iface->stop = ide_clang_client_stop;
-}
diff --git a/src/plugins/clang/ide-clang-client.h b/src/plugins/clang/ide-clang-client.h
index 8b6df1ba8..6c4826363 100644
--- a/src/plugins/clang/ide-clang-client.h
+++ b/src/plugins/clang/ide-clang-client.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-code-index-entries.c
b/src/plugins/clang/ide-clang-code-index-entries.c
index cca2b310b..46e69c4ed 100644
--- a/src/plugins/clang/ide-clang-code-index-entries.c
+++ b/src/plugins/clang/ide-clang-code-index-entries.c
@@ -107,7 +107,7 @@ ide_clang_code_index_entries_worker (IdeTask *task,
&begin.line, &begin.column,
&end.line, &end.column);
- if (dzl_str_empty0 (key))
+ if (ide_str_empty0 (key))
key = NULL;
ide_code_index_entry_builder_set_name (builder, name);
diff --git a/src/plugins/clang/ide-clang-code-index-entries.h
b/src/plugins/clang/ide-clang-code-index-entries.h
index 5f46713cb..f62f749dd 100644
--- a/src/plugins/clang/ide-clang-code-index-entries.h
+++ b/src/plugins/clang/ide-clang-code-index-entries.h
@@ -21,7 +21,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-code-indexer.c b/src/plugins/clang/ide-clang-code-indexer.c
index f46637cb4..bf0b44687 100644
--- a/src/plugins/clang/ide-clang-code-indexer.c
+++ b/src/plugins/clang/ide-clang-code-indexer.c
@@ -71,7 +71,7 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer,
{
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
g_autoptr(IdeTask) task = NULL;
- IdeClangClient *client;
+ g_autoptr(IdeClangClient) client = NULL;
IdeContext *context;
g_assert (IDE_IS_CLANG_CODE_INDEXER (self));
@@ -95,7 +95,7 @@ ide_clang_code_indexer_index_file_async (IdeCodeIndexer *indexer,
ide_task_set_task_data (task, g_file_get_path (file), g_free);
context = ide_object_get_context (IDE_OBJECT (self));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
ide_clang_client_index_file_async (client,
file,
@@ -138,7 +138,7 @@ ide_clang_code_indexer_generate_key_cb (GObject *object,
static void
ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
- IdeSourceLocation *location,
+ IdeLocation *location,
const gchar * const *args,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -146,9 +146,8 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
{
IdeClangCodeIndexer *self = (IdeClangCodeIndexer *)indexer;
g_autoptr(IdeTask) task = NULL;
- IdeClangClient *client;
+ g_autoptr(IdeClangClient) client = NULL;
IdeContext *context;
- IdeFile *ifile;
GFile *file;
guint line;
guint column;
@@ -163,12 +162,11 @@ ide_clang_code_indexer_generate_key_async (IdeCodeIndexer *indexer,
ide_task_set_kind (task, IDE_TASK_KIND_INDEXER);
context = ide_object_get_context (IDE_OBJECT (self));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
- ifile = ide_source_location_get_file (location);
- file = ide_file_get_file (ifile);
- line = ide_source_location_get_line (location);
- column = ide_source_location_get_line_offset (location);
+ file = ide_location_get_file (location);
+ line = ide_location_get_line (location);
+ column = ide_location_get_line_offset (location);
ide_clang_client_get_index_key_async (client,
file,
diff --git a/src/plugins/clang/ide-clang-code-indexer.h b/src/plugins/clang/ide-clang-code-indexer.h
index 3cc26cea6..61a86c9d3 100644
--- a/src/plugins/clang/ide-clang-code-indexer.h
+++ b/src/plugins/clang/ide-clang-code-indexer.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-completion-item.c b/src/plugins/clang/ide-clang-completion-item.c
index 10db19374..93ca4d391 100644
--- a/src/plugins/clang/ide-clang-completion-item.c
+++ b/src/plugins/clang/ide-clang-completion-item.c
@@ -22,6 +22,7 @@
#include <clang-c/Index.h>
#include <glib/gi18n.h>
+#include <libide-foundry.h>
#include "ide-clang-completion-item.h"
@@ -55,24 +56,24 @@ ide_clang_completion_item_do_init (IdeClangCompletionItem *self)
case CXCursor_ObjCClassMethodDecl:
case CXCursor_ObjCInstanceMethodDecl:
self->icon_name = "lang-method-symbolic";
- self->kind = IDE_SYMBOL_METHOD;
+ self->kind = IDE_SYMBOL_KIND_METHOD;
break;
case CXCursor_ConversionFunction:
case CXCursor_FunctionDecl:
case CXCursor_FunctionTemplate:
self->icon_name = "lang-function-symbolic";
- self->kind = IDE_SYMBOL_FUNCTION;
+ self->kind = IDE_SYMBOL_KIND_FUNCTION;
break;
case CXCursor_FieldDecl:
self->icon_name = "lang-struct-field-symbolic";
- self->kind = IDE_SYMBOL_FIELD;
+ self->kind = IDE_SYMBOL_KIND_FIELD;
break;
case CXCursor_VarDecl:
self->icon_name = "lang-variable-symbolic";
- self->kind = IDE_SYMBOL_VARIABLE;
+ self->kind = IDE_SYMBOL_KIND_VARIABLE;
/* local? */
break;
@@ -80,7 +81,7 @@ ide_clang_completion_item_do_init (IdeClangCompletionItem *self)
case CXCursor_NamespaceAlias:
case CXCursor_NamespaceRef:
self->icon_name = "lang-namespace-symbolic";
- self->kind = IDE_SYMBOL_NAMESPACE;
+ self->kind = IDE_SYMBOL_KIND_NAMESPACE;
break;
case CXCursor_ParmDecl:
@@ -92,12 +93,12 @@ ide_clang_completion_item_do_init (IdeClangCompletionItem *self)
case CXCursor_StructDecl:
self->icon_name = "lang-struct-symbolic";
- self->kind = IDE_SYMBOL_STRUCT;
+ self->kind = IDE_SYMBOL_KIND_STRUCT;
break;
case CXCursor_UnionDecl:
self->icon_name = "lang-union-symbolic";
- self->kind = IDE_SYMBOL_UNION;
+ self->kind = IDE_SYMBOL_KIND_UNION;
break;
case CXCursor_ClassDecl:
@@ -116,23 +117,23 @@ ide_clang_completion_item_do_init (IdeClangCompletionItem *self)
case CXCursor_TemplateTypeParameter:
case CXCursor_TemplateTemplateParameter:
self->icon_name = "lang-class-symbolic";
- self->kind = IDE_SYMBOL_CLASS;
+ self->kind = IDE_SYMBOL_KIND_CLASS;
break;
case CXCursor_MacroDefinition:
case CXCursor_MacroExpansion:
self->icon_name = "lang-define-symbolic";
- self->kind = IDE_SYMBOL_MACRO;
+ self->kind = IDE_SYMBOL_KIND_MACRO;
break;
case CXCursor_EnumConstantDecl:
self->icon_name = "lang-enum-value-symbolic";
- self->kind = IDE_SYMBOL_ENUM_VALUE;
+ self->kind = IDE_SYMBOL_KIND_ENUM_VALUE;
break;
case CXCursor_EnumDecl:
self->icon_name = "lang-enum-symbolic";
- self->kind = IDE_SYMBOL_ENUM;
+ self->kind = IDE_SYMBOL_KIND_ENUM;
break;
case CXCursor_NotImplemented:
@@ -185,7 +186,7 @@ ide_clang_completion_item_do_init (IdeClangCompletionItem *self)
break;
case CXCompletionChunk_Informative:
- if (dzl_str_equal0 (text, "const "))
+ if (ide_str_equal0 (text, "const "))
g_string_append (markup, text);
break;
diff --git a/src/plugins/clang/ide-clang-completion-item.h b/src/plugins/clang/ide-clang-completion-item.h
index 61fb82dc0..4b32a9667 100644
--- a/src/plugins/clang/ide-clang-completion-item.h
+++ b/src/plugins/clang/ide-clang-completion-item.h
@@ -20,7 +20,8 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
+#include <libide-sourceview.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-completion-provider.c
b/src/plugins/clang/ide-clang-completion-provider.c
index 4d549c79b..c6fa63f89 100644
--- a/src/plugins/clang/ide-clang-completion-provider.c
+++ b/src/plugins/clang/ide-clang-completion-provider.c
@@ -103,7 +103,7 @@ ide_clang_completion_provider_key_activates (IdeCompletionProvider *provider,
IdeClangCompletionItem *item = IDE_CLANG_COMPLETION_ITEM (proposal);
/* Try to dereference field/variable */
- if (item->kind == IDE_SYMBOL_FIELD || item->kind == IDE_SYMBOL_VARIABLE)
+ if (item->kind == IDE_SYMBOL_KIND_FIELD || item->kind == IDE_SYMBOL_KIND_VARIABLE)
return key->keyval == GDK_KEY_period;
#if 0
@@ -129,9 +129,9 @@ ide_clang_completion_provider_activate_proposal (IdeCompletionProvider *provider
IdeClangCompletionItem *item = (IdeClangCompletionItem *)proposal;
g_autofree gchar *word = NULL;
g_autoptr(IdeSnippet) snippet = NULL;
+ IdeFileSettings *file_settings;
GtkTextBuffer *buffer;
GtkTextView *view;
- IdeFile *file;
GtkTextIter begin, end;
g_assert (IDE_IS_CLANG_COMPLETION_PROVIDER (provider));
@@ -144,8 +144,7 @@ ide_clang_completion_provider_activate_proposal (IdeCompletionProvider *provider
g_assert (IDE_IS_BUFFER (buffer));
g_assert (IDE_IS_SOURCE_VIEW (view));
- file = ide_buffer_get_file (IDE_BUFFER (buffer));
- g_assert (IDE_IS_FILE (file));
+ file_settings = ide_buffer_get_file_settings (IDE_BUFFER (buffer));
/*
* If the typed text matches the typed text of the item, and the user
@@ -155,7 +154,7 @@ ide_clang_completion_provider_activate_proposal (IdeCompletionProvider *provider
{
if ((word = ide_completion_context_get_word (context)))
{
- if (dzl_str_equal0 (word, item->typed_text))
+ if (ide_str_equal0 (word, item->typed_text))
{
ide_completion_context_get_bounds (context, &begin, &end);
gtk_text_buffer_insert (buffer, &end, "\n", -1);
@@ -170,13 +169,13 @@ ide_clang_completion_provider_activate_proposal (IdeCompletionProvider *provider
if (ide_completion_context_get_bounds (context, &begin, &end))
gtk_text_buffer_delete (buffer, &begin, &end);
- snippet = ide_clang_completion_item_get_snippet (item, ide_file_peek_settings (file));
+ snippet = ide_clang_completion_item_get_snippet (item, file_settings);
/*
* If we are completing field or variable types, we might want to add
* a . or -> to the snippet based on the input character.
*/
- if (item->kind == IDE_SYMBOL_FIELD || item->kind == IDE_SYMBOL_VARIABLE)
+ if (item->kind == IDE_SYMBOL_KIND_FIELD || item->kind == IDE_SYMBOL_KIND_VARIABLE)
{
if (key->keyval == GDK_KEY_period || key->keyval == GDK_KEY_minus)
{
@@ -238,12 +237,12 @@ ide_clang_completion_provider_load (IdeCompletionProvider *provider,
IdeContext *context)
{
IdeClangCompletionProvider *self = (IdeClangCompletionProvider *)provider;
- IdeClangClient *client;
+ g_autoptr(IdeClangClient) client = NULL;
g_assert (IDE_IS_CLANG_COMPLETION_PROVIDER (self));
g_assert (IDE_IS_CONTEXT (context));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
g_set_object (&self->client, client);
}
diff --git a/src/plugins/clang/ide-clang-completion-provider.h
b/src/plugins/clang/ide-clang-completion-provider.h
index 0b95d274f..408ad51cf 100644
--- a/src/plugins/clang/ide-clang-completion-provider.h
+++ b/src/plugins/clang/ide-clang-completion-provider.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-diagnostic-provider.c
b/src/plugins/clang/ide-clang-diagnostic-provider.c
index 246e44af9..e5d9fb256 100644
--- a/src/plugins/clang/ide-clang-diagnostic-provider.c
+++ b/src/plugins/clang/ide-clang-diagnostic-provider.c
@@ -21,6 +21,7 @@
#define G_LOG_DOMAIN "ide-clang-diagnostic-provider"
#include <glib/gi18n.h>
+#include <libide-foundry.h>
#include "ide-clang-client.h"
#include "ide-clang-diagnostic-provider.h"
@@ -61,8 +62,8 @@ diagnose_get_build_flags_cb (GObject *object,
{
IdeBuildSystem *build_system = (IdeBuildSystem *)object;
g_autoptr(IdeTask) task = user_data;
+ g_autoptr(IdeClangClient) client = NULL;
g_auto(GStrv) flags = NULL;
- IdeClangClient *client;
GCancellable *cancellable;
IdeContext *context;
GFile *file;
@@ -73,7 +74,7 @@ diagnose_get_build_flags_cb (GObject *object,
flags = ide_build_system_get_build_flags_finish (build_system, result, NULL);
context = ide_object_get_context (IDE_OBJECT (build_system));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
file = ide_task_get_task_data (task);
cancellable = ide_task_get_cancellable (task);
@@ -87,8 +88,9 @@ diagnose_get_build_flags_cb (GObject *object,
static void
ide_clang_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
- IdeFile *file,
- IdeBuffer *buffer,
+ GFile *file,
+ GBytes *contents,
+ const gchar *lang_id,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -97,18 +99,16 @@ ide_clang_diagnostic_provider_diagnose_async (IdeDiagnosticProvider *provider,
g_autoptr(IdeTask) task = NULL;
IdeBuildSystem *build_system;
IdeContext *context;
- GFile *gfile;
- g_return_if_fail (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self));
-
- gfile = ide_file_get_file (file);
+ g_assert (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self));
+ g_assert (IDE_IS_CLANG_DIAGNOSTIC_PROVIDER (self));
task = ide_task_new (self, cancellable, callback, user_data);
- ide_task_set_task_data (task, g_object_ref (gfile), g_object_unref);
+ ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
ide_task_set_kind (task, IDE_TASK_KIND_COMPILER);
context = ide_object_get_context (IDE_OBJECT (self));
- build_system = ide_context_get_build_system (context);
+ build_system = ide_build_system_from_context (context);
ide_build_system_get_build_flags_async (build_system,
file,
diff --git a/src/plugins/clang/ide-clang-diagnostic-provider.h
b/src/plugins/clang/ide-clang-diagnostic-provider.h
index 297656904..d11314769 100644
--- a/src/plugins/clang/ide-clang-diagnostic-provider.h
+++ b/src/plugins/clang/ide-clang-diagnostic-provider.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-highlighter.c b/src/plugins/clang/ide-clang-highlighter.c
index 6370fc130..3bcb60f24 100644
--- a/src/plugins/clang/ide-clang-highlighter.c
+++ b/src/plugins/clang/ide-clang-highlighter.c
@@ -18,7 +18,12 @@
* SPDX-License-Identifier: GPL-3.0-or-later
*/
+#define G_LOG_DOMAIN "ide-clang-highlighter"
+
+#include "config.h"
+
#include <glib/gi18n.h>
+#include <libide-foundry.h>
#include "ide-clang-client.h"
#include "ide-clang-highlighter.h"
@@ -113,12 +118,12 @@ get_index_flags_cb (GObject *object,
{
IdeBuildSystem *build_system = (IdeBuildSystem *)object;
g_autoptr(IdeTask) task = user_data;
+ g_autoptr(IdeClangClient) client = NULL;
g_autoptr(GError) error = NULL;
g_auto(GStrv) flags = NULL;
- IdeClangClient *client;
GCancellable *cancellable;
IdeContext *context;
- IdeFile *file;
+ GFile *file;
g_assert (IDE_IS_BUILD_SYSTEM (build_system));
g_assert (G_IS_ASYNC_RESULT (result));
@@ -126,12 +131,12 @@ get_index_flags_cb (GObject *object,
flags = ide_build_system_get_build_flags_finish (build_system, result, &error);
context = ide_object_get_context (IDE_OBJECT (build_system));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
file = ide_task_get_task_data (task);
cancellable = ide_task_get_cancellable (task);
ide_clang_client_get_highlight_index_async (client,
- ide_file_get_file (file),
+ file,
(const gchar * const *)flags,
cancellable,
get_highlight_index_cb,
@@ -309,11 +314,11 @@ static gboolean
ide_clang_highlighter_do_update (IdeClangHighlighter *self)
{
g_autoptr(IdeTask) task = NULL;
+ g_autoptr(IdeClangClient) client = NULL;
IdeBuildSystem *build_system;
- IdeClangClient *client;
IdeContext *context;
IdeBuffer *buffer;
- IdeFile *file;
+ GFile *file;
g_assert (IDE_IS_CLANG_HIGHLIGHTER (self));
@@ -323,14 +328,14 @@ ide_clang_highlighter_do_update (IdeClangHighlighter *self)
!(buffer = ide_highlight_engine_get_buffer (self->engine)) ||
!(file = ide_buffer_get_file (buffer)) ||
!(context = ide_object_get_context (IDE_OBJECT (self))) ||
- !(client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT)))
+ !(client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT)))
return G_SOURCE_REMOVE;
task = ide_task_new (self, NULL, NULL, NULL);
ide_task_set_source_tag (task, ide_clang_highlighter_get_index);
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
- build_system = ide_context_get_build_system (context);
+ build_system = ide_build_system_from_context (context);
ide_build_system_get_build_flags_async (build_system,
file,
diff --git a/src/plugins/clang/ide-clang-highlighter.h b/src/plugins/clang/ide-clang-highlighter.h
index 88d3f2130..6c7a64b2c 100644
--- a/src/plugins/clang/ide-clang-highlighter.h
+++ b/src/plugins/clang/ide-clang-highlighter.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-preferences-addin.c b/src/plugins/clang/ide-clang-preferences-addin.c
index d665b0abd..06571beb5 100644
--- a/src/plugins/clang/ide-clang-preferences-addin.c
+++ b/src/plugins/clang/ide-clang-preferences-addin.c
@@ -19,7 +19,8 @@
*/
#include <glib/gi18n.h>
-#include <ide.h>
+#include <libide-code.h>
+#include <libide-gui.h>
#include "ide-clang-preferences-addin.h"
diff --git a/src/plugins/clang/ide-clang-proposals.c b/src/plugins/clang/ide-clang-proposals.c
index 0f1cc4b76..9106c9941 100644
--- a/src/plugins/clang/ide-clang-proposals.c
+++ b/src/plugins/clang/ide-clang-proposals.c
@@ -22,13 +22,16 @@
#include "config.h"
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-sourceview.h>
#include <clang-c/Index.h>
+#include "ide-buffer-private.h"
+
#include "ide-clang-completion-item.h"
#include "ide-clang-proposals.h"
-#include "sourceview/ide-text-iter.h"
-
struct _IdeClangProposals
{
GObject parent_instance;
@@ -216,7 +219,7 @@ ide_clang_proposals_class_init (IdeClangProposalsClass *klass)
"The client to the clang worker process",
IDE_TYPE_CLANG_CLIENT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
-
+
g_object_class_install_properties (object_class, N_PROPS, properties);
}
@@ -514,7 +517,7 @@ ide_clang_proposals_query_build_flags_cb (GObject *object,
static void
ide_clang_proposals_query_async (IdeClangProposals *self,
- IdeFile *file,
+ GFile *file,
guint line,
guint column,
GCancellable *cancellable,
@@ -527,15 +530,15 @@ ide_clang_proposals_query_async (IdeClangProposals *self,
Query *q;
g_assert (IDE_IS_CLANG_PROPOSALS (self));
- g_assert (IDE_IS_FILE (file));
+ g_assert (G_IS_FILE (file));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
context = ide_object_get_context (IDE_OBJECT (self->client));
- build_system = ide_context_get_build_system (context);
+ build_system = ide_build_system_from_context (context);
q = g_slice_new0 (Query);
q->client = g_object_ref (self->client);
- q->file = g_object_ref (ide_file_get_file (file));
+ q->file = g_object_ref (file);
q->line = line;
q->column = column;
q->query_id = ++self->query_id;
@@ -613,7 +616,7 @@ ide_clang_proposals_populate_async (IdeClangProposals *self,
GtkTextBuffer *buffer;
GtkTextIter begin;
GtkTextIter previous;
- IdeFile *file;
+ GFile *file;
IDE_ENTRY;
@@ -655,7 +658,7 @@ ide_clang_proposals_populate_async (IdeClangProposals *self,
}
/* Unlikely, but is this the exact same query as before? */
- if (dzl_str_equal0 (self->filter, word))
+ if (ide_str_equal0 (self->filter, word))
{
ide_task_return_boolean (task, TRUE);
IDE_EXIT;
@@ -687,7 +690,7 @@ ide_clang_proposals_populate_async (IdeClangProposals *self,
query_client:
- ide_buffer_sync_to_unsaved_files (IDE_BUFFER (buffer));
+ _ide_buffer_sync_to_unsaved_files (IDE_BUFFER (buffer));
file = ide_buffer_get_file (IDE_BUFFER (buffer));
prev_cancellable = g_steal_pointer (&self->cancellable);
diff --git a/src/plugins/clang/ide-clang-proposals.h b/src/plugins/clang/ide-clang-proposals.h
index fdfa557b5..b2bc677be 100644
--- a/src/plugins/clang/ide-clang-proposals.h
+++ b/src/plugins/clang/ide-clang-proposals.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
#include "ide-clang-client.h"
diff --git a/src/plugins/clang/ide-clang-rename-provider.c b/src/plugins/clang/ide-clang-rename-provider.c
index 18b790f8f..7ccc7cb58 100644
--- a/src/plugins/clang/ide-clang-rename-provider.c
+++ b/src/plugins/clang/ide-clang-rename-provider.c
@@ -22,6 +22,10 @@
#include "config.h"
+#include <libide-code.h>
+#include <libide-foundry.h>
+#include <libide-vcs.h>
+
#include "ide-clang-rename-provider.h"
struct _IdeClangRenameProvider
@@ -45,10 +49,10 @@ ide_clang_rename_provider_communicate_cb (GObject *object,
{
IdeSubprocess *subprocess = (IdeSubprocess *)object;
g_autoptr(IdeTask) task = user_data;
- g_autoptr(IdeProjectEdit) edit = NULL;
- g_autoptr(IdeSourceLocation) begin = NULL;
- g_autoptr(IdeSourceLocation) end = NULL;
- g_autoptr(IdeSourceRange) range = NULL;
+ g_autoptr(IdeTextEdit) edit = NULL;
+ g_autoptr(IdeLocation) begin = NULL;
+ g_autoptr(IdeLocation) end = NULL;
+ g_autoptr(IdeRange) range = NULL;
g_autoptr(GError) error = NULL;
g_autoptr(GPtrArray) edits = NULL;
g_autofree gchar *stdout_buf = NULL;
@@ -70,7 +74,7 @@ ide_clang_rename_provider_communicate_cb (GObject *object,
if (ide_task_return_error_if_cancelled (task))
IDE_EXIT;
- if (dzl_str_empty0 (stdout_buf) || (stdout_buf[0] == '\n' && stdout_buf[1] == 0))
+ if (ide_str_empty0 (stdout_buf) || (stdout_buf[0] == '\n' && stdout_buf[1] == 0))
{
/* Don't allow deleting the buffer contents */
ide_task_return_new_error (task,
@@ -100,17 +104,14 @@ ide_clang_rename_provider_communicate_cb (GObject *object,
gtk_text_buffer_get_bounds (GTK_TEXT_BUFFER (buffer), &begin_iter, &end_iter);
begin = ide_buffer_get_iter_location (buffer, &begin_iter);
end = ide_buffer_get_iter_location (buffer, &end_iter);
- range = ide_source_range_new (begin, end);
+ range = ide_range_new (begin, end);
/*
* We just get the single replacement buffer from clang-rename instead
- * of individual file-edits, so create IdeProjectEdit to reflect that.
+ * of individual file-edits, so create IdeTextEdit to reflect that.
*/
- edit = ide_project_edit_new ();
- ide_project_edit_set_range (edit, range);
- ide_project_edit_set_replacement (edit, stdout_buf);
-
+ edit = ide_text_edit_new (range, stdout_buf);
edits = g_ptr_array_new_full (1, g_object_unref);
g_ptr_array_add (edits, g_steal_pointer (&edit));
@@ -121,7 +122,7 @@ ide_clang_rename_provider_communicate_cb (GObject *object,
static void
ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
- IdeSourceLocation *location,
+ IdeLocation *location,
const gchar *new_name,
GCancellable *cancellable,
GAsyncReadyCallback callback,
@@ -139,8 +140,7 @@ ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
IdeBuildManager *build_manager;
const gchar *builddir = NULL;
IdeContext *context;
- IdeFile *file;
- GFile *gfile;
+ GFile *file;
guint offset;
IDE_ENTRY;
@@ -148,7 +148,7 @@ ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
g_assert (IDE_IS_CLANG_RENAME_PROVIDER (self));
g_assert (IDE_IS_BUFFER (self->buffer));
g_assert (location != NULL);
- g_assert (!dzl_str_empty0 (new_name));
+ g_assert (!ide_str_empty0 (new_name));
g_assert (!cancellable || G_IS_CANCELLABLE (cancellable));
/* TODO: For build systems that don't support compile_commands.json,
@@ -161,13 +161,12 @@ ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
ide_task_set_task_data (task, g_object_ref (self->buffer), g_object_unref);
context = ide_object_get_context (IDE_OBJECT (self));
- build_manager = ide_context_get_build_manager (context);
+ build_manager = ide_build_manager_from_context (context);
if ((pipeline = ide_build_manager_get_pipeline (build_manager)))
builddir = ide_build_pipeline_get_builddir (pipeline);
- file = ide_source_location_get_file (location);
- gfile = ide_file_get_file (file);
- path = g_file_get_path (gfile);
+ file = ide_location_get_file (location);
+ path = g_file_get_path (file);
if (path == NULL)
{
@@ -178,7 +177,7 @@ ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
IDE_EXIT;
}
- offset = ide_source_location_get_offset (location);
+ offset = ide_location_get_offset (location);
position_arg = g_strdup_printf ("-offset=%u", offset);
new_name_arg = g_strdup_printf ("-new-name=%s", new_name);
@@ -189,8 +188,8 @@ ide_clang_rename_provider_rename_async (IdeRenameProvider *provider,
ide_subprocess_launcher_set_cwd (launcher, builddir);
else
{
- IdeVcs *vcs = ide_context_get_vcs (context);
- GFile *workdir = ide_vcs_get_working_directory (vcs);
+ IdeVcs *vcs = ide_vcs_from_context (context);
+ GFile *workdir = ide_vcs_get_workdir (vcs);
g_autofree gchar *srcdir = g_file_get_path (workdir);
/* fallback to srcdir */
diff --git a/src/plugins/clang/ide-clang-rename-provider.h b/src/plugins/clang/ide-clang-rename-provider.h
index 77a215f26..dde3de58e 100644
--- a/src/plugins/clang/ide-clang-rename-provider.h
+++ b/src/plugins/clang/ide-clang-rename-provider.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-symbol-node.c b/src/plugins/clang/ide-clang-symbol-node.c
index d16bff2e8..92cbe32d6 100644
--- a/src/plugins/clang/ide-clang-symbol-node.c
+++ b/src/plugins/clang/ide-clang-symbol-node.c
@@ -35,15 +35,13 @@ struct _IdeClangSymbolNode
G_DEFINE_TYPE (IdeClangSymbolNode, ide_clang_symbol_node, IDE_TYPE_SYMBOL_NODE)
IdeSymbolNode *
-ide_clang_symbol_node_new (IdeContext *context,
- GVariant *node)
+ide_clang_symbol_node_new (GVariant *node)
{
g_autoptr(IdeSymbol) symbol = NULL;
g_autoptr(GVariant) children = NULL;
IdeClangSymbolNode *self;
const gchar *name;
- g_return_val_if_fail (!context || IDE_IS_CONTEXT (context), NULL);
g_return_val_if_fail (node != NULL, NULL);
if (!(symbol = ide_symbol_new_from_variant (node)))
@@ -52,10 +50,9 @@ ide_clang_symbol_node_new (IdeContext *context,
name = ide_symbol_get_name (symbol);
self = g_object_new (IDE_TYPE_CLANG_SYMBOL_NODE,
- "context", context,
"kind", ide_symbol_get_kind (symbol),
"flags", ide_symbol_get_flags (symbol),
- "name", dzl_str_empty0 (name) ? _("anonymous") : name,
+ "name", ide_str_empty0 (name) ? _("anonymous") : name,
NULL);
self->symbol = g_steal_pointer (&symbol);
@@ -80,7 +77,7 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
{
IdeClangSymbolNode *self = (IdeClangSymbolNode *)symbol_node;
g_autoptr(IdeTask) task = NULL;
- IdeSourceLocation *location;
+ IdeLocation *location;
g_return_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
@@ -90,20 +87,19 @@ ide_clang_symbol_node_get_location_async (IdeSymbolNode *symbol_node,
ide_task_set_priority (task, G_PRIORITY_LOW);
if (self->symbol == NULL ||
- (!(location = ide_symbol_get_definition_location (self->symbol)) &&
- !(location = ide_symbol_get_declaration_location (self->symbol)) &&
- !(location = ide_symbol_get_canonical_location (self->symbol))))
+ (!(location = ide_symbol_get_location (self->symbol)) &&
+ !(location = ide_symbol_get_header_location (self->symbol))))
ide_task_return_new_error (task,
G_IO_ERROR,
G_IO_ERROR_NOT_FOUND,
"Failed to locate location for symbol");
else
ide_task_return_pointer (task,
- ide_source_location_ref (location),
- (GDestroyNotify) ide_source_location_unref);
+ g_object_ref (location),
+ g_object_unref);
}
-static IdeSourceLocation *
+static IdeLocation *
ide_clang_symbol_node_get_location_finish (IdeSymbolNode *symbol_node,
GAsyncResult *result,
GError **error)
@@ -119,7 +115,7 @@ ide_clang_symbol_node_finalize (GObject *object)
{
IdeClangSymbolNode *self = (IdeClangSymbolNode *)object;
- g_clear_pointer (&self->symbol, ide_symbol_unref);
+ g_clear_object (&self->symbol);
g_clear_pointer (&self->children, g_variant_unref);
G_OBJECT_CLASS (ide_clang_symbol_node_parent_class)->finalize (object);
@@ -155,15 +151,13 @@ ide_clang_symbol_node_get_nth_child (IdeClangSymbolNode *self,
guint nth)
{
g_autoptr(GVariant) child = NULL;
- IdeContext *context;
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_NODE (self), NULL);
if (self->children == NULL || g_variant_n_children (self->children) <= nth)
return NULL;
- context = ide_object_get_context (IDE_OBJECT (self));
child = g_variant_get_child_value (self->children, nth);
- return ide_clang_symbol_node_new (context, child);
+ return ide_clang_symbol_node_new (child);
}
diff --git a/src/plugins/clang/ide-clang-symbol-node.h b/src/plugins/clang/ide-clang-symbol-node.h
index c4c45624a..6966a8b37 100644
--- a/src/plugins/clang/ide-clang-symbol-node.h
+++ b/src/plugins/clang/ide-clang-symbol-node.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
@@ -28,8 +28,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeClangSymbolNode, ide_clang_symbol_node, IDE, CLANG_SYMBOL_NODE, IdeSymbolNode)
-IdeSymbolNode *ide_clang_symbol_node_new (IdeContext *context,
- GVariant *variant);
+IdeSymbolNode *ide_clang_symbol_node_new (GVariant *variant);
guint ide_clang_symbol_node_get_n_children (IdeClangSymbolNode *self);
IdeSymbolNode *ide_clang_symbol_node_get_nth_child (IdeClangSymbolNode *self,
guint nth);
diff --git a/src/plugins/clang/ide-clang-symbol-resolver.c b/src/plugins/clang/ide-clang-symbol-resolver.c
index e8c444954..33bf47314 100644
--- a/src/plugins/clang/ide-clang-symbol-resolver.c
+++ b/src/plugins/clang/ide-clang-symbol-resolver.c
@@ -20,6 +20,10 @@
#define G_LOG_DOMAIN "clang-symbol-resolver"
+#include "config.h"
+
+#include <libide-foundry.h>
+
#include "ide-clang-client.h"
#include "ide-clang-symbol-resolver.h"
@@ -54,7 +58,7 @@ ide_clang_symbol_resolver_lookup_symbol_cb (GObject *object,
else
ide_task_return_pointer (task,
g_steal_pointer (&symbol),
- (GDestroyNotify) ide_symbol_unref);
+ g_object_unref);
IDE_EXIT;
}
@@ -66,13 +70,12 @@ lookup_symbol_flags_cb (GObject *object,
{
IdeBuildSystem *build_system = (IdeBuildSystem *)object;
g_autoptr(IdeTask) task = user_data;
+ g_autoptr(IdeClangClient) client = NULL;
g_auto(GStrv) flags = NULL;
- IdeSourceLocation *location;
- IdeClangClient *client;
+ IdeLocation *location;
GCancellable *cancellable;
IdeContext *context;
- IdeFile *file;
- GFile *gfile;
+ GFile *file;
guint line;
guint column;
@@ -84,16 +87,15 @@ lookup_symbol_flags_cb (GObject *object,
flags = ide_build_system_get_build_flags_finish (build_system, result, NULL);
context = ide_object_get_context (IDE_OBJECT (build_system));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
cancellable = ide_task_get_cancellable (task);
location = ide_task_get_task_data (task);
- file = ide_source_location_get_file (location);
- gfile = ide_file_get_file (file);
- line = ide_source_location_get_line (location);
- column = ide_source_location_get_line_offset (location);
+ file = ide_location_get_file (location);
+ line = ide_location_get_line (location);
+ column = ide_location_get_line_offset (location);
ide_clang_client_locate_symbol_async (client,
- gfile,
+ file,
(const gchar * const *)flags,
line + 1,
column + 1,
@@ -106,7 +108,7 @@ lookup_symbol_flags_cb (GObject *object,
static void
ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
- IdeSourceLocation *location,
+ IdeLocation *location,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -115,7 +117,7 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
g_autoptr(IdeTask) task = NULL;
IdeBuildSystem *build_system;
IdeContext *context;
- IdeFile *file;
+ GFile *file;
IDE_ENTRY;
@@ -127,12 +129,12 @@ ide_clang_symbol_resolver_lookup_symbol_async (IdeSymbolResolver *resolver,
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_source_tag (task, ide_clang_symbol_resolver_lookup_symbol_async);
ide_task_set_task_data (task,
- ide_source_location_ref (location),
- ide_source_location_unref);
+ g_object_ref (location),
+ g_object_unref);
context = ide_object_get_context (IDE_OBJECT (self));
- build_system = ide_context_get_build_system (context);
- file = ide_source_location_get_file (location);
+ build_system = ide_build_system_from_context (context);
+ file = ide_location_get_file (location);
ide_build_system_get_build_flags_async (build_system,
file,
@@ -191,8 +193,8 @@ get_symbol_tree_flags_cb (GObject *object,
{
IdeBuildSystem *build_system = (IdeBuildSystem *)object;
g_autoptr(IdeTask) task = user_data;
+ g_autoptr(IdeClangClient) client = NULL;
g_auto(GStrv) flags = NULL;
- IdeClangClient *client;
GCancellable *cancellable;
IdeContext *context;
GFile *file;
@@ -203,7 +205,7 @@ get_symbol_tree_flags_cb (GObject *object,
flags = ide_build_system_get_build_flags_finish (build_system, result, NULL);
context = ide_object_get_context (IDE_OBJECT (build_system));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
cancellable = ide_task_get_cancellable (task);
file = ide_task_get_task_data (task);
@@ -218,14 +220,13 @@ get_symbol_tree_flags_cb (GObject *object,
static void
ide_clang_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver,
GFile *file,
- IdeBuffer *buffer,
+ GBytes *content,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
IdeClangSymbolResolver *self = (IdeClangSymbolResolver *)resolver;
g_autoptr(IdeTask) task = NULL;
- g_autoptr(IdeFile) ifile = NULL;
IdeBuildSystem *build_system;
IdeContext *context;
@@ -233,7 +234,6 @@ ide_clang_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver,
g_return_if_fail (IDE_IS_CLANG_SYMBOL_RESOLVER (self));
g_return_if_fail (G_IS_FILE (file));
- g_return_if_fail (IDE_IS_BUFFER (buffer));
g_return_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable));
task = ide_task_new (self, cancellable, callback, user_data);
@@ -242,11 +242,10 @@ ide_clang_symbol_resolver_get_symbol_tree_async (IdeSymbolResolver *resolver,
ide_task_set_task_data (task, g_object_ref (file), g_object_unref);
context = ide_object_get_context (IDE_OBJECT (self));
- build_system = ide_context_get_build_system (context);
- ifile = ide_file_new (context, file);
+ build_system = ide_build_system_from_context (context);
ide_build_system_get_build_flags_async (build_system,
- ifile,
+ file,
cancellable,
get_symbol_tree_flags_cb,
g_steal_pointer (&task));
@@ -290,7 +289,7 @@ ide_clang_symbol_resolver_find_scope_cb (GObject *object,
else
ide_task_return_pointer (task,
g_steal_pointer (&symbol),
- (GDestroyNotify)ide_symbol_unref);
+ g_object_unref);
}
static void
@@ -300,13 +299,12 @@ find_nearest_scope_flags_cb (GObject *object,
{
IdeBuildSystem *build_system = (IdeBuildSystem *)object;
g_autoptr(IdeTask) task = user_data;
+ g_autoptr(IdeClangClient) client = NULL;
g_auto(GStrv) flags = NULL;
- IdeSourceLocation *location;
- IdeClangClient *client;
+ IdeLocation *location;
GCancellable *cancellable;
IdeContext *context;
- IdeFile *file;
- GFile *gfile;
+ GFile *file;
guint line;
guint column;
@@ -316,16 +314,15 @@ find_nearest_scope_flags_cb (GObject *object,
flags = ide_build_system_get_build_flags_finish (build_system, result, NULL);
context = ide_object_get_context (IDE_OBJECT (build_system));
- client = ide_context_get_service_typed (context, IDE_TYPE_CLANG_CLIENT);
+ client = ide_object_ensure_child_typed (IDE_OBJECT (context), IDE_TYPE_CLANG_CLIENT);
cancellable = ide_task_get_cancellable (task);
location = ide_task_get_task_data (task);
- file = ide_source_location_get_file (location);
- gfile = ide_file_get_file (file);
- line = ide_source_location_get_line (location);
- column = ide_source_location_get_line_offset (location);
+ file = ide_location_get_file (location);
+ line = ide_location_get_line (location);
+ column = ide_location_get_line_offset (location);
ide_clang_client_find_nearest_scope_async (client,
- gfile,
+ file,
(const gchar * const *)flags,
line + 1,
column + 1,
@@ -336,7 +333,7 @@ find_nearest_scope_flags_cb (GObject *object,
static void
ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver *symbol_resolver,
- IdeSourceLocation *location,
+ IdeLocation *location,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
@@ -345,7 +342,7 @@ ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver *symbol_
g_autoptr(IdeTask) task = NULL;
IdeBuildSystem *build_system;
IdeContext *context;
- IdeFile *file;
+ GFile *file;
IDE_ENTRY;
@@ -356,12 +353,12 @@ ide_clang_symbol_resolver_find_nearest_scope_async (IdeSymbolResolver *symbol_
ide_task_set_priority (task, G_PRIORITY_LOW);
ide_task_set_source_tag (task, ide_clang_symbol_resolver_find_nearest_scope_async);
ide_task_set_task_data (task,
- ide_source_location_ref (location),
- ide_source_location_unref);
+ g_object_ref (location),
+ g_object_unref);
context = ide_object_get_context (IDE_OBJECT (self));
- build_system = ide_context_get_build_system (context);
- file = ide_source_location_get_file (location);
+ build_system = ide_build_system_from_context (context);
+ file = ide_location_get_file (location);
ide_build_system_get_build_flags_async (build_system,
file,
diff --git a/src/plugins/clang/ide-clang-symbol-resolver.h b/src/plugins/clang/ide-clang-symbol-resolver.h
index 308ad58c8..d545b7776 100644
--- a/src/plugins/clang/ide-clang-symbol-resolver.h
+++ b/src/plugins/clang/ide-clang-symbol-resolver.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/ide-clang-symbol-tree.c b/src/plugins/clang/ide-clang-symbol-tree.c
index f6db27275..82e369266 100644
--- a/src/plugins/clang/ide-clang-symbol-tree.c
+++ b/src/plugins/clang/ide-clang-symbol-tree.c
@@ -35,7 +35,7 @@ struct _IdeClangSymbolTree
static void symbol_tree_iface_init (IdeSymbolTreeInterface *iface);
-G_DEFINE_TYPE_WITH_CODE (IdeClangSymbolTree, ide_clang_symbol_tree, IDE_TYPE_OBJECT,
+G_DEFINE_TYPE_WITH_CODE (IdeClangSymbolTree, ide_clang_symbol_tree, G_TYPE_OBJECT,
G_IMPLEMENT_INTERFACE (IDE_TYPE_SYMBOL_TREE, symbol_tree_iface_init))
enum {
@@ -87,7 +87,6 @@ ide_clang_symbol_tree_get_nth_child (IdeSymbolTree *symbol_tree,
IdeClangSymbolTree *self = (IdeClangSymbolTree *)symbol_tree;
g_autoptr(GVariant) node = NULL;
IdeSymbolNode *ret;
- IdeContext *context;
g_assert (IDE_IS_CLANG_SYMBOL_TREE (self));
g_assert (!parent || IDE_IS_CLANG_SYMBOL_NODE (parent));
@@ -101,9 +100,8 @@ ide_clang_symbol_tree_get_nth_child (IdeSymbolTree *symbol_tree,
if (nth >= g_variant_n_children (self->tree))
g_return_val_if_reached (NULL);
- context = ide_object_get_context (IDE_OBJECT (self));
node = g_variant_get_child_value (self->tree, nth);
- ret = ide_clang_symbol_node_new (context, node);
+ ret = ide_clang_symbol_node_new (node);
g_return_val_if_fail (IDE_IS_CLANG_SYMBOL_NODE (ret), NULL);
@@ -184,8 +182,7 @@ ide_clang_symbol_tree_init (IdeClangSymbolTree *self)
}
IdeClangSymbolTree *
-ide_clang_symbol_tree_new (IdeContext *context,
- GFile *file,
+ide_clang_symbol_tree_new (GFile *file,
GVariant *tree)
{
IdeClangSymbolTree *self;
@@ -197,7 +194,6 @@ ide_clang_symbol_tree_new (IdeContext *context,
NULL);
self = g_object_new (IDE_TYPE_CLANG_SYMBOL_TREE,
- "context", context,
"file", file,
NULL);
diff --git a/src/plugins/clang/ide-clang-symbol-tree.h b/src/plugins/clang/ide-clang-symbol-tree.h
index 57d4e2495..0485ad158 100644
--- a/src/plugins/clang/ide-clang-symbol-tree.h
+++ b/src/plugins/clang/ide-clang-symbol-tree.h
@@ -21,16 +21,15 @@
#pragma once
#include <gio/gio.h>
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
#define IDE_TYPE_CLANG_SYMBOL_TREE (ide_clang_symbol_tree_get_type())
-G_DECLARE_FINAL_TYPE (IdeClangSymbolTree, ide_clang_symbol_tree, IDE, CLANG_SYMBOL_TREE, IdeObject)
+G_DECLARE_FINAL_TYPE (IdeClangSymbolTree, ide_clang_symbol_tree, IDE, CLANG_SYMBOL_TREE, GObject)
-IdeClangSymbolTree *ide_clang_symbol_tree_new (IdeContext *context,
- GFile *file,
+IdeClangSymbolTree *ide_clang_symbol_tree_new (GFile *file,
GVariant *tree);
GFile *ide_clang_symbol_tree_get_file (IdeClangSymbolTree *self);
diff --git a/src/plugins/clang/ide-clang-util.h b/src/plugins/clang/ide-clang-util.h
index b7444ada2..432c16756 100644
--- a/src/plugins/clang/ide-clang-util.h
+++ b/src/plugins/clang/ide-clang-util.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
#include "ide-clang-autocleanups.h"
@@ -32,50 +32,50 @@ ide_clang_translate_kind (enum CXCursorKind cursor_kind)
switch ((int)cursor_kind)
{
case CXCursor_StructDecl:
- return IDE_SYMBOL_STRUCT;
+ return IDE_SYMBOL_KIND_STRUCT;
case CXCursor_UnionDecl:
- return IDE_SYMBOL_UNION;
+ return IDE_SYMBOL_KIND_UNION;
case CXCursor_ClassDecl:
- return IDE_SYMBOL_CLASS;
+ return IDE_SYMBOL_KIND_CLASS;
case CXCursor_EnumDecl:
- return IDE_SYMBOL_ENUM;
+ return IDE_SYMBOL_KIND_ENUM;
case CXCursor_FieldDecl:
- return IDE_SYMBOL_FIELD;
+ return IDE_SYMBOL_KIND_FIELD;
case CXCursor_EnumConstantDecl:
- return IDE_SYMBOL_ENUM_VALUE;
+ return IDE_SYMBOL_KIND_ENUM_VALUE;
case CXCursor_FunctionDecl:
- return IDE_SYMBOL_FUNCTION;
+ return IDE_SYMBOL_KIND_FUNCTION;
case CXCursor_CXXMethod:
- return IDE_SYMBOL_METHOD;
+ return IDE_SYMBOL_KIND_METHOD;
case CXCursor_VarDecl:
case CXCursor_ParmDecl:
- return IDE_SYMBOL_VARIABLE;
+ return IDE_SYMBOL_KIND_VARIABLE;
case CXCursor_TypedefDecl:
case CXCursor_NamespaceAlias:
case CXCursor_TypeAliasDecl:
- return IDE_SYMBOL_ALIAS;
+ return IDE_SYMBOL_KIND_ALIAS;
case CXCursor_Namespace:
- return IDE_SYMBOL_NAMESPACE;
+ return IDE_SYMBOL_KIND_NAMESPACE;
case CXCursor_FunctionTemplate:
case CXCursor_ClassTemplate:
- return IDE_SYMBOL_TEMPLATE;
+ return IDE_SYMBOL_KIND_TEMPLATE;
case CXCursor_MacroDefinition:
- return IDE_SYMBOL_MACRO;
+ return IDE_SYMBOL_KIND_MACRO;
default:
- return IDE_SYMBOL_NONE;
+ return IDE_SYMBOL_KIND_NONE;
}
}
diff --git a/src/plugins/clang/ide-clang.c b/src/plugins/clang/ide-clang.c
index ea0d6ec47..808a73537 100644
--- a/src/plugins/clang/ide-clang.c
+++ b/src/plugins/clang/ide-clang.c
@@ -22,7 +22,7 @@
#define G_LOG_DOMAIN "ide-clang"
-#include <ide.h>
+#include <libide-code.h>
#include "ide-clang.h"
#include "ide-clang-util.h"
@@ -290,54 +290,54 @@ ide_clang_get_symbol_kind (CXCursor cursor,
switch ((int)cxkind)
{
case CXCursor_StructDecl:
- kind = IDE_SYMBOL_STRUCT;
+ kind = IDE_SYMBOL_KIND_STRUCT;
break;
case CXCursor_UnionDecl:
- kind = IDE_SYMBOL_UNION;
+ kind = IDE_SYMBOL_KIND_UNION;
break;
case CXCursor_ClassDecl:
- kind = IDE_SYMBOL_CLASS;
+ kind = IDE_SYMBOL_KIND_CLASS;
break;
case CXCursor_FunctionDecl:
- kind = IDE_SYMBOL_FUNCTION;
+ kind = IDE_SYMBOL_KIND_FUNCTION;
break;
case CXCursor_EnumDecl:
- kind = IDE_SYMBOL_ENUM;
+ kind = IDE_SYMBOL_KIND_ENUM;
break;
case CXCursor_EnumConstantDecl:
- kind = IDE_SYMBOL_ENUM_VALUE;
+ kind = IDE_SYMBOL_KIND_ENUM_VALUE;
break;
case CXCursor_FieldDecl:
- kind = IDE_SYMBOL_FIELD;
+ kind = IDE_SYMBOL_KIND_FIELD;
break;
case CXCursor_InclusionDirective:
- kind = IDE_SYMBOL_HEADER;
+ kind = IDE_SYMBOL_KIND_HEADER;
break;
case CXCursor_VarDecl:
- kind = IDE_SYMBOL_VARIABLE;
+ kind = IDE_SYMBOL_KIND_VARIABLE;
break;
case CXCursor_NamespaceAlias:
- kind = IDE_SYMBOL_NAMESPACE;
+ kind = IDE_SYMBOL_KIND_NAMESPACE;
break;
case CXCursor_CXXMethod:
case CXCursor_Destructor:
case CXCursor_Constructor:
- kind = IDE_SYMBOL_METHOD;
+ kind = IDE_SYMBOL_KIND_METHOD;
break;
case CXCursor_MacroDefinition:
case CXCursor_MacroExpansion:
- kind = IDE_SYMBOL_MACRO;
+ kind = IDE_SYMBOL_KIND_MACRO;
break;
default:
@@ -356,8 +356,7 @@ create_symbol (const gchar *path,
{
g_auto(CXString) cxname = {0};
g_autoptr(GFile) gfile = NULL;
- g_autoptr(IdeFile) ifile = NULL;
- g_autoptr(IdeSourceLocation) srcloc = NULL;
+ g_autoptr(IdeLocation) srcloc = NULL;
IdeSymbolKind symkind;
IdeSymbolFlags symflags = 0;
CXSourceLocation loc;
@@ -376,21 +375,15 @@ create_symbol (const gchar *path,
loc = clang_getCursorLocation (cursor);
clang_getExpansionLocation (loc, NULL, &line, &column, NULL);
gfile = g_file_new_for_path (path);
- ifile = ide_file_new (NULL, gfile);
if (line) line--;
if (column) column--;
- srcloc = ide_source_location_new (ifile, line, column, 0);
+ srcloc = ide_location_new (gfile, line, column);
cxname = clang_getCursorSpelling (cursor);
symkind = ide_clang_get_symbol_kind (cursor, &symflags);
- return ide_symbol_new (clang_getCString (cxname),
- symkind,
- symflags,
- NULL,
- NULL,
- srcloc);
+ return ide_symbol_new (clang_getCString (cxname), symkind, symflags, srcloc, srcloc);
}
static void
@@ -472,28 +465,28 @@ ide_clang_index_symbol_prefix (IdeSymbolKind kind)
{
switch ((int)kind)
{
- case IDE_SYMBOL_FUNCTION:
+ case IDE_SYMBOL_KIND_FUNCTION:
return "f\x1F";
- case IDE_SYMBOL_STRUCT:
+ case IDE_SYMBOL_KIND_STRUCT:
return "s\x1F";
- case IDE_SYMBOL_VARIABLE:
+ case IDE_SYMBOL_KIND_VARIABLE:
return "v\x1F";
- case IDE_SYMBOL_UNION:
+ case IDE_SYMBOL_KIND_UNION:
return "u\x1F";
- case IDE_SYMBOL_ENUM:
+ case IDE_SYMBOL_KIND_ENUM:
return "e\x1F";
- case IDE_SYMBOL_CLASS:
+ case IDE_SYMBOL_KIND_CLASS:
return "c\x1F";
- case IDE_SYMBOL_ENUM_VALUE:
+ case IDE_SYMBOL_KIND_ENUM_VALUE:
return "a\x1F";
- case IDE_SYMBOL_MACRO:
+ case IDE_SYMBOL_KIND_MACRO:
return "m\x1F";
default:
@@ -529,7 +522,7 @@ ide_clang_index_file_visitor (CXCursor cursor,
cxpath = clang_getFileName (file);
path = clang_getCString (cxpath);
- if (dzl_str_equal0 (path, state->path))
+ if (ide_str_equal0 (path, state->path))
{
enum CXCursorKind cursor_kind = clang_getCursorKind (cursor);
@@ -568,7 +561,7 @@ ide_clang_index_file_next_entry (IndexFile *state,
g_auto(CXString) usr = {0};
CXSourceLocation location;
IdeSymbolFlags flags = IDE_SYMBOL_FLAGS_NONE;
- IdeSymbolKind kind = IDE_SYMBOL_NONE;
+ IdeSymbolKind kind = IDE_SYMBOL_KIND_NONE;
enum CXLinkageKind linkage;
enum CXCursorKind cursor_kind;
const gchar *cname = NULL;
@@ -615,7 +608,7 @@ ide_clang_index_file_next_entry (IndexFile *state,
*/
cxname = clang_getCursorSpelling (*cursor);
cname = clang_getCString (cxname);
- if (dzl_str_empty0 (cname))
+ if (ide_str_empty0 (cname))
return NULL;
/*
@@ -736,7 +729,7 @@ ide_clang_index_file_worker (IdeTask *task,
break;
}
-
+
ide_task_return_pointer (task,
g_steal_pointer (&state->entries),
(GDestroyNotify)g_ptr_array_unref);
@@ -885,14 +878,13 @@ get_path (GFile *workdir,
return path_or_uri (child);
}
-static IdeSourceLocation *
+static IdeLocation *
create_location (GFile *workdir,
CXSourceLocation cxloc,
- IdeSourceLocation *alternate)
+ IdeLocation *alternate)
{
g_autofree gchar *path = NULL;
- g_autoptr(IdeFile) file = NULL;
- g_autoptr(GFile) gfile = NULL;
+ g_autoptr(GFile) file = NULL;
g_auto(CXString) str = {0};
CXFile cxfile = NULL;
unsigned line;
@@ -906,7 +898,7 @@ create_location (GFile *workdir,
str = clang_getFileName (cxfile);
if (line == 0 || clang_getCString (str) == NULL)
- return alternate ? ide_source_location_ref (alternate) : NULL;
+ return alternate ? g_object_ref (alternate) : NULL;
if (line > 0)
line--;
@@ -914,24 +906,21 @@ create_location (GFile *workdir,
if (column > 0)
column--;
- /* TODO: Remove IdeFile from IdeSourceLocation */
-
path = get_path (workdir, clang_getCString (str));
- gfile = g_file_new_for_path (path);
- file = ide_file_new (NULL, gfile);
+ file = g_file_new_for_path (path);
- return ide_source_location_new (file, line, column, offset);
+ return ide_location_new (file, line, column);
}
-static IdeSourceRange *
+static IdeRange *
create_range (GFile *workdir,
CXSourceRange cxrange)
{
- IdeSourceRange *range = NULL;
+ IdeRange *range = NULL;
CXSourceLocation cxbegin;
CXSourceLocation cxend;
- g_autoptr(IdeSourceLocation) begin = NULL;
- g_autoptr(IdeSourceLocation) end = NULL;
+ g_autoptr(IdeLocation) begin = NULL;
+ g_autoptr(IdeLocation) end = NULL;
g_assert (G_IS_FILE (workdir));
@@ -939,13 +928,13 @@ create_range (GFile *workdir,
cxend = clang_getRangeEnd (cxrange);
/* Sometimes the end location does not have a file associated with it,
- * so we force it to have the IdeFile of the first location.
+ * so we force it to have the GFile of the first location.
*/
begin = create_location (workdir, cxbegin, NULL);
end = create_location (workdir, cxend, begin);
if ((begin != NULL) && (end != NULL))
- range = ide_source_range_new (begin, end);
+ range = ide_range_new (begin, end);
return range;
}
@@ -955,7 +944,7 @@ create_diagnostic (GFile *workdir,
GFile *target,
CXDiagnostic *cxdiag)
{
- g_autoptr(IdeSourceLocation) loc = NULL;
+ g_autoptr(IdeLocation) loc = NULL;
enum CXDiagnosticSeverity cxseverity;
IdeDiagnosticSeverity severity;
IdeDiagnostic *diag;
@@ -1000,7 +989,7 @@ create_diagnostic (GFile *workdir,
for (guint i = 0; i < num_ranges; i++)
{
CXSourceRange cxrange;
- IdeSourceRange *range;
+ IdeRange *range;
cxrange = clang_getDiagnosticRange (cxdiag, i);
range = create_range (workdir, cxrange);
@@ -1122,7 +1111,7 @@ ide_clang_diagnose_async (IdeClang *self,
else
state->workdir = g_file_new_for_path ((parent = g_path_get_dirname (path)));
- IDE_PTR_ARRAY_SET_FREE_FUNC (state->diagnostics, ide_diagnostic_unref);
+ IDE_PTR_ARRAY_SET_FREE_FUNC (state->diagnostics, ide_object_unref_and_destroy);
task = ide_task_new (self, cancellable, callback, user_data);
ide_task_set_source_tag (task, ide_clang_diagnose_async);
@@ -1154,9 +1143,7 @@ ide_clang_diagnose_finish (IdeClang *self,
ret = ide_task_propagate_pointer (IDE_TASK (result), error);
- IDE_PTR_ARRAY_CLEAR_FREE_FUNC (ret);
-
- return ret;
+ return IDE_PTR_ARRAY_STEAL_FULL (&ret);
}
/* Completion {{{1 */
@@ -1457,7 +1444,7 @@ ide_clang_find_nearest_scope_worker (IdeTask *task,
else
ide_task_return_pointer (task,
g_steal_pointer (&ret),
- (GDestroyNotify)ide_symbol_unref);
+ g_object_unref);
}
void
@@ -1540,9 +1527,8 @@ ide_clang_locate_symbol_worker (IdeTask *task,
GCancellable *cancellable)
{
LocateSymbol *state = task_data;
- g_autoptr(IdeSourceLocation) declaration = NULL;
- g_autoptr(IdeSourceLocation) definition = NULL;
- g_autoptr(IdeSourceLocation) canonical = NULL;
+ g_autoptr(IdeLocation) declaration = NULL;
+ g_autoptr(IdeLocation) definition = NULL;
g_autoptr(IdeSymbol) ret = NULL;
g_auto(CXTranslationUnit) unit = NULL;
g_auto(CXString) cxstr = {0};
@@ -1619,7 +1605,7 @@ ide_clang_locate_symbol_worker (IdeTask *task,
symkind = ide_clang_get_symbol_kind (cursor, &symflags);
- if (symkind == IDE_SYMBOL_HEADER)
+ if (symkind == IDE_SYMBOL_KIND_HEADER)
{
g_auto(CXString) included_file_name = {0};
CXFile included_file;
@@ -1631,24 +1617,19 @@ ide_clang_locate_symbol_worker (IdeTask *task,
if (path != NULL)
{
- g_autoptr(IdeFile) file = NULL;
- g_autoptr(GFile) gfile = NULL;
-
- gfile = g_file_new_for_path (path);
- file = ide_file_new (NULL, gfile);
+ g_autoptr(GFile) file = g_file_new_for_path (path);
- g_clear_pointer (&definition, ide_source_location_unref);
- declaration = ide_source_location_new (file, 0, 0, 0);
+ g_clear_object (&definition);
+ declaration = ide_location_new (file, -1, -1);
}
}
cxstr = clang_getCursorDisplayName (cursor);
- ret = ide_symbol_new (clang_getCString (cxstr), symkind, symflags,
- declaration, definition, canonical);
+ ret = ide_symbol_new (clang_getCString (cxstr), symkind, symflags, declaration, definition);
ide_task_return_pointer (task,
g_steal_pointer (&ret),
- (GDestroyNotify)ide_symbol_unref);
+ g_object_unref);
}
void
@@ -1762,7 +1743,7 @@ cursor_is_recognized (GetSymbolTree *state,
cxloc = clang_getCursorLocation (cursor);
clang_getFileLocation (cxloc, &file, NULL, NULL, NULL);
filename = clang_getFileName (file);
- ret = dzl_str_equal0 (clang_getCString (filename), state->path);
+ ret = ide_str_equal0 (clang_getCString (filename), state->path);
}
break;
diff --git a/src/plugins/clang/ide-clang.h b/src/plugins/clang/ide-clang.h
index 73ec87494..d1a96fc57 100644
--- a/src/plugins/clang/ide-clang.h
+++ b/src/plugins/clang/ide-clang.h
@@ -20,7 +20,7 @@
#pragma once
-#include <ide.h>
+#include <libide-code.h>
G_BEGIN_DECLS
diff --git a/src/plugins/clang/meson.build b/src/plugins/clang/meson.build
index ba5c46a28..01381b74f 100644
--- a/src/plugins/clang/meson.build
+++ b/src/plugins/clang/meson.build
@@ -1,12 +1,6 @@
-if get_option('with_clang')
+if get_option('plugin_clang')
-clang_resources = gnome.compile_resources(
- 'ide-clang-resources',
- 'clang.gresource.xml',
- c_name: 'ide_clang',
-)
-
-clang_sources = [
+plugins_sources += files([
'clang-plugin.c',
'ide-clang-client.c',
'ide-clang-client.h',
@@ -34,13 +28,21 @@ clang_sources = [
'ide-clang-symbol-resolver.h',
'ide-clang-symbol-tree.c',
'ide-clang-symbol-tree.h',
-]
+])
gnome_builder_clang_sources = [
'gnome-builder-clang.c',
'ide-clang.c',
]
+plugin_clang_resources = gnome.compile_resources(
+ 'clang-resources',
+ 'clang.gresource.xml',
+ c_name: 'gbp_clang',
+)
+
+plugins_sources += plugin_clang_resources[0]
+
add_languages('cpp') # Needed for llvm dep
llvm_dep = dependency('llvm', version: '>= 3.5')
clang_include = llvm_dep.get_configtool_variable('includedir')
@@ -59,11 +61,14 @@ clang_includes_dep = declare_dependency(
include_directories: include_directories(clang_include),
)
-gnome_builder_plugins_deps += [clang_includes_dep]
-gnome_builder_plugins_sources += files(clang_sources)
-gnome_builder_plugins_sources += clang_resources[0]
+plugins_deps += [clang_includes_dep]
+
+gnome_builder_clang_deps = [
+ clang_dep,
+ libjsonrpc_glib_dep,
-gnome_builder_clang_deps = [ clang_dep, libide_deps, libide_dep ]
+ libide_code_dep,
+]
executable('gnome-builder-clang', gnome_builder_clang_sources,
dependencies: gnome_builder_clang_deps,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]