[gnome-builder] diagnostics: add IDE_DIAGNOSTIC_DEPRECATED and use it
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] diagnostics: add IDE_DIAGNOSTIC_DEPRECATED and use it
- Date: Sun, 17 May 2015 08:02:32 +0000 (UTC)
commit d5f19af3ec212a3d36cdc54d264f707cf0a2b0cc
Author: Christian Hergert <christian hergert me>
Date: Sun May 17 01:02:18 2015 -0700
diagnostics: add IDE_DIAGNOSTIC_DEPRECATED and use it
The hack turns out to be very similar, since we don't seem to be getting
what I expected to out of clang, but it is much cleaner now and is
available throughout the modules.
libide/clang/ide-clang-translation-unit.c | 12 ++++++++++++
libide/gca/ide-gca-diagnostic-provider.c | 26 ++++++++++++++++++++++++--
libide/ide-buffer.c | 12 +++++-------
libide/ide-diagnostic.c | 4 ++++
libide/ide-diagnostic.h | 11 ++++++-----
tools/ide-list-diagnostics.c | 22 ++++++++++++----------
6 files changed, 63 insertions(+), 24 deletions(-)
---
diff --git a/libide/clang/ide-clang-translation-unit.c b/libide/clang/ide-clang-translation-unit.c
index 3277c20..98c6e60 100644
--- a/libide/clang/ide-clang-translation-unit.c
+++ b/libide/clang/ide-clang-translation-unit.c
@@ -337,6 +337,18 @@ create_diagnostic (IdeClangTranslationUnit *self,
spelling = g_strdup (clang_getCString (cxstr));
clang_disposeString (cxstr);
+ /*
+ * I thought we could use an approach like the following to get deprecation
+ * status. However, it has so far proven ineffective.
+ *
+ * cursor = clang_getCursor (self->tu, cxloc);
+ * avail = clang_getCursorAvailability (cursor);
+ */
+ if ((severity == IDE_DIAGNOSTIC_WARNING) &&
+ (spelling != NULL) &&
+ (strstr (spelling, "deprecated") != NULL))
+ severity = IDE_DIAGNOSTIC_DEPRECATED;
+
loc = create_location (self, project, workpath, cxloc);
diag = _ide_diagnostic_new (severity, spelling, loc);
diff --git a/libide/gca/ide-gca-diagnostic-provider.c b/libide/gca/ide-gca-diagnostic-provider.c
index 15ed483..e7154d1 100644
--- a/libide/gca/ide-gca-diagnostic-provider.c
+++ b/libide/gca/ide-gca-diagnostic-provider.c
@@ -33,6 +33,8 @@
#include "ide-unsaved-file.h"
#include "ide-unsaved-files.h"
+#include "gca-structs.h"
+
struct _IdeGcaDiagnosticProvider
{
IdeDiagnosticProvider parent_instance;
@@ -68,8 +70,28 @@ diagnose_state_free (gpointer data)
static IdeDiagnosticSeverity
get_severity (guint val)
{
- /* these currently map one-to-one */
- return (IdeDiagnosticSeverity)val;
+ switch (val)
+ {
+ case GCA_SEVERITY_INFO:
+ return IDE_DIAGNOSTIC_NOTE;
+
+ case GCA_SEVERITY_WARNING:
+ return IDE_DIAGNOSTIC_WARNING;
+
+ case GCA_SEVERITY_DEPRECATED:
+ return IDE_DIAGNOSTIC_DEPRECATED;
+
+ case GCA_SEVERITY_ERROR:
+ return IDE_DIAGNOSTIC_ERROR;
+
+ case GCA_SEVERITY_FATAL:
+ return IDE_DIAGNOSTIC_FATAL;
+
+ case GCA_SEVERITY_NONE:
+ default:
+ return IDE_DIAGNOSTIC_IGNORED;
+ break;
+ }
}
static IdeDiagnostics *
diff --git a/libide/ide-buffer.c b/libide/ide-buffer.c
index 0bfb0ac..4d38998 100644
--- a/libide/ide-buffer.c
+++ b/libide/ide-buffer.c
@@ -281,7 +281,6 @@ ide_buffer_update_diagnostic (IdeBuffer *self,
IdeBufferPrivate *priv = ide_buffer_get_instance_private (self);
IdeDiagnosticSeverity severity;
const gchar *tag_name = NULL;
- const gchar *text;
IdeSourceLocation *location;
gsize num_ranges;
gsize i;
@@ -290,7 +289,6 @@ ide_buffer_update_diagnostic (IdeBuffer *self,
g_assert (diagnostic);
severity = ide_diagnostic_get_severity (diagnostic);
- text = ide_diagnostic_get_text (diagnostic);
switch (severity)
{
@@ -298,13 +296,12 @@ ide_buffer_update_diagnostic (IdeBuffer *self,
tag_name = TAG_NOTE;
break;
+ case IDE_DIAGNOSTIC_DEPRECATED:
+ tag_name = TAG_DEPRECATED;
+ break;
+
case IDE_DIAGNOSTIC_WARNING:
tag_name = TAG_WARNING;
- /*
- * TODO: We should add a flags bit to diagnostics for deprecation.
- */
- if (text && strstr (text, "deprecated"))
- tag_name = TAG_DEPRECATED;
break;
case IDE_DIAGNOSTIC_ERROR:
@@ -1237,6 +1234,7 @@ ide_buffer_get_line_flags (IdeBuffer *self,
flags |= IDE_BUFFER_LINE_FLAGS_ERROR;
break;
+ case IDE_DIAGNOSTIC_DEPRECATED:
case IDE_DIAGNOSTIC_WARNING:
flags |= IDE_BUFFER_LINE_FLAGS_WARNING;
break;
diff --git a/libide/ide-diagnostic.c b/libide/ide-diagnostic.c
index a7d0373..65f69fb 100644
--- a/libide/ide-diagnostic.c
+++ b/libide/ide-diagnostic.c
@@ -236,6 +236,10 @@ ide_diagnostic_severity_to_string (IdeDiagnosticSeverity severity)
return "ignored";
case IDE_DIAGNOSTIC_NOTE:
+ return "note";
+
+ case IDE_DIAGNOSTIC_DEPRECATED:
+ return "deprecated";
case IDE_DIAGNOSTIC_WARNING:
return "warning";
diff --git a/libide/ide-diagnostic.h b/libide/ide-diagnostic.h
index 9c88d1c..4e93f85 100644
--- a/libide/ide-diagnostic.h
+++ b/libide/ide-diagnostic.h
@@ -28,11 +28,12 @@ G_BEGIN_DECLS
typedef enum
{
- IDE_DIAGNOSTIC_IGNORED = 0,
- IDE_DIAGNOSTIC_NOTE = 1,
- IDE_DIAGNOSTIC_WARNING = 2,
- IDE_DIAGNOSTIC_ERROR = 3,
- IDE_DIAGNOSTIC_FATAL = 4,
+ IDE_DIAGNOSTIC_IGNORED = 0,
+ IDE_DIAGNOSTIC_NOTE = 1,
+ IDE_DIAGNOSTIC_DEPRECATED = 2,
+ IDE_DIAGNOSTIC_WARNING = 3,
+ IDE_DIAGNOSTIC_ERROR = 4,
+ IDE_DIAGNOSTIC_FATAL = 5,
} IdeDiagnosticSeverity;
IdeSourceLocation *ide_diagnostic_get_location (IdeDiagnostic *self);
diff --git a/tools/ide-list-diagnostics.c b/tools/ide-list-diagnostics.c
index 17d8507..de7bbae 100644
--- a/tools/ide-list-diagnostics.c
+++ b/tools/ide-list-diagnostics.c
@@ -43,11 +43,12 @@ severity_to_string (IdeDiagnosticSeverity severity)
{
switch (severity)
{
- case IDE_DIAGNOSTIC_IGNORED: return "ignored:";
- case IDE_DIAGNOSTIC_NOTE: return "note:";
- case IDE_DIAGNOSTIC_WARNING: return "\033[1;35mwarning:\033[0m";
- case IDE_DIAGNOSTIC_ERROR: return "\033[1;31merror:\033[0m";
- case IDE_DIAGNOSTIC_FATAL: return "\033[1;31mfatal error:\033[0m";
+ case IDE_DIAGNOSTIC_IGNORED: return "ignored:";
+ case IDE_DIAGNOSTIC_NOTE: return "note:";
+ case IDE_DIAGNOSTIC_DEPRECATED: return "\033[1;35mdeprecated:\033[0m";
+ case IDE_DIAGNOSTIC_WARNING: return "\033[1;35mwarning:\033[0m";
+ case IDE_DIAGNOSTIC_ERROR: return "\033[1;31merror:\033[0m";
+ case IDE_DIAGNOSTIC_FATAL: return "\033[1;31mfatal error:\033[0m";
default: return "";
}
}
@@ -55,11 +56,12 @@ severity_to_string (IdeDiagnosticSeverity severity)
{
switch (severity)
{
- case IDE_DIAGNOSTIC_IGNORED: return "ignored:";
- case IDE_DIAGNOSTIC_NOTE: return "note:";
- case IDE_DIAGNOSTIC_WARNING: return "warning:";
- case IDE_DIAGNOSTIC_ERROR: return "error:";
- case IDE_DIAGNOSTIC_FATAL: return "fatal error:";
+ case IDE_DIAGNOSTIC_IGNORED: return "ignored:";
+ case IDE_DIAGNOSTIC_NOTE: return "note:";
+ case IDE_DIAGNOSTIC_DEPRECATED: return "deprecated:";
+ case IDE_DIAGNOSTIC_WARNING: return "warning:";
+ case IDE_DIAGNOSTIC_ERROR: return "error:";
+ case IDE_DIAGNOSTIC_FATAL: return "fatal error:";
default: return "";
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]