From 45f8ed427a69a0637bbf6efe41892b26288e4efa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ji=C5=99=C3=AD=20Techet?= Date: Thu, 1 Sep 2022 00:30:37 +0200 Subject: [PATCH] geanygendoc: Remove all sanity checks testing if tag is tm_tag_file_t tm_tag_file_t has never been used by Geany so the check is unnecessary. In the latest version of Geany this tag was renamed to tm_tag_local_var_t and used for local variables which breaks compilation. --- geanygendoc/src/ggd-tag-utils.c | 66 +++++++++++++-------------------- geanygendoc/src/ggd.c | 2 +- 2 files changed, 27 insertions(+), 41 deletions(-) diff --git a/geanygendoc/src/ggd-tag-utils.c b/geanygendoc/src/ggd-tag-utils.c index 44a8ba94d..a5a3b0425 100644 --- a/geanygendoc/src/ggd-tag-utils.c +++ b/geanygendoc/src/ggd-tag-utils.c @@ -56,16 +56,12 @@ tag_cmp_by_line (gconstpointer a, gint direction = GPOINTER_TO_INT (data); gint rv; - if (t1->type & tm_tag_file_t || t2->type & tm_tag_file_t) { - rv = 0; + if (t1->line > t2->line) { + rv = +direction; + } else if (t1->line < t2->line) { + rv = -direction; } else { - if (t1->line > t2->line) { - rv = +direction; - } else if (t1->line < t2->line) { - rv = -direction; - } else { - rv = 0; - } + rv = 0; } return rv; @@ -158,11 +154,9 @@ ggd_tag_find_from_line (const GPtrArray *tags, g_return_val_if_fail (tags != NULL, NULL); GGD_PTR_ARRAY_FOR (tags, i, el) { - if (! (el->type & tm_tag_file_t)) { - if (el->line <= line && - (! tag || el->line > tag->line)) { - tag = el; - } + if (el->line <= line && + (! tag || el->line > tag->line)) { + tag = el; } } @@ -239,8 +233,7 @@ ggd_tag_find_parent (const GPtrArray *tags, /*g_debug ("%s: parent_name = %s", G_STRFUNC, parent_name); g_debug ("%s: parent_scope = %s", G_STRFUNC, parent_scope);*/ GGD_PTR_ARRAY_FOR (tags, i, el) { - if (! (el->type & tm_tag_file_t) && - (utils_str_equal (el->name, parent_name) && + if ((utils_str_equal (el->name, parent_name) && utils_str_equal (el->scope, parent_scope) && el->line <= child->line)) { tag = el; @@ -273,8 +266,7 @@ static const struct { { tm_tag_variable_t, "variable" }, { tm_tag_externvar_t, "extern" }, { tm_tag_macro_t, "define" }, - { tm_tag_macro_with_arg_t, "macro" }, - { tm_tag_file_t, "file" } + { tm_tag_macro_with_arg_t, "macro" } }; /** @@ -361,32 +353,27 @@ ggd_tag_resolve_type_hierarchy (const GPtrArray *tags, GeanyFiletypeID geany_ft, const TMTag *tag) { + TMTag *parent_tag; gchar *scope = NULL; g_return_val_if_fail (tags != NULL, NULL); g_return_val_if_fail (tag != NULL, NULL); - - if (tag->type & tm_tag_file_t) { - g_critical (_("Invalid tag")); - } else { - TMTag *parent_tag; - parent_tag = ggd_tag_find_parent (tags, geany_ft, tag); - scope = g_strdup (ggd_tag_get_type_name (tag)); - if (parent_tag) { - gchar *parent_scope; + parent_tag = ggd_tag_find_parent (tags, geany_ft, tag); + scope = g_strdup (ggd_tag_get_type_name (tag)); + if (parent_tag) { + gchar *parent_scope; + + parent_scope = ggd_tag_resolve_type_hierarchy (tags, geany_ft, parent_tag); + if (! parent_scope) { + /*g_debug ("no parent scope");*/ + } else { + gchar *tmp; - parent_scope = ggd_tag_resolve_type_hierarchy (tags, geany_ft, parent_tag); - if (! parent_scope) { - /*g_debug ("no parent scope");*/ - } else { - gchar *tmp; - - tmp = g_strconcat (parent_scope, ".", scope, NULL); - g_free (scope); - scope = tmp; - g_free (parent_scope); - } + tmp = g_strconcat (parent_scope, ".", scope, NULL); + g_free (scope); + scope = tmp; + g_free (parent_scope); } } @@ -414,8 +401,7 @@ ggd_tag_find_from_name (const GPtrArray *tags, g_return_val_if_fail (name != NULL, NULL); GGD_PTR_ARRAY_FOR (tags, i, el) { - if (! (el->type & tm_tag_file_t) && - utils_str_equal (el->name, name)) { + if (utils_str_equal (el->name, name)) { tag = el; break; } diff --git a/geanygendoc/src/ggd.c b/geanygendoc/src/ggd.c index e702236fe..b60d9d79b 100644 --- a/geanygendoc/src/ggd.c +++ b/geanygendoc/src/ggd.c @@ -529,7 +529,7 @@ ggd_insert_comment (GeanyDocument *doc, tag_array = doc->tm_file->tags_array; tag = ggd_tag_find_from_line (tag_array, line + 1 /* it is a SCI line */); } - if (! tag || (tag->type & tm_tag_file_t)) { + if (! tag) { msgwin_status_add (_("No valid tag at line %d."), line); } else { if (get_config (doc, doc_type, &filetype, &doctype)) {