[gnome-builder/wip/libide: 88/237] libide: start plumbing IdeFile and IdeLanguage



commit be16bca5fe3cb4a90005a83b004891da3940806a
Author: Christian Hergert <christian hergert me>
Date:   Wed Feb 11 12:24:11 2015 -0800

    libide: start plumbing IdeFile and IdeLanguage

 libide/Makefile.am           |    1 +
 libide/ide-diagnostician.h   |   37 ++++++++
 libide/ide-file.h            |    4 +
 libide/ide-highlighter.h     |   37 ++++++++
 libide/ide-indenter.h        |   15 +--
 libide/ide-language.c        |  210 ++++++++++++++++++++++++++++++++++++++++++
 libide/ide-language.h        |   29 ++++--
 libide/ide-symbol-resolver.h |    9 ++
 libide/ide-types.h           |   20 +---
 libide/ide.h                 |    2 +
 10 files changed, 332 insertions(+), 32 deletions(-)
---
diff --git a/libide/Makefile.am b/libide/Makefile.am
index 424cd88..c80344e 100644
--- a/libide/Makefile.am
+++ b/libide/Makefile.am
@@ -46,6 +46,7 @@ libide_la_SOURCES = \
        libide/ide-file.h \
        libide/ide-global.h \
        libide/ide-indenter.h \
+       libide/ide-language.c \
        libide/ide-language.h \
        libide/ide-object.c \
        libide/ide-object.h \
diff --git a/libide/ide-diagnostician.h b/libide/ide-diagnostician.h
new file mode 100644
index 0000000..ba031b5
--- /dev/null
+++ b/libide/ide-diagnostician.h
@@ -0,0 +1,37 @@
+/* ide-diagnostician.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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_DIAGNOSTICIAN_H
+#define IDE_DIAGNOSTICIAN_H
+
+#include "ide-object.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_DIAGNOSTICIAN (ide_diagnostician_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeDiagnostician, ide_diagnostician, IDE, DIAGNOSTICIAN, IdeObject)
+
+struct _IdeDiagnosticianClass
+{
+  GObjectClass parent;
+};
+
+G_END_DECLS
+
+#endif /* IDE_DIAGNOSTICIAN_H */
diff --git a/libide/ide-file.h b/libide/ide-file.h
index 7b2931c..d7c7b89 100644
--- a/libide/ide-file.h
+++ b/libide/ide-file.h
@@ -32,6 +32,10 @@ struct _IdeFile
   IdeObject parent_instance;
 };
 
+IdeLanguage *ide_file_get_language     (IdeFile *self);
+GFile       *ide_file_get_file         (IdeFile *self);
+const gchar *ide_file_get_project_path (IdeFile *self);
+
 G_END_DECLS
 
 #endif /* IDE_FILE_H */
diff --git a/libide/ide-highlighter.h b/libide/ide-highlighter.h
new file mode 100644
index 0000000..4853b09
--- /dev/null
+++ b/libide/ide-highlighter.h
@@ -0,0 +1,37 @@
+/* ide-highlighter.h
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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_HIGHLIGHTER_H
+#define IDE_HIGHLIGHTER_H
+
+#include "ide-object.h"
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_HIGHLIGHTER (ide_highlighter_get_type())
+
+G_DECLARE_DERIVABLE_TYPE (IdeHighlighter, ide_highlighter, IDE, HIGHLIGHTER, IdeObject)
+
+struct _IdeHighlighterClass
+{
+  GObjectClass parent;
+};
+
+G_END_DECLS
+
+#endif /* IDE_HIGHLIGHTER_H */
diff --git a/libide/ide-indenter.h b/libide/ide-indenter.h
index 5fb5ffb..f007591 100644
--- a/libide/ide-indenter.h
+++ b/libide/ide-indenter.h
@@ -19,22 +19,19 @@
 #ifndef IDE_INDENTER_H
 #define IDE_INDENTER_H
 
-#include <glib-object.h>
+#include "ide-object.h"
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_INDENTER               (ide_indenter_get_type ())
-#define IDE_INDENTER(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_INDENTER, IdeIndenter))
-#define IDE_IS_INDENTER(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_INDENTER))
-#define IDE_INDENTER_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), IDE_TYPE_INDENTER, 
IdeIndenterInterface))
+#define IDE_TYPE_INDENTER (ide_indenter_get_type())
 
-struct _IdeIndenterInterface
+G_DECLARE_DERIVABLE_TYPE (IdeIndenter, ide_indenter, IDE, INDENTER, IdeObject)
+
+struct _IdeIndenterClass
 {
-  GTypeInterface parent;
+  IdeObjectClass parent;
 };
 
-GType ide_indenter_get_type (void);
-
 G_END_DECLS
 
 #endif /* IDE_INDENTER_H */
diff --git a/libide/ide-language.c b/libide/ide-language.c
new file mode 100644
index 0000000..7ae6164
--- /dev/null
+++ b/libide/ide-language.c
@@ -0,0 +1,210 @@
+/* ide-language.c
+ *
+ * Copyright (C) 2015 Christian Hergert <christian hergert me>
+ *
+ * This file is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This file 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
+ * Lesser 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/>.
+ */
+
+#include <glib/gi18n.h>
+
+#include "ide-diagnostician.h"
+#include "ide-highlighter.h"
+#include "ide-indenter.h"
+#include "ide-language.h"
+#include "ide-refactory.h"
+#include "ide-symbol-resolver.h"
+
+typedef struct
+{
+  const gchar *id;
+} IdeLanguagePrivate;
+
+G_DEFINE_TYPE_WITH_PRIVATE (IdeLanguage, ide_language, IDE_TYPE_OBJECT)
+
+enum {
+  PROP_0,
+  PROP_DIAGNOSTICIAN,
+  PROP_HIGHLIGHTER,
+  PROP_INDENTER,
+  PROP_ID,
+  PROP_NAME,
+  PROP_REFACTORY,
+  PROP_SYMBOL_RESOLVER,
+  LAST_PROP
+};
+
+static GParamSpec *gParamSpecs [LAST_PROP];
+
+const gchar *
+ide_language_get_id (IdeLanguage *self)
+{
+  IdeLanguagePrivate *priv = ide_language_get_instance_private (self);
+
+  g_return_val_if_fail (IDE_IS_LANGUAGE (self), NULL);
+
+  return priv->id;
+}
+
+void
+ide_language_set_id (IdeLanguage *self,
+                     const gchar *id)
+{
+  IdeLanguagePrivate *priv = ide_language_get_instance_private (self);
+
+  g_return_if_fail (IDE_IS_LANGUAGE (self));
+  g_return_if_fail (!priv->id);
+
+  priv->id = g_intern_string (id);
+}
+
+static void
+ide_language_get_property (GObject    *object,
+                           guint       prop_id,
+                           GValue     *value,
+                           GParamSpec *pspec)
+{
+  IdeLanguage *self = IDE_LANGUAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_DIAGNOSTICIAN:
+      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;
+
+    case PROP_INDENTER:
+      g_value_set_object (value, ide_language_get_indenter (self));
+      break;
+
+    case PROP_NAME:
+      g_value_set_string (value, ide_language_get_name (self));
+      break;
+
+    case PROP_REFACTORY:
+      g_value_set_object (value, ide_language_get_refactory (self));
+      break;
+
+    case PROP_SYMBOL_RESOLVER:
+      g_value_set_object (value, ide_language_get_symbol_resolver (self));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+ide_language_set_property (GObject      *object,
+                           guint         prop_id,
+                           const GValue *value,
+                           GParamSpec   *pspec)
+{
+  IdeLanguage *self = IDE_LANGUAGE (object);
+
+  switch (prop_id)
+    {
+    case PROP_ID:
+      ide_language_set_id (self, g_value_get_string (value));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+    }
+}
+
+static void
+ide_language_class_init (IdeLanguageClass *klass)
+{
+  GObjectClass *object_class = G_OBJECT_CLASS (klass);
+
+  object_class->get_property = ide_language_get_property;
+  object_class->set_property = ide_language_set_property;
+
+  gParamSpecs [PROP_DIAGNOSTICIAN] =
+    g_param_spec_object ("diagnostician",
+                         _("Diagnostician"),
+                         _("The diagnostician for the language."),
+                         IDE_TYPE_DIAGNOSTICIAN,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_DIAGNOSTICIAN,
+                                   gParamSpecs [PROP_DIAGNOSTICIAN]);
+
+  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));
+  g_object_class_install_property (object_class, PROP_HIGHLIGHTER,
+                                   gParamSpecs [PROP_HIGHLIGHTER]);
+
+  gParamSpecs [PROP_ID] =
+    g_param_spec_string ("id",
+                         _("Id"),
+                         _("The language identifier such as \"c\"."),
+                         NULL,
+                         (G_PARAM_READWRITE |
+                          G_PARAM_CONSTRUCT_ONLY |
+                          G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_ID,
+                                   gParamSpecs [PROP_ID]);
+
+  gParamSpecs [PROP_INDENTER] =
+    g_param_spec_object ("indenter",
+                         _("Indenter"),
+                         _("The semantic indenter for the language."),
+                         IDE_TYPE_INDENTER,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_INDENTER,
+                                   gParamSpecs [PROP_INDENTER]);
+
+  gParamSpecs [PROP_NAME] =
+    g_param_spec_string ("name",
+                         _("Name"),
+                         _("The name of the language."),
+                         NULL,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_NAME,
+                                   gParamSpecs [PROP_NAME]);
+
+  gParamSpecs [PROP_REFACTORY] =
+    g_param_spec_object ("refactory",
+                         _("Refactory"),
+                         _("The refactory engine for the language."),
+                         IDE_TYPE_REFACTORY,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_REFACTORY,
+                                   gParamSpecs [PROP_REFACTORY]);
+
+  gParamSpecs [PROP_SYMBOL_RESOLVER] =
+    g_param_spec_object ("symbol-resolver",
+                         _("Symbol Resolver"),
+                         _("The symbol resolver for the language."),
+                         IDE_TYPE_SYMBOL_RESOLVER,
+                         (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+  g_object_class_install_property (object_class, PROP_SYMBOL_RESOLVER,
+                                   gParamSpecs [PROP_SYMBOL_RESOLVER]);
+}
+
+static void
+ide_language_init (IdeLanguage *self)
+{
+}
diff --git a/libide/ide-language.h b/libide/ide-language.h
index a5d8042..ffbd07d 100644
--- a/libide/ide-language.h
+++ b/libide/ide-language.h
@@ -19,21 +19,34 @@
 #ifndef IDE_LANGUAGE_H
 #define IDE_LANGUAGE_H
 
-#include <glib-object.h>
+#include "ide-object.h"
 
 G_BEGIN_DECLS
 
-#define IDE_TYPE_LANGUAGE               (ide_language_get_type ())
-#define IDE_LANGUAGE(obj)               (G_TYPE_CHECK_INSTANCE_CAST ((obj), IDE_TYPE_LANGUAGE, IdeLanguage))
-#define IDE_IS_LANGUAGE(obj)            (G_TYPE_CHECK_INSTANCE_TYPE ((obj), IDE_TYPE_LANGUAGE))
-#define IDE_LANGUAGE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), IDE_TYPE_LANGUAGE, 
IdeLanguageInterface))
+#define IDE_TYPE_LANGUAGE            (ide_language_get_type())
+#define IDE_LANGUAGE_EXTENSION_POINT "org.gnome.libide.extensions.language"
 
-struct _IdeLanguageInterface
+G_DECLARE_DERIVABLE_TYPE (IdeLanguage, ide_language, IDE, LANGUAGE, IdeObject)
+
+struct _IdeLanguageClass
 {
-  GTypeInterface parent;
+  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);
+  IdeSymbolResolver *(*get_symbol_resolver) (IdeLanguage *self);
 };
 
-GType ide_language_get_type (void);
+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);
+IdeRefactory      *ide_language_get_refactory       (IdeLanguage *self);
+IdeSymbolResolver *ide_language_get_symbol_resolver (IdeLanguage *self);
 
 G_END_DECLS
 
diff --git a/libide/ide-symbol-resolver.h b/libide/ide-symbol-resolver.h
index d6104bf..4b3f4ea 100644
--- a/libide/ide-symbol-resolver.h
+++ b/libide/ide-symbol-resolver.h
@@ -35,6 +35,15 @@ struct _IdeSymbolResolverInterface
 
 GType ide_symbol_resolver_get_type (void);
 
+void       ide_symbol_resolver_lookup_symbol_async  (IdeSymbolResolver    *self,
+                                                     IdeSourceLocation    *location,
+                                                     GCancellable         *cancellable,
+                                                     GAsyncReadyCallback   callback,
+                                                     gpointer              user_data);
+IdeSymbol *ide_symbol_resolver_lookup_symbol_finish (IdeSymbolResolver    *self,
+                                                     GAsyncResult         *result,
+                                                     GError              **error);
+
 G_END_DECLS
 
 #endif /* IDE_SYMBOL_RESOLVER_H */
diff --git a/libide/ide-types.h b/libide/ide-types.h
index 62d0ff3..f84d938 100644
--- a/libide/ide-types.h
+++ b/libide/ide-types.h
@@ -24,7 +24,7 @@
 G_BEGIN_DECLS
 
 #define ide_clear_weak_pointer(ptr) \
-  (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),1) : 0)
+  (*(ptr) ? (g_object_remove_weak_pointer((GObject*)*(ptr), (gpointer*)ptr),*(ptr)=NULL,1) : 0)
 
 #define ide_set_weak_pointer(ptr,obj) \
   ((obj!=*(ptr)) ? (ide_clear_weak_pointer(ptr),*(ptr)=obj,g_object_add_weak_pointer((GObject*)obj, 
(gpointer*)ptr),1) : 0)
@@ -33,12 +33,6 @@ typedef struct _IdeBackForwardItem             IdeBackForwardItem;
 
 typedef struct _IdeBackForwardList             IdeBackForwardList;
 
-typedef struct _IdeBuffer                      IdeBuffer;
-typedef struct _IdeBufferInterface             IdeBufferInterface;
-
-typedef struct _IdeBufferIter                  IdeBufferIter;
-typedef struct _IdeBufferIterInterface         IdeBufferIterInterface;
-
 typedef struct _IdeBuilder                     IdeBuilder;
 
 typedef struct _IdeBuildResult                 IdeBuildResult;
@@ -60,10 +54,10 @@ typedef struct _IdeDeviceProvider              IdeDeviceProvider;
 typedef struct _IdeDeviceProviderInterface     IdeDeviceProviderInterface;
 
 typedef struct _IdeDiagnostic                  IdeDiagnostic;
-typedef struct _IdeDiagnosticInterface         IdeDiagnosticInterface;
+
+typedef struct _IdeDiagnostician               IdeDiagnostician;
 
 typedef struct _IdeDiagnosticProvider          IdeDiagnosticProvider;
-typedef struct _IdeDiagnosticProviderInterface IdeDiagnosticProviderInterface;
 
 typedef struct _IdeExecuter                    IdeExecuter;
 typedef struct _IdeExecuterInterface           IdeExecuterInterface;
@@ -73,11 +67,11 @@ typedef struct _IdeExecutableInterface         IdeExecutableInterface;
 
 typedef struct _IdeFile                        IdeFile;
 
+typedef struct _IdeHighlighter                 IdeHighlighter;
+
 typedef struct _IdeIndenter                    IdeIndenter;
-typedef struct _IdeIndenterInterface           IdeIndenterInterface;
 
 typedef struct _IdeLanguage                    IdeLanguage;
-typedef struct _IdeLanguageInterface           IdeLanguageInterface;
 
 typedef struct _IdeObject                      IdeObject;
 
@@ -96,16 +90,12 @@ typedef struct _IdeRefactory                   IdeRefactory;
 typedef struct _IdeRefactoryInterface          IdeRefactoryInterface;
 
 typedef struct _IdeScript                      IdeScript;
-typedef struct _IdeScriptClass                 IdeScriptClass;
-typedef struct _IdeScriptPrivate               IdeScriptPrivate;
 
 typedef struct _IdeSearchEngine                IdeSearchEngine;
 
 typedef struct _IdeSearchProvider              IdeSearchProvider;
 
 typedef struct _IdeSearchResult                IdeSearchResult;
-typedef struct _IdeSearchResultClass           IdeSearchResultClass;
-typedef struct _IdeSearchResultPrivate         IdeSearchResultPrivate;
 
 typedef struct _IdeService                     IdeService;
 
diff --git a/libide/ide.h b/libide/ide.h
index a518ed6..3762263 100644
--- a/libide/ide.h
+++ b/libide/ide.h
@@ -39,11 +39,13 @@ G_BEGIN_DECLS
 #include "ide-device-provider.h"
 #include "ide-device-manager.h"
 #include "ide-diagnostic.h"
+#include "ide-diagnostician.h"
 #include "ide-diagnostic-provider.h"
 #include "ide-executable.h"
 #include "ide-executer.h"
 #include "ide-file.h"
 #include "ide-global.h"
+#include "ide-highlighter.h"
 #include "ide-indenter.h"
 #include "ide-language.h"
 #include "ide-object.h"


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