[gnome-builder/wip/extensions] language: remove IdeLanguage::get_highlighter
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder/wip/extensions] language: remove IdeLanguage::get_highlighter
- Date: Sat, 27 Jun 2015 07:35:07 +0000 (UTC)
commit 105950eb0ee0b901e76ef9159abc8d3d393aaa21
Author: Christian Hergert <christian hergert me>
Date: Sat Jun 27 00:35:00 2015 -0700
language: remove IdeLanguage::get_highlighter
Instead we will use extension points to get the highlighter.
This still lacks monitoring of the extension point for changes to the
preferred implementation.
libide/c/ide-c-language.c | 53 ----------------------------------
libide/html/ide-html-language.c | 27 +----------------
libide/ide-buffer.c | 22 ++++++++++----
libide/ide-language.c | 60 ---------------------------------------
libide/ide-language.h | 2 -
libide/ide.c | 19 ++++++------
libide/xml/ide-xml-language.c | 34 +--------------------
7 files changed, 30 insertions(+), 187 deletions(-)
---
diff --git a/libide/c/ide-c-language.c b/libide/c/ide-c-language.c
index 343b390..20187f2 100644
--- a/libide/c/ide-c-language.c
+++ b/libide/c/ide-c-language.c
@@ -25,23 +25,17 @@
#include "ide-c-language.h"
#include "ide-clang-completion-provider.h"
#include "ide-clang-diagnostic-provider.h"
-#include "ide-clang-highlighter.h"
#include "ide-clang-symbol-resolver.h"
#include "ide-diagnostician.h"
#include "ide-extension-point.h"
#include "ide-internal.h"
-#define C_HIGHLIGHTER "org.gnome.builder.highlighter.c"
-
typedef struct
{
IdeDiagnostician *diagnostician;
- IdeHighlighter *highlighter;
IdeIndenter *indenter;
IdeRefactory *refactory;
IdeSymbolResolver *symbol_resolver;
-
- EggSignalGroup *highlighter_extension_signals;
} IdeCLanguagePrivate;
static void _g_initable_iface_init (GInitableIface *iface);
@@ -76,17 +70,6 @@ ide_c_language_get_diagnostician (IdeLanguage *language)
return priv->diagnostician;
}
-static IdeHighlighter *
-ide_c_language_get_highlighter (IdeLanguage *language)
-{
- IdeCLanguage *self = (IdeCLanguage *)language;
- IdeCLanguagePrivate *priv = ide_c_language_get_instance_private (self);
-
- g_return_val_if_fail (IDE_IS_C_LANGUAGE (self), NULL);
-
- return priv->highlighter;
-}
-
static IdeIndenter *
ide_c_language_get_indenter (IdeLanguage *language)
{
@@ -127,38 +110,12 @@ ide_c_language_get_name (IdeLanguage *self)
}
static void
-highlighter_changed (IdeCLanguage *self,
- IdeExtensionPoint *point)
-{
- IdeCLanguagePrivate *priv = ide_c_language_get_instance_private (self);
- IdeContext *context = ide_object_get_context (IDE_OBJECT (self));
-
- g_clear_object (&priv->highlighter);
- priv->highlighter = ide_extension_point_create (C_HIGHLIGHTER,
- "context", context,
- NULL);
-}
-
-static void
-ide_c_language_constructed (GObject *object)
-{
- IdeCLanguage *self = (IdeCLanguage *)object;
-
- highlighter_changed (self, NULL);
-
- G_OBJECT_CLASS (ide_c_language_parent_class)->constructed (object);
-}
-
-static void
ide_c_language_dispose (GObject *object)
{
IdeCLanguage *self = (IdeCLanguage *)object;
IdeCLanguagePrivate *priv = ide_c_language_get_instance_private (self);
- g_clear_object (&priv->highlighter_extension_signals);
- g_clear_object (&priv->highlighter);
g_clear_object (&priv->diagnostician);
- g_clear_object (&priv->highlighter);
g_clear_object (&priv->indenter);
g_clear_object (&priv->refactory);
g_clear_object (&priv->symbol_resolver);
@@ -174,27 +131,17 @@ ide_c_language_class_init (IdeCLanguageClass *klass)
language_class->get_completion_providers = ide_c_language_get_completion_providers;
language_class->get_diagnostician = ide_c_language_get_diagnostician;
- language_class->get_highlighter = ide_c_language_get_highlighter;
language_class->get_indenter = ide_c_language_get_indenter;
language_class->get_refactory = ide_c_language_get_refactory;
language_class->get_symbol_resolver = ide_c_language_get_symbol_resolver;
language_class->get_name = ide_c_language_get_name;
- object_class->constructed = ide_c_language_constructed;
object_class->dispose = ide_c_language_dispose;
}
static void
ide_c_language_init (IdeCLanguage *self)
{
- IdeCLanguagePrivate *priv = ide_c_language_get_instance_private (self);
-
- priv->highlighter_extension_signals = egg_signal_group_new (IDE_TYPE_EXTENSION_POINT);
- egg_signal_group_connect_object (priv->highlighter_extension_signals,
- "changed",
- G_CALLBACK (highlighter_changed),
- self,
- G_CONNECT_SWAPPED);
}
static gboolean
diff --git a/libide/html/ide-html-language.c b/libide/html/ide-html-language.c
index 10f2bb9..6d438d5 100644
--- a/libide/html/ide-html-language.c
+++ b/libide/html/ide-html-language.c
@@ -20,15 +20,13 @@
#include "ide-html-completion-provider.h"
#include "ide-html-language.h"
-#include "ide-xml-highlighter.h"
#include "ide-xml-indenter.h"
struct _IdeHtmlLanguage
{
- IdeLanguage parent_instance;
+ IdeLanguage parent_instance;
- IdeXmlIndenter *indenter;
- IdeXmlHighlighter *highlighter;
+ IdeXmlIndenter *indenter;
};
static void initable_iface_init (GInitableIface *iface);
@@ -70,26 +68,6 @@ ide_html_language_get_indenter (IdeLanguage *language)
return IDE_INDENTER (self->indenter);
}
-static IdeHighlighter *
-ide_html_language_get_highlighter (IdeLanguage *language)
-{
- IdeHtmlLanguage *self = (IdeHtmlLanguage *)language;
-
- g_assert (IDE_IS_HTML_LANGUAGE (self));
-
- if (!self->highlighter)
- {
- IdeContext *context;
-
- context = ide_object_get_context (IDE_OBJECT (language));
- self->highlighter = g_object_new (IDE_TYPE_XML_HIGHLIGHTER,
- "context", context,
- NULL);
- }
-
- return IDE_HIGHLIGHTER (self->highlighter);
-}
-
static void
ide_html_language_finalize (GObject *object)
{
@@ -109,7 +87,6 @@ ide_html_language_class_init (IdeHtmlLanguageClass *klass)
object_class->finalize = ide_html_language_finalize;
language_class->get_completion_providers = ide_html_language_get_completion_providers;
- language_class->get_highlighter = ide_html_language_get_highlighter;
language_class->get_indenter = ide_html_language_get_indenter;
}
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 1199697..726b0ab 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -31,6 +31,7 @@
#include "ide-diagnostic.h"
#include "ide-diagnostician.h"
#include "ide-diagnostics.h"
+#include "ide-extension-point.h"
#include "ide-file.h"
#include "ide-file-settings.h"
#include "ide-highlighter.h"
@@ -565,20 +566,29 @@ ide_buffer_reload_highlighter (IdeBuffer *self)
{
IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
IdeHighlighter *highlighter = NULL;
+ IdeLanguage *language;
g_assert (IDE_IS_BUFFER (self));
- if (priv->file != NULL)
- {
- IdeLanguage *language;
+ language = ide_file_get_language (priv->file);
- language = ide_file_get_language (priv->file);
- if (language != NULL)
- highlighter = ide_language_get_highlighter (language);
+ if (language != NULL)
+ {
+ const gchar *lang_id;
+ gchar *name;
+
+ lang_id = ide_language_get_id (language);
+ name = g_strdup_printf ("org.gnome.builder.highlighter.%s", lang_id);
+ highlighter = ide_extension_point_create (name,
+ "context", priv->context,
+ NULL);
+ g_free (name);
}
if (priv->highlight_engine != NULL)
ide_highlight_engine_set_highlighter (priv->highlight_engine, highlighter);
+
+ g_clear_object (&highlighter);
}
static void
diff --git a/libide/ide-language.c b/libide/ide-language.c
index d284659..cbaf901 100644
--- a/libide/ide-language.c
+++ b/libide/ide-language.c
@@ -22,7 +22,6 @@
#include "ide-ctags-service.h"
#include "ide-diagnostician.h"
#include "ide-gca-diagnostic-provider.h"
-#include "ide-highlighter.h"
#include "ide-indenter.h"
#include "ide-internal.h"
#include "ide-language.h"
@@ -39,7 +38,6 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeLanguage, ide_language, IDE_TYPE_OBJECT)
enum {
PROP_0,
PROP_DIAGNOSTICIAN,
- PROP_HIGHLIGHTER,
PROP_INDENTER,
PROP_ID,
PROP_NAME,
@@ -173,52 +171,6 @@ ide_language_real_get_diagnostician (IdeLanguage *self)
return gDiagnostician;
}
-static IdeHighlighter *
-ide_language_real_get_highlighter (IdeLanguage *self)
-{
- IdeLanguagePrivate *priv = ide_language_get_instance_private (self);
-
- g_assert (IDE_IS_LANGUAGE (self));
-
- if (ide_str_equal0 (priv->id, "c") ||
- ide_str_equal0 (priv->id, "cpp") ||
- ide_str_equal0 (priv->id, "chdr") ||
- ide_str_equal0 (priv->id, "python") ||
- ide_str_equal0 (priv->id, "js") ||
- ide_str_equal0 (priv->id, "css") ||
- ide_str_equal0 (priv->id, "html"))
- {
- IdeCtagsService *service;
- IdeContext *context;
-
- context = ide_object_get_context (IDE_OBJECT (self));
- service = ide_context_get_service_typed (context, IDE_TYPE_CTAGS_SERVICE);
- return ide_ctags_service_get_highlighter (service);
- }
-
- return NULL;
-}
-
-/**
- * ide_language_get_highlighter:
- *
- * Fetches the #IdeHighlighter for the #IdeLanguage.
- *
- * If @language does not provide a semantic highlighter, %NULL is returned.
- *
- * Returns: (transfer none) (nullable): An #IdeHighlighter or %NULL.
- */
-IdeHighlighter *
-ide_language_get_highlighter (IdeLanguage *self)
-{
- g_return_val_if_fail (IDE_IS_LANGUAGE (self), NULL);
-
- if (IDE_LANGUAGE_GET_CLASS (self)->get_highlighter)
- return IDE_LANGUAGE_GET_CLASS (self)->get_highlighter (self);
-
- return NULL;
-}
-
/**
* ide_language_get_indenter:
*
@@ -340,10 +292,6 @@ ide_language_get_property (GObject *object,
g_value_set_object (value, ide_language_get_diagnostician (self));
break;
- case PROP_HIGHLIGHTER:
- g_value_set_object (value, ide_language_get_highlighter (self));
- break;
-
case PROP_ID:
g_value_set_string (value, ide_language_get_id (self));
break;
@@ -398,7 +346,6 @@ ide_language_class_init (IdeLanguageClass *klass)
klass->get_completion_providers = ide_language_real_get_completion_providers;
klass->get_diagnostician = ide_language_real_get_diagnostician;
- klass->get_highlighter = ide_language_real_get_highlighter;
gParamSpecs [PROP_DIAGNOSTICIAN] =
g_param_spec_object ("diagnostician",
@@ -407,13 +354,6 @@ ide_language_class_init (IdeLanguageClass *klass)
IDE_TYPE_DIAGNOSTICIAN,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
- gParamSpecs [PROP_HIGHLIGHTER] =
- g_param_spec_object ("highlighter",
- _("Highlighter"),
- _("The semantic highlighter for the language."),
- IDE_TYPE_HIGHLIGHTER,
- (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
-
gParamSpecs [PROP_ID] =
g_param_spec_string ("id",
_("ID"),
diff --git a/libide/ide-language.h b/libide/ide-language.h
index 6fe6039..c7193a8 100644
--- a/libide/ide-language.h
+++ b/libide/ide-language.h
@@ -35,7 +35,6 @@ struct _IdeLanguageClass
IdeObjectClass parent;
IdeDiagnostician *(*get_diagnostician) (IdeLanguage *self);
- IdeHighlighter *(*get_highlighter) (IdeLanguage *self);
IdeIndenter *(*get_indenter) (IdeLanguage *self);
const gchar *(*get_name) (IdeLanguage *self);
IdeRefactory *(*get_refactory) (IdeLanguage *self);
@@ -45,7 +44,6 @@ struct _IdeLanguageClass
};
IdeDiagnostician *ide_language_get_diagnostician (IdeLanguage *self);
-IdeHighlighter *ide_language_get_highlighter (IdeLanguage *self);
const gchar *ide_language_get_id (IdeLanguage *self);
IdeIndenter *ide_language_get_indenter (IdeLanguage *self);
const gchar *ide_language_get_name (IdeLanguage *self);
diff --git a/libide/ide.c b/libide/ide.c
index b4b27ce..508f94e 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -90,6 +90,8 @@ static void
ide_init_ctor (void)
{
GgitFeatureFlags ggit_flags;
+ const gchar *ctags_types[] = { "c", "cpp", "chdr", "python", "js", "css", "html", NULL };
+ gint i;
g_irepository_prepend_search_path (LIBDIR"/gnome-builder/girepository-1.0");
@@ -124,15 +126,14 @@ ide_init_ctor (void)
IDE_TYPE_CLANG_HIGHLIGHTER,
0);
- ide_extension_point_implement ("org.gnome.builder.highlighter.c",
- IDE_TYPE_CTAGS_HIGHLIGHTER,
- 100);
- ide_extension_point_implement ("org.gnome.builder.highlighter.cpp",
- IDE_TYPE_CTAGS_HIGHLIGHTER,
- 100);
- ide_extension_point_implement ("org.gnome.builder.highlighter.chdr",
- IDE_TYPE_CTAGS_HIGHLIGHTER,
- 100);
+ for (i = 0; ctags_types [i]; i++)
+ {
+ gchar *name;
+
+ name = g_strdup_printf ("org.gnome.builder.highlighter.%s", ctags_types [i]);
+ ide_extension_point_implement (name, IDE_TYPE_CTAGS_HIGHLIGHTER, 100);
+ g_free (name);
+ }
g_io_extension_point_implement (IDE_BUILD_SYSTEM_EXTENSION_POINT,
IDE_TYPE_AUTOTOOLS_BUILD_SYSTEM,
diff --git a/libide/xml/ide-xml-language.c b/libide/xml/ide-xml-language.c
index af6d922..59bc3be 100644
--- a/libide/xml/ide-xml-language.c
+++ b/libide/xml/ide-xml-language.c
@@ -19,14 +19,12 @@
#include "ide-extension-point.h"
#include "ide-xml-language.h"
#include "ide-xml-indenter.h"
-#include "ide-xml-highlighter.h"
struct _IdeXmlLanguage
{
- IdeLanguage parent_instance;
+ IdeLanguage parent_instance;
- IdeXmlIndenter *indenter;
- IdeXmlHighlighter *highlighter;
+ IdeXmlIndenter *indenter;
};
static void initable_iface_init (GInitableIface *iface);
@@ -55,33 +53,6 @@ ide_xml_language_get_indenter (IdeLanguage *language)
return IDE_INDENTER (self->indenter);
}
-static IdeHighlighter *
-ide_xml_language_get_highlighter (IdeLanguage *language)
-{
- IdeXmlLanguage *self = (IdeXmlLanguage *)language;
-
- g_return_val_if_fail (IDE_IS_XML_LANGUAGE (self), NULL);
-
- if (!self->highlighter)
- {
- IdeContext *context;
-
- context = ide_object_get_context (IDE_OBJECT (language));
-
- /*
- * TODO: This should all go, once we get rid of IdeLanguage.
- * Now that we have access to extension points, we should
- * be able to put this into IdeBuffer and (un)hook things
- * as plugins are (un)loaded.
- */
- self->highlighter = ide_extension_point_create ("org.gnome.builder.highlighter.xml",
- "context", context,
- NULL);
- }
-
- return IDE_HIGHLIGHTER (self->highlighter);
-}
-
static void
ide_xml_language_finalize (GObject *object)
{
@@ -99,7 +70,6 @@ ide_xml_language_class_init (IdeXmlLanguageClass *klass)
IdeLanguageClass *language_class = IDE_LANGUAGE_CLASS (klass);
object_class->finalize = ide_xml_language_finalize;
- language_class->get_highlighter = ide_xml_language_get_highlighter;
language_class->get_indenter = ide_xml_language_get_indenter;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]