diff --git a/data/style-schemes/Adwaita.style-scheme.xml b/data/style-schemes/Adwaita.style-scheme.xml
index 4a474f818cce2136eef58bbf686b163020b7c8aa..ba8c1066796358fa2639918eae4b89ac87a9ab7c 100644
--- a/data/style-schemes/Adwaita.style-scheme.xml
+++ b/data/style-schemes/Adwaita.style-scheme.xml
@@ -62,10 +62,14 @@
+
+
+
+
diff --git a/src/libide/code/ide-diagnostics.c b/src/libide/code/ide-diagnostics.c
index 0bb462465193cb4694577cc09b915014c5246a0e..ec430b5ee3bbd2057f74709893ca8f7ff9d00757 100644
--- a/src/libide/code/ide-diagnostics.c
+++ b/src/libide/code/ide-diagnostics.c
@@ -482,6 +482,54 @@ ide_diagnostics_get_diagnostic_at_line (IdeDiagnostics *self,
return NULL;
}
+/**
+ * ide_diagnostics_get_diagnostics_at_line:
+ * @self: a #IdeDiagnostics
+ * @file: the target file
+ * @line: a line number
+ *
+ * Locates all #IdeDiagnostic in @file at @line.
+ *
+ * Returns: (transfer full) (element-type IdeDiagnostic) (nullable): an #GPtrArray or %NULL
+ *
+ * Since: 3.38
+ */
+GPtrArray *
+ide_diagnostics_get_diagnostics_at_line (IdeDiagnostics *self,
+ GFile *file,
+ guint line)
+{
+ IdeDiagnosticsPrivate *priv = ide_diagnostics_get_instance_private (self);
+ g_autoptr(GPtrArray) valid_diag = NULL;
+
+ g_return_val_if_fail (IDE_IS_DIAGNOSTICS (self), NULL);
+ g_return_val_if_fail (G_IS_FILE (file), NULL);
+
+ valid_diag = g_ptr_array_new_with_free_func (g_object_unref);
+
+ for (guint i = 0; i < priv->items->len; i++)
+ {
+ IdeDiagnostic *diag = g_ptr_array_index (priv->items, i);
+ IdeLocation *loc = ide_diagnostic_get_location (diag);
+ GFile *loc_file;
+ guint loc_line;
+
+ if (loc == NULL)
+ continue;
+
+ loc_file = ide_location_get_file (loc);
+ loc_line = ide_location_get_line (loc);
+
+ if (loc_line == line && g_file_equal (file, loc_file))
+ g_ptr_array_add (valid_diag, g_object_ref(diag));
+ }
+
+ if (valid_diag->len != 0)
+ return IDE_PTR_ARRAY_STEAL_FULL (&valid_diag);
+
+ return NULL;
+}
+
/**
* ide_diagnostics_new_from_array:
* @array: (nullable) (element-type IdeDiagnostic): optional array
diff --git a/src/libide/code/ide-diagnostics.h b/src/libide/code/ide-diagnostics.h
index 5fbc47d971a52a98a95d7542aa17d9275f7d2970..cfd0a8c1550e5746547a259749f7b07283eefd67 100644
--- a/src/libide/code/ide-diagnostics.h
+++ b/src/libide/code/ide-diagnostics.h
@@ -88,7 +88,11 @@ void ide_diagnostics_foreach_line_in_range (IdeDiagnostics
IdeDiagnosticsLineCallback callback,
gpointer user_data);
IDE_AVAILABLE_IN_3_32
-IdeDiagnostic *ide_diagnostics_get_diagnostic_at_line (IdeDiagnostics *self,
+IdeDiagnostic *ide_diagnostics_get_diagnostic_at_line (IdeDiagnostics *self,
+ GFile *file,
+ guint line);
+IDE_AVAILABLE_IN_3_38
+GPtrArray *ide_diagnostics_get_diagnostics_at_line (IdeDiagnostics *self,
GFile *file,
guint line);
diff --git a/src/libide/core/ide-version-macros.h b/src/libide/core/ide-version-macros.h
index 59a480498b01a4f5a634f008a1efc6a466d0ba2f..a407424eefa186723ed7382d516e2f8f78db7192 100644
--- a/src/libide/core/ide-version-macros.h
+++ b/src/libide/core/ide-version-macros.h
@@ -43,6 +43,7 @@
#define IDE_VERSION_3_32 (G_ENCODE_VERSION (3, 32))
#define IDE_VERSION_3_34 (G_ENCODE_VERSION (3, 34))
#define IDE_VERSION_3_36 (G_ENCODE_VERSION (3, 36))
+#define IDE_VERSION_3_38 (G_ENCODE_VERSION (3, 38))
#if (IDE_MINOR_VERSION == 99)
# define IDE_VERSION_CUR_STABLE (G_ENCODE_VERSION (IDE_MAJOR_VERSION + 1, 0))
@@ -184,3 +185,17 @@
#else
# define IDE_AVAILABLE_IN_3_36 _IDE_EXTERN
#endif
+
+#if IDE_VERSION_MIN_REQUIRED >= IDE_VERSION_3_38
+# define IDE_DEPRECATED_IN_3_38 IDE_DEPRECATED
+# define IDE_DEPRECATED_IN_3_38_FOR(f) IDE_DEPRECATED_FOR(f)
+#else
+# define IDE_DEPRECATED_IN_3_38 _IDE_EXTERN
+# define IDE_DEPRECATED_IN_3_38_FOR(f) _IDE_EXTERN
+#endif
+
+#if IDE_VERSION_MAX_ALLOWED < IDE_VERSION_3_38
+# define IDE_AVAILABLE_IN_3_38 IDE_UNAVAILABLE(3, 38)
+#else
+# define IDE_AVAILABLE_IN_3_38 _IDE_EXTERN
+#endif
diff --git a/src/libide/sourceview/ide-source-view.c b/src/libide/sourceview/ide-source-view.c
index e27dafcff958a7294d6ee7ca83fb843284e27f01..9d76912a84fff29eb31bb25f68ec13a2cc7a7d56 100644
--- a/src/libide/sourceview/ide-source-view.c
+++ b/src/libide/sourceview/ide-source-view.c
@@ -4491,7 +4491,7 @@ ide_source_view_real_populate_popup (GtkTextView *text_view,
IdeSourceView *self = (IdeSourceView *)text_view;
GtkSeparatorMenuItem *sep;
IdeDiagnostics *diagnostics;
- IdeDiagnostic *diagnostic = NULL;
+ GPtrArray *line_diags = 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);
+ }
}
}
}
diff --git a/src/plugins/editor/gbp-editor-hover-provider.c b/src/plugins/editor/gbp-editor-hover-provider.c
index b4319775deb1a0d67798ccbe47d228d236278ea0..ef3962b6aa042789fcb7d1377162050a12ded8a7 100644
--- a/src/plugins/editor/gbp-editor-hover-provider.c
+++ b/src/plugins/editor/gbp-editor-hover-provider.c
@@ -62,21 +62,29 @@ gbp_editor_hover_provider_hover_async (IdeHoverProvider *provider,
GFile *file = ide_buffer_get_file (IDE_BUFFER (buffer));
guint line = gtk_text_iter_get_line (iter);
IdeDiagnostics *diagnostics;
- IdeDiagnostic *diag;
+ GPtrArray *line_diags;
- if ((diagnostics = ide_buffer_get_diagnostics (IDE_BUFFER (buffer))) &&
- (diag = ide_diagnostics_get_diagnostic_at_line (diagnostics, file, line)))
+ diagnostics = ide_buffer_get_diagnostics (IDE_BUFFER (buffer));
+ line_diags = ide_diagnostics_get_diagnostics_at_line (diagnostics, file, line);
+ IDE_PTR_ARRAY_SET_FREE_FUNC (line_diags, g_object_unref);
+
+ if (diagnostics && line_diags)
{
- g_autoptr(IdeMarkedContent) content = NULL;
- g_autofree gchar *text = ide_diagnostic_get_text_for_display (diag);
-
- content = ide_marked_content_new_from_data (text,
- strlen (text),
- IDE_MARKED_KIND_PLAINTEXT);
- ide_hover_context_add_content (context,
- DIAGNOSTICS_HOVER_PRIORITY,
- _("Diagnostics"),
- content);
+ for (guint i = 0; i < line_diags->len; i++)
+ {
+ IdeDiagnostic *diag = g_ptr_array_index (line_diags, i);
+ g_autoptr(IdeMarkedContent) content = NULL;
+ g_autofree gchar *text = ide_diagnostic_get_text_for_display (diag);
+
+ content = ide_marked_content_new_from_data (text,
+ strlen (text),
+ IDE_MARKED_KIND_PLAINTEXT);
+ ide_hover_context_add_content (context,
+ DIAGNOSTICS_HOVER_PRIORITY,
+ _("Diagnostics"),
+ content);
+
+ }
}
}