Skip to content

Commit

Permalink
geanygendoc: Remove all sanity checks testing if tag is tm_tag_file_t
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
techee committed Sep 1, 2022
1 parent 7900eb3 commit 45f8ed4
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 41 deletions.
66 changes: 26 additions & 40 deletions geanygendoc/src/ggd-tag-utils.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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" }
};

/**
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion geanygendoc/src/ggd.c
Expand Up @@ -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)) {
Expand Down

0 comments on commit 45f8ed4

Please sign in to comment.