[gnome-builder] clang: allow disabling diagnostics provided by clang



commit 2eacf1c9d3cb153ef759898ec107dee885675606
Author: Christian Hergert <christian hergert me>
Date:   Sun Feb 21 19:28:16 2016 -0800

    clang: allow disabling diagnostics provided by clang
    
    For those that find inline clang warnings annoying, now you can disable
    them with this one easy trick!

 plugins/clang/Makefile.am                   |    2 +
 plugins/clang/clang-plugin.c                |    4 +
 plugins/clang/ide-clang-preferences-addin.c |   86 +++++++++++++++++++++++++++
 plugins/clang/ide-clang-preferences-addin.h |   32 ++++++++++
 4 files changed, 124 insertions(+), 0 deletions(-)
---
diff --git a/plugins/clang/Makefile.am b/plugins/clang/Makefile.am
index deb4537..5b2976b 100644
--- a/plugins/clang/Makefile.am
+++ b/plugins/clang/Makefile.am
@@ -16,6 +16,8 @@ libclang_plugin_la_SOURCES = \
        ide-clang-diagnostic-provider.h \
        ide-clang-highlighter.c \
        ide-clang-highlighter.h \
+       ide-clang-preferences-addin.c \
+       ide-clang-preferences-addin.h \
        ide-clang-private.h \
        ide-clang-service.c \
        ide-clang-service.h \
diff --git a/plugins/clang/clang-plugin.c b/plugins/clang/clang-plugin.c
index aa69488..42278b5 100644
--- a/plugins/clang/clang-plugin.c
+++ b/plugins/clang/clang-plugin.c
@@ -23,6 +23,7 @@
 #include "ide-clang-completion-provider.h"
 #include "ide-clang-diagnostic-provider.h"
 #include "ide-clang-highlighter.h"
+#include "ide-clang-preferences-addin.h"
 #include "ide-clang-private.h"
 #include "ide-clang-service.h"
 #include "ide-clang-symbol-node.h"
@@ -48,4 +49,7 @@ peas_register_types (PeasObjectModule *module)
   peas_object_module_register_extension_type (module,
                                               IDE_TYPE_COMPLETION_PROVIDER,
                                               IDE_TYPE_CLANG_COMPLETION_PROVIDER);
+  peas_object_module_register_extension_type (module,
+                                              IDE_TYPE_PREFERENCES_ADDIN,
+                                              IDE_TYPE_CLANG_PREFERENCES_ADDIN);
 }
diff --git a/plugins/clang/ide-clang-preferences-addin.c b/plugins/clang/ide-clang-preferences-addin.c
new file mode 100644
index 0000000..37c0192
--- /dev/null
+++ b/plugins/clang/ide-clang-preferences-addin.c
@@ -0,0 +1,86 @@
+/* ide-clang-preferences-addin.c
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * 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/>.
+ */
+
+#include <glib/gi18n.h>
+#include <ide.h>
+
+#include "ide-clang-preferences-addin.h"
+
+struct _IdeClangPreferencesAddin
+{
+  GObject parent;
+  guint   diagnose_id;
+};
+
+static void preferences_addin_iface_init (IdePreferencesAddinInterface *iface);
+
+G_DEFINE_TYPE_EXTENDED (IdeClangPreferencesAddin, ide_clang_preferences_addin, G_TYPE_OBJECT, 0,
+                        G_IMPLEMENT_INTERFACE (IDE_TYPE_PREFERENCES_ADDIN,
+                                               preferences_addin_iface_init))
+
+static void
+ide_clang_preferences_addin_class_init (IdeClangPreferencesAddinClass *klass)
+{
+}
+
+static void
+ide_clang_preferences_addin_init (IdeClangPreferencesAddin *self)
+{
+}
+
+static void
+ide_clang_preferences_addin_load (IdePreferencesAddin *addin,
+                                  IdePreferences      *preferences)
+{
+  IdeClangPreferencesAddin *self = (IdeClangPreferencesAddin *)addin;
+
+  g_assert (IDE_IS_CLANG_PREFERENCES_ADDIN (addin));
+  g_assert (IDE_IS_PREFERENCES (preferences));
+
+  self->diagnose_id = ide_preferences_add_switch (preferences,
+                                                  "code-insight",
+                                                  "diagnostics",
+                                                  "org.gnome.builder.extension-type",
+                                                  "enabled",
+                                                  
"/org/gnome/builder/extension-types/clang-plugin/IdeDiagnosticProvider/",
+                                                  NULL,
+                                                  _("Clang"),
+                                                  _("Show errors and warnings provided by Clang"),
+                                                  /* translators: keywords used when searching for 
preferences */
+                                                  _("clang diagnostics warnings errors"),
+                                                  50);
+}
+
+static void
+ide_clang_preferences_addin_unload (IdePreferencesAddin *addin,
+                                    IdePreferences      *preferences)
+{
+  IdeClangPreferencesAddin *self = (IdeClangPreferencesAddin *)addin;
+
+  g_assert (IDE_IS_CLANG_PREFERENCES_ADDIN (addin));
+  g_assert (IDE_IS_PREFERENCES (preferences));
+
+  ide_preferences_remove_id (preferences, self->diagnose_id);
+}
+
+static void
+preferences_addin_iface_init (IdePreferencesAddinInterface *iface)
+{
+  iface->load = ide_clang_preferences_addin_load;
+  iface->unload = ide_clang_preferences_addin_unload;
+}
diff --git a/plugins/clang/ide-clang-preferences-addin.h b/plugins/clang/ide-clang-preferences-addin.h
new file mode 100644
index 0000000..9e80e29
--- /dev/null
+++ b/plugins/clang/ide-clang-preferences-addin.h
@@ -0,0 +1,32 @@
+/* ide-clang-preferences-addin.h
+ *
+ * Copyright (C) 2016 Christian Hergert <christian hergert me>
+ *
+ * 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_CLANG_PREFERENCES_ADDIN_H
+#define IDE_CLANG_PREFERENCES_ADDIN_H
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS
+
+#define IDE_TYPE_CLANG_PREFERENCES_ADDIN (ide_clang_preferences_addin_get_type())
+
+G_DECLARE_FINAL_TYPE (IdeClangPreferencesAddin, ide_clang_preferences_addin, IDE, CLANG_PREFERENCES_ADDIN, 
GObject)
+
+G_END_DECLS
+
+#endif /* IDE_CLANG_PREFERENCES_ADDIN_H */


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