[gnome-builder] libide-code: add ide_diagnostic_equal()
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] libide-code: add ide_diagnostic_equal()
- Date: Tue, 12 Jul 2022 06:39:07 +0000 (UTC)
commit 6f8c958038388a1dc8a37e386e756e57e498ef95
Author: Christian Hergert <chergert redhat com>
Date: Mon Jul 11 16:19:53 2022 -0700
libide-code: add ide_diagnostic_equal()
src/libide/code/ide-diagnostic.c | 28 ++++++++++++++++++++++++++++
src/libide/code/ide-diagnostic.h | 3 +++
2 files changed, 31 insertions(+)
---
diff --git a/src/libide/code/ide-diagnostic.c b/src/libide/code/ide-diagnostic.c
index 1a377dfaf..fdee6b3f4 100644
--- a/src/libide/code/ide-diagnostic.c
+++ b/src/libide/code/ide-diagnostic.c
@@ -590,6 +590,34 @@ ide_diagnostic_hash (IdeDiagnostic *self)
return priv->hash;
}
+gboolean
+ide_diagnostic_equal (IdeDiagnostic *a,
+ IdeDiagnostic *b)
+{
+ IdeDiagnosticPrivate *a_priv = ide_diagnostic_get_instance_private (a);
+ IdeDiagnosticPrivate *b_priv = ide_diagnostic_get_instance_private (b);
+
+ g_return_val_if_fail (!a || IDE_IS_DIAGNOSTIC (a), FALSE);
+ g_return_val_if_fail (!b || IDE_IS_DIAGNOSTIC (b), FALSE);
+
+ if (a == NULL || b == NULL)
+ return FALSE;
+
+ if (G_OBJECT_TYPE (a) != G_OBJECT_TYPE (b))
+ return FALSE;
+
+ if (ide_diagnostic_hash (a) != ide_diagnostic_hash (b))
+ return FALSE;
+
+ if (g_strcmp0 (a_priv->text, b_priv->text) != 0)
+ return FALSE;
+
+ if (!ide_location_equal (a_priv->location, b_priv->location))
+ return FALSE;
+
+ return TRUE;
+}
+
/**
* ide_diagnostic_to_variant:
* @self: a #IdeDiagnostic
diff --git a/src/libide/code/ide-diagnostic.h b/src/libide/code/ide-diagnostic.h
index 7071533b0..9fc1a457d 100644
--- a/src/libide/code/ide-diagnostic.h
+++ b/src/libide/code/ide-diagnostic.h
@@ -63,6 +63,9 @@ IDE_AVAILABLE_IN_3_32
IdeDiagnostic *ide_diagnostic_new_from_variant (GVariant *variant);
IDE_AVAILABLE_IN_3_32
guint ide_diagnostic_hash (IdeDiagnostic *self);
+IDE_AVAILABLE_IN_ALL
+gboolean ide_diagnostic_equal (IdeDiagnostic *a,
+ IdeDiagnostic *b);
IDE_AVAILABLE_IN_3_32
IdeLocation *ide_diagnostic_get_location (IdeDiagnostic *self);
IDE_AVAILABLE_IN_3_32
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]