[geany/geany] 13a58c: Fix anonymous tag renaming for Fortran structures
Jiří Techet
git-noreply at geany.org
Fri May 13 00:27:05 UTC 2022
Branch: refs/heads/master
Author: Jiří Techet <techet at gmail.com>
Committer: Jiří Techet <techet at gmail.com>
Date: Mon, 11 Apr 2022 15:05:35 UTC
Commit: 13a58c2b2e58d4a3157e93a7f2bd0d006b884cdf
https://github.com/geany/geany/commit/13a58c2b2e58d4a3157e93a7f2bd0d006b884cdf
Log Message:
-----------
Fix anonymous tag renaming for Fortran structures
See comment in the added code.
Modified Paths:
--------------
src/tagmanager/tm_ctags.c
Modified: src/tagmanager/tm_ctags.c
16 lines changed, 16 insertions(+), 0 deletions(-)
===================================================================
@@ -257,6 +257,7 @@ static void rename_anon_tags(TMSourceFile *source_file)
gchar *orig_name, *new_name = NULL;
guint j;
guint new_name_len, orig_name_len;
+ gboolean inside_nesting = FALSE;
guint scope_len = tag->scope ? strlen(tag->scope) : 0;
gchar kind = tag->kind_letter;
@@ -332,6 +333,21 @@ static void rename_anon_tags(TMSourceFile *source_file)
guint nested_scope_len = nested_tag->scope ? strlen(nested_tag->scope) : 0;
gchar *pos;
+ /* In Fortran, we can create variables of anonymous structures:
+ * structure var1, var2
+ * integer a
+ * end structure
+ * and the parser first generates tags for var1 and var2 which
+ * are on the same scope as the structure itself. So first
+ * we need to skip past the tags on the same scope and only
+ * afterwards we get the nested tags.
+ * */
+ if ((source_file->lang == TM_PARSER_F77 || source_file->lang == TM_PARSER_FORTRAN) &&
+ !inside_nesting && nested_scope_len == scope_len)
+ continue;
+
+ inside_nesting = TRUE;
+
/* Terminate if outside of tag scope, see above */
if (nested_scope_len <= scope_len)
break;
--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
More information about the Commits
mailing list