[Github-comments] [geany/geany] Improve handling of anonymous tags (PR #3059)

Jiří Techet notifications at xxxxx
Sun Dec 19 20:58:13 UTC 2021


There are several problems with how we handle anonymous tags which this pull request tries to resolve:

1. Anonymous tags are currently determined based on how these tags are named by ctags which may not be completely reliable and unnecessary. ctags now has XTAG_ANONYMOUS flag we can query and determine whether a tag is anonymous or not based on that. Our fortran parser didn't report XTAG_ANONYMOUS so it has been updated to do so.
2. In order to store the information about anonymous tags, this pull request renames the unused `pointerOrder` member of TMTag (see the corresponding commit about more details  to `flags` and uses one bit to indicate whether a tag is anonymous. This is technically a API change but since pointerOrder always contained 0 and was unused (or maybe used by some super-old parser 15 years back), it doesn't really matter (no g-p plugin uses this field).
3. With the introduction of the new cxx parser, anonymous tags are reported as `__anonNUM` - before they were reported as e.g `anon_struct_NUM` - i.e. they contained information about the type in their name which made them easier to identify in the symbol tree. This pull request adds back this naming.
4. In addition to (3), the NUM in the previous parser was global for all types - i.e. tags were named as `anon_enum_1`, `anon_struct_2`, `anon_enum_3` which is a bit strange as it suggests there are 3 enums but there are 2 instead. This pull request makes these numbers per-type so the above becomes `anon_enum_1`, `anon_struct_1`, `anon_enum_2`.
5. This pull request sets the name of anonymous tag if it's followed by the corresponding typedef tag and the typedef tag is removed. For instance, for `typedef struct{int a} Foo;` you would previously get an anonymous tag for the struct under which `a` would be shown and then separately tag `Foo` as a typedef. After this patch, you get a tag `Foo` for the struct with `a` as its member and the anonymous name is dropped which makes things much clearer in the sidebar.

And finally, thanks to the fact that we do renaming of anonymous tags ourselves now, the last diff against ctags main can be dropped so we can use the upstream version without any modifications and the patch file isn't necessary any more. Hurray!!!
You can view, comment on, or merge this pull request online at:

  https://github.com/geany/geany/pull/3059

-- Commit Summary --

  * Rename pointerOrder TMtag member to flags
  * Use XTAG_ANONYMOUS in Fortran parser
  * Add a flag representing anonymous tags
  * Determine anonymous tags based on name only when necessary
  * Consistently rename anonymous tags and drop the last ctags diff
  * Add type information to anonymous tags
  * Rename anon types based on the typedef name if present

-- File Changes --

    D ctags/ctags_changes.patch (24)
    M ctags/main/parse.c (6)
    M ctags/parsers/geany_fortran.c (6)
    M src/editor.c (6)
    M src/tagmanager/tm_ctags.c (147)
    M src/tagmanager/tm_parser.c (22)
    M src/tagmanager/tm_parser.h (2)
    M src/tagmanager/tm_source_file.c (23)
    M src/tagmanager/tm_tag.c (16)
    M src/tagmanager/tm_tag.h (13)
    M src/tagmanager/tm_workspace.c (6)

-- Patch Links --

https://github.com/geany/geany/pull/3059.patch
https://github.com/geany/geany/pull/3059.diff

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3059
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/pull/3059 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211219/8945e126/attachment-0001.htm>


More information about the Github-comments mailing list