Merge pull request #3059 from techee/anon4
commit9642f17d83ce8d2e4e8d3e08c3cfd589f98741d8
authorThomas Martitz <thomas.martitz@mailbox.org>
Sat, 12 Feb 2022 21:38:16 +0000 (12 22:38 +0100)
committerGitHub <noreply@github.com>
Sat, 12 Feb 2022 21:38:16 +0000 (12 22:38 +0100)
treef5f8bb038dab4f884315a866fc906df2d9c7e4b5
parenta3031e96bda15f77c9b132dcf138cf791c085e2d
parent6f6261678fb91100269521ad5952d441d184c849
Merge pull request #3059 from techee/anon4

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!!!
src/tagmanager/tm_parser.c
src/tagmanager/tm_parser.h
src/tagmanager/tm_tag.c