Commit 26109025 authored by Günther Wagner's avatar Günther Wagner Committed by Christian Hergert

code: add ide_diagnostics_get_diagnostics_at_line()

parent 13b990c3
......@@ -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
......
......@@ -60,37 +60,41 @@ struct _IdeDiagnosticsClass
};
IDE_AVAILABLE_IN_3_32
IdeDiagnostics *ide_diagnostics_new (void);
IdeDiagnostics *ide_diagnostics_new (void);
IDE_AVAILABLE_IN_3_32
IdeDiagnostics *ide_diagnostics_new_from_array (GPtrArray *array);
IdeDiagnostics *ide_diagnostics_new_from_array (GPtrArray *array);
IDE_AVAILABLE_IN_3_32
void ide_diagnostics_add (IdeDiagnostics *self,
IdeDiagnostic *diagnostic);
void ide_diagnostics_add (IdeDiagnostics *self,
IdeDiagnostic *diagnostic);
IDE_AVAILABLE_IN_3_32
void ide_diagnostics_take (IdeDiagnostics *self,
IdeDiagnostic *diagnostic);
void ide_diagnostics_take (IdeDiagnostics *self,
IdeDiagnostic *diagnostic);
IDE_AVAILABLE_IN_3_32
void ide_diagnostics_merge (IdeDiagnostics *self,
IdeDiagnostics *other);
void ide_diagnostics_merge (IdeDiagnostics *self,
IdeDiagnostics *other);
IDE_AVAILABLE_IN_3_32
guint ide_diagnostics_get_n_errors (IdeDiagnostics *self);
guint ide_diagnostics_get_n_errors (IdeDiagnostics *self);
IDE_AVAILABLE_IN_3_32
gboolean ide_diagnostics_get_has_errors (IdeDiagnostics *self);
gboolean ide_diagnostics_get_has_errors (IdeDiagnostics *self);
IDE_AVAILABLE_IN_3_32
guint ide_diagnostics_get_n_warnings (IdeDiagnostics *self);
guint ide_diagnostics_get_n_warnings (IdeDiagnostics *self);
IDE_AVAILABLE_IN_3_32
gboolean ide_diagnostics_get_has_warnings (IdeDiagnostics *self);
gboolean ide_diagnostics_get_has_warnings (IdeDiagnostics *self);
IDE_AVAILABLE_IN_3_32
void ide_diagnostics_foreach_line_in_range (IdeDiagnostics *self,
GFile *file,
guint begin_line,
guint end_line,
IdeDiagnosticsLineCallback callback,
gpointer user_data);
void ide_diagnostics_foreach_line_in_range (IdeDiagnostics *self,
GFile *file,
guint begin_line,
guint end_line,
IdeDiagnosticsLineCallback callback,
gpointer user_data);
IDE_AVAILABLE_IN_3_32
IdeDiagnostic *ide_diagnostics_get_diagnostic_at_line (IdeDiagnostics *self,
GFile *file,
guint line);
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);
#define ide_diagnostics_get_size(d) ((gsize)g_list_model_get_n_items(G_LIST_MODEL(d)))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment