[gnome-builder] libide: use IdeCLanguage for C headers and C++ (for now)



commit 9fa3bcb0c9afece1cf29e4b61ea3525b87783a31
Author: Christian Hergert <christian hergert me>
Date:   Thu Feb 12 11:27:37 2015 -0800

    libide: use IdeCLanguage for C headers and C++ (for now)

 libide/c/ide-c-language.c |    5 ++++-
 libide/ide-file.c         |   20 +++++++++++++++++++-
 libide/ide.c              |    2 +-
 3 files changed, 24 insertions(+), 3 deletions(-)
---
diff --git a/libide/c/ide-c-language.c b/libide/c/ide-c-language.c
index 7b7ae09..5ca13be 100644
--- a/libide/c/ide-c-language.c
+++ b/libide/c/ide-c-language.c
@@ -153,7 +153,9 @@ ide_c_language_initiable_init (GInitable     *initable,
 
   id = ide_language_get_id (IDE_LANGUAGE (self));
 
-  if ((g_strcmp0 (id, "c") == 0) || (g_strcmp0 (id, "chdr") == 0))
+  if ((g_strcmp0 (id, "c") == 0) ||
+      (g_strcmp0 (id, "chdr") == 0) ||
+      (g_strcmp0 (id, "cpp") == 0))
     {
       IdeContext *context;
       IdeDiagnosticProvider *provider;
@@ -182,6 +184,7 @@ ide_c_language_initiable_init (GInitable     *initable,
       /*
        * Create our indenter to provide as-you-type indentation.
        */
+      /* TODO: Obviously change for C++ */
       priv->indenter = g_object_new (IDE_TYPE_C_INDENTER,
                                      "context", context,
                                      NULL);
diff --git a/libide/ide-file.c b/libide/ide-file.c
index 7e19f59..737c72f 100644
--- a/libide/ide-file.c
+++ b/libide/ide-file.c
@@ -39,6 +39,22 @@ G_DEFINE_TYPE_WITH_PRIVATE (IdeFile, ide_file, IDE_TYPE_OBJECT)
 
 static GParamSpec *gParamSpecs [LAST_PROP];
 
+static const gchar *
+ide_file_remap_language (const gchar *lang_id)
+{
+  if (!lang_id)
+    return NULL;
+
+  if (g_str_equal (lang_id, "chdr") ||
+      g_str_equal (lang_id, "cpp"))
+    return "c";
+
+  if (g_str_equal (lang_id, "python3"))
+    return "python";
+
+  return lang_id;
+}
+
 guint
 ide_file_hash (IdeFile *self)
 {
@@ -97,9 +113,11 @@ ide_file_create_language (IdeFile *self)
           g_autoptr(gchar) ext_name = NULL;
           GIOExtension *extension;
           GIOExtensionPoint *point;
+          const gchar *lookup_id;
 
           lang_id = gtk_source_language_get_id (srclang);
-          ext_name = g_strdup_printf (IDE_LANGUAGE_EXTENSION_POINT".%s", lang_id);
+          lookup_id = ide_file_remap_language (lang_id);
+          ext_name = g_strdup_printf (IDE_LANGUAGE_EXTENSION_POINT".%s", lookup_id);
           point = g_io_extension_point_lookup (IDE_LANGUAGE_EXTENSION_POINT);
           extension = g_io_extension_point_get_extension_by_name (point, ext_name);
 
diff --git a/libide/ide.c b/libide/ide.c
index 6aaeed7..62f58ed 100644
--- a/libide/ide.c
+++ b/libide/ide.c
@@ -76,7 +76,7 @@ ide_init_ctor (void)
   g_io_extension_point_implement (IDE_LANGUAGE_EXTENSION_POINT,
                                   IDE_TYPE_C_LANGUAGE,
                                   IDE_LANGUAGE_EXTENSION_POINT".c",
-                                  0);
+                                  -100);
 
   g_io_extension_point_implement (IDE_SERVICE_EXTENSION_POINT,
                                   IDE_TYPE_CLANG_SERVICE,


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