[gnome-builder] libide: add function to create diagnostic
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide: add function to create diagnostic
- Date: Mon, 23 Mar 2015 23:27:58 +0000 (UTC)
commit fb45d6916b280cce65416e03fc6a94bfc8dfb41c
Author: Christian Hergert <christian hergert me>
Date: Wed Feb 11 22:30:36 2015 -0800
libide: add function to create diagnostic
This will of course be expanded as we add the rest of the fields.
libide/clang/ide-clang-translation-unit.c | 47 +++++++++++++++++++++++++++--
1 files changed, 44 insertions(+), 3 deletions(-)
---
diff --git a/libide/clang/ide-clang-translation-unit.c b/libide/clang/ide-clang-translation-unit.c
index 9ce5f11..756eeb1 100644
--- a/libide/clang/ide-clang-translation-unit.c
+++ b/libide/clang/ide-clang-translation-unit.c
@@ -66,6 +66,47 @@ _ide_clang_translation_unit_new (IdeContext *context,
return ret;
}
+static IdeDiagnosticSeverity
+translate_severity (enum CXDiagnosticSeverity severity)
+{
+ switch (severity)
+ {
+ case CXDiagnostic_Ignored:
+ return IDE_DIAGNOSTIC_IGNORED;
+
+ case CXDiagnostic_Note:
+ return IDE_DIAGNOSTIC_NOTE;
+
+ case CXDiagnostic_Warning:
+ return IDE_DIAGNOSTIC_WARNING;
+
+ case CXDiagnostic_Error:
+ return IDE_DIAGNOSTIC_ERROR;
+
+ case CXDiagnostic_Fatal:
+ return IDE_DIAGNOSTIC_FATAL;
+
+ default:
+ return 0;
+ }
+}
+
+static IdeDiagnostic *
+create_diagnostic (IdeClangTranslationUnit *self,
+ CXDiagnostic *cxdiag)
+{
+ enum CXDiagnosticSeverity cxseverity;
+ IdeDiagnosticSeverity severity;
+
+ g_return_val_if_fail (IDE_IS_CLANG_TRANSLATION_UNIT (self), NULL);
+ g_return_val_if_fail (cxdiag, NULL);
+
+ cxseverity = clang_getDiagnosticSeverity (cxdiag);
+ severity = translate_severity (cxseverity);
+
+ return _ide_diagnostic_new (severity);
+}
+
/**
* ide_clang_translation_unit_get_diagnostics:
*
@@ -94,12 +135,12 @@ ide_clang_translation_unit_get_diagnostics (IdeClangTranslationUnit *self)
for (i = 0; i < count; i++)
{
CXDiagnostic cxdiag;
+ IdeDiagnostic *diag;
CXString cxstr;
cxdiag = clang_getDiagnostic (priv->tu, i);
- cxstr = clang_getDiagnosticSpelling (cxdiag);
- g_print ("> %s\n", clang_getCString (cxstr));
- clang_disposeString (cxstr);
+ diag = create_diagnostic (self, cxdiag);
+ g_ptr_array_add (ar, diag);
clang_disposeDiagnostic (cxdiag);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]