Permalink
Browse files

1206

  • Loading branch information...
anoopchandu committed Jun 12, 2017
1 parent be2adde commit 64d1de878d91a1f806ca351381d352358603a27a
View
@@ -47,6 +47,7 @@
#include "projects/ide-recent-projects.h"
#include "runner/ide-run-manager.h"
#include "runtimes/ide-runtime-manager.h"
#include "symbols/ide-ast-indexer.h"
#include "search/ide-search-engine.h"
#include "search/ide-search-provider.h"
#include "snippets/ide-source-snippets-manager.h"
@@ -62,6 +63,7 @@ struct _IdeContext
{
GObject parent_instance;
IdeAstIndexer *ast_indexer;
IdeBackForwardList *back_forward_list;
IdeBufferManager *buffer_manager;
IdeBuildManager *build_manager;
@@ -142,6 +144,51 @@ ide_context_get_recent_manager (IdeContext *self)
return self->recent_manager;
}
/**
* ide_context_get_ast_indexer:
*
* Gets an implementation of IdeAstIndexer interface.
*
* Returns: (transfer none): An #IdeAstIndexer.
*/
IdeAstIndexer *
ide_context_get_ast_indexer (IdeContext *self)
{
g_return_val_if_fail (IDE_IS_CONTEXT (self), NULL);
if (self->ast_indexer == NULL)
{
const GList *plugins;
PeasEngine *engine;
engine = peas_engine_get_default ();
plugins = peas_engine_get_plugin_list (engine);
for (;plugins != NULL; plugins = plugins->next)
{
PeasPluginInfo *plugin_info;
plugin_info = plugins->data;
if (peas_engine_provides_extension (engine, plugin_info, IDE_TYPE_AST_INDEXER))
{
PeasExtension *extension;
extension = peas_engine_create_extension (engine, plugin_info,
IDE_TYPE_AST_INDEXER,
"context", self,
NULL);
self->ast_indexer = IDE_AST_INDEXER (extension);
break;
}
}
}
return self->ast_indexer;
}
/**
* ide_context_get_back_forward_list:
*
View
@@ -30,6 +30,7 @@ G_BEGIN_DECLS
G_DECLARE_FINAL_TYPE (IdeContext, ide_context, IDE, CONTEXT, GObject)
IdeAstIndexer *ide_context_get_ast_indexer (IdeContext *self);
IdeBackForwardList *ide_context_get_back_forward_list (IdeContext *self);
GFile *ide_context_get_project_file (IdeContext *self);
IdeBufferManager *ide_context_get_buffer_manager (IdeContext *self);
View
@@ -25,6 +25,8 @@
G_BEGIN_DECLS
typedef struct _IdeAstIndexer IdeAstIndexer;
typedef struct _IdeBackForwardItem IdeBackForwardItem;
typedef struct _IdeBackForwardList IdeBackForwardList;
View
@@ -127,6 +127,7 @@ G_BEGIN_DECLS
#include "sourceview/ide-source-view.h"
#include "subprocess/ide-subprocess.h"
#include "subprocess/ide-subprocess-launcher.h"
#include "symbols/ide-ast-indexer.h"
#include "symbols/ide-symbol-resolver.h"
#include "symbols/ide-symbol.h"
#include "symbols/ide-tags-builder.h"
View
@@ -145,6 +145,7 @@ libide_public_headers = [
'subprocess/ide-subprocess.h',
'subprocess/ide-subprocess-launcher.h',
'subprocess/ide-subprocess-supervisor.h',
'symbols/ide-ast-indexer.h',
'symbols/ide-symbol-node.h',
'symbols/ide-symbol-resolver.h',
'symbols/ide-symbol-tree.h',
@@ -339,6 +340,7 @@ libide_public_sources = [
'subprocess/ide-subprocess.c',
'subprocess/ide-subprocess-launcher.c',
'subprocess/ide-subprocess-supervisor.c',
'symbols/ide-ast-indexer.c',
'symbols/ide-symbol-node.c',
'symbols/ide-symbol-resolver.c',
'symbols/ide-symbol-tree.c',
@@ -0,0 +1,69 @@
/* ide-ast-indexer.c
*
* Copyright (C) 2017 Anoop Chandu <anoopchandu96@gmail.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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define G_LOG_DOMAIN "ide-ast-indexer"
#include "ide-ast-indexer.h"
G_DEFINE_INTERFACE (IdeAstIndexer, ide_ast_indexer, IDE_TYPE_OBJECT)
static void
ide_ast_indexer_default_init (IdeAstIndexerInterface *iface)
{
}
void
ide_ast_indexer_index_async (IdeAstIndexer *self,
GPtrArray *files,
GHashTable *fileids,
GFile *destination,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data)
{
IdeAstIndexerInterface *iface;
g_return_if_fail (IDE_IS_AST_INDEXER (self));
iface = IDE_AST_INDEXER_GET_IFACE (self);
if (iface->index_async != NULL)
iface->index_async (self,
files,fileids,
destination,
cancellable, callback,
user_data);
}
gpointer
ide_ast_indexer_index_finish (IdeAstIndexer *self,
GAsyncResult *result,
GError **error)
{
IdeAstIndexerInterface *iface;
g_return_val_if_fail (IDE_IS_AST_INDEXER (self), NULL);
iface = IDE_AST_INDEXER_GET_IFACE (self);
if (iface->index_finish != NULL)
return iface->index_finish (self, result, error);
else
return NULL;
}
@@ -0,0 +1,59 @@
/* ide-ast-indexer.h
*
* Copyright (C) 2017 Anoop Chandu <anoopchandu96@gmail.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
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef IDE_AST_INDEXER_H
#define IDE_AST_INDEXER_H
#include "ide-object.h"
G_BEGIN_DECLS
#define IDE_TYPE_AST_INDEXER (ide_ast_indexer_get_type())
G_DECLARE_INTERFACE (IdeAstIndexer, ide_ast_indexer, IDE, AST_INDEXER, IdeObject)
struct _IdeAstIndexerInterface
{
GTypeInterface parent_interface;
void (*index_async) (IdeAstIndexer *self,
GPtrArray *files,
GHashTable *fileids,
GFile *destination,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gpointer (*index_finish) (IdeAstIndexer *self,
GAsyncResult *result,
GError **error);
};
void ide_ast_indexer_index_async (IdeAstIndexer *self,
GPtrArray *files,
GHashTable *fileids,
GFile *destination,
GCancellable *cancellable,
GAsyncReadyCallback callback,
gpointer user_data);
gpointer ide_ast_indexer_index_finish (IdeAstIndexer *self,
GAsyncResult *result,
GError **error);
G_END_DECLS
#endif /* IDE_AST_INDEXER */
View
@@ -39,6 +39,7 @@ option('with_gnome_code_assistance', type: 'boolean')
option('with_hello_cpp', type: 'boolean')
option('with_html_completion', type: 'boolean')
option('with_html_preview', type: 'boolean')
option('with_indexer', type: 'boolean')
option('with_jedi', type: 'boolean')
option('with_jhbuild', type: 'boolean')
option('with_make', type: 'boolean')
@@ -19,6 +19,7 @@
#include <libpeas/peas.h>
#include <ide.h>
#include "ide-clang-ast-indexer.h"
#include "ide-clang-completion-item.h"
#include "ide-clang-completion-provider.h"
#include "ide-clang-diagnostic-provider.h"
@@ -34,6 +35,9 @@
void
peas_register_types (PeasObjectModule *module)
{
peas_object_module_register_extension_type (module,
IDE_TYPE_AST_INDEXER,
IDE_TYPE_CLANG_AST_INDEXER);
peas_object_module_register_extension_type (module,
IDE_TYPE_HIGHLIGHTER,
IDE_TYPE_CLANG_HIGHLIGHTER);
Oops, something went wrong.

0 comments on commit 64d1de8

Please sign in to comment.