[gnome-builder] sourceview: show multiple diagnostics at line
- From: Christian Hergert <chergert src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-builder] sourceview: show multiple diagnostics at line
- Date: Wed, 1 Jul 2020 01:29:30 +0000 (UTC)
commit 8bbc2dc18b06630c4fe4764b3618afb66ff86d1a
Author: Günther Wagner <info gunibert de>
Date: Tue Jun 30 18:25:36 2020 -0700
sourceview: show multiple diagnostics at line
src/libide/sourceview/ide-source-view.c | 101 +++++++++++++++++---------------
1 file changed, 54 insertions(+), 47 deletions(-)
---
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index e27dafcff..a7cd3ad44 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -4489,9 +4489,9 @@ ide_source_view_real_populate_popup (GtkTextView *text_view,
GtkWidget *popup)
{
IdeSourceView *self = (IdeSourceView *)text_view;
+ g_autoptr(GPtrArray) line_diags = NULL;
GtkSeparatorMenuItem *sep;
IdeDiagnostics *diagnostics;
- IdeDiagnostic *diagnostic = NULL;
GtkTextBuffer *buffer;
GtkMenuItem *menu_item;
GtkTextMark *insert;
@@ -4529,60 +4529,67 @@ ide_source_view_real_populate_popup (GtkTextView *text_view,
* If so, display the "Apply TextEdit" menu item with available fixits.
*/
if ((diagnostics = ide_buffer_get_diagnostics (IDE_BUFFER (buffer))))
- diagnostic = ide_diagnostics_get_diagnostic_at_line (diagnostics,
- ide_buffer_get_file (IDE_BUFFER (buffer)),
- gtk_text_iter_get_line (&iter));
+ {
+ line_diags = ide_diagnostics_get_diagnostics_at_line (diagnostics,
+ ide_buffer_get_file (IDE_BUFFER (buffer)),
+ gtk_text_iter_get_line (&iter));
+ IDE_PTR_ARRAY_SET_FREE_FUNC (line_diags, g_object_unref);
+ }
- if (diagnostic != NULL)
+ if (line_diags != NULL)
{
- guint num_fixits;
+ for (guint j = 0; j < line_diags->len; j++)
+ {
+ IdeDiagnostic *diag = g_ptr_array_index (line_diags, j);
+ guint num_fixits;
- num_fixits = ide_diagnostic_get_n_fixits (diagnostic);
+ num_fixits = ide_diagnostic_get_n_fixits (diag);
- if (num_fixits > 0)
- {
- GtkWidget *parent;
- GtkWidget *submenu;
- guint i;
+ if (num_fixits > 0)
+ {
+ GtkWidget *parent;
+ GtkWidget *submenu;
+ guint i;
- sep = g_object_new (GTK_TYPE_SEPARATOR_MENU_ITEM,
- "visible", TRUE,
- NULL);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), GTK_WIDGET (sep));
+ sep = g_object_new (GTK_TYPE_SEPARATOR_MENU_ITEM,
+ "visible", TRUE,
+ NULL);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), GTK_WIDGET (sep));
- submenu = gtk_menu_new ();
+ submenu = gtk_menu_new ();
- parent = g_object_new (GTK_TYPE_MENU_ITEM,
- "label", _("Apply Fix-It"),
- "submenu", submenu,
- "visible", TRUE,
- NULL);
- gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), parent);
+ parent = g_object_new (GTK_TYPE_MENU_ITEM,
+ "label", _("Apply Fix-It"),
+ "submenu", submenu,
+ "visible", TRUE,
+ NULL);
+ gtk_menu_shell_prepend (GTK_MENU_SHELL (popup), parent);
- for (i = 0; i < num_fixits; i++)
- {
- IdeTextEdit *fixit;
- gchar *label;
-
- fixit = ide_diagnostic_get_fixit (diagnostic, i);
- label = ide_source_view_get_fixit_label (self, fixit);
-
- menu_item = g_object_new (GTK_TYPE_MENU_ITEM,
- "label", label,
- "visible", TRUE,
- NULL);
- gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (menu_item));
-
- g_object_set_data_full (G_OBJECT (menu_item),
- "IDE_FIXIT",
- g_object_ref (fixit),
- (GDestroyNotify)g_object_unref);
-
- g_signal_connect_object (menu_item,
- "activate",
- G_CALLBACK (ide_source_view__fixit_activate),
- self,
- G_CONNECT_SWAPPED);
+ for (i = 0; i < num_fixits; i++)
+ {
+ IdeTextEdit *fixit;
+ gchar *label;
+
+ fixit = ide_diagnostic_get_fixit (diag, i);
+ label = ide_source_view_get_fixit_label (self, fixit);
+
+ menu_item = g_object_new (GTK_TYPE_MENU_ITEM,
+ "label", label,
+ "visible", TRUE,
+ NULL);
+ gtk_menu_shell_append (GTK_MENU_SHELL (submenu), GTK_WIDGET (menu_item));
+
+ g_object_set_data_full (G_OBJECT (menu_item),
+ "IDE_FIXIT",
+ g_object_ref (fixit),
+ (GDestroyNotify)g_object_unref);
+
+ g_signal_connect_object (menu_item,
+ "activate",
+ G_CALLBACK (ide_source_view__fixit_activate),
+ self,
+ G_CONNECT_SWAPPED);
+ }
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]