[Github-comments] [geany/geany] Use cxx parser from uctags (PR #3032)

Jiří Techet notifications at xxxxx
Tue Dec 7 14:37:31 UTC 2021


> Hmmm, I see what you mean, looking at the typedefs at the start of tm_parser.c the struct is shown as __anon and the the typedef then shows later, but there is no link between them. So AFAICT uses of the typedef can't find the members for autocomplete?

The disconnection between typedefs and e.g. anonymous enums isn't something new - it was already present in the old parser. The new thing here is that the name lacks the information about what kind of anonymous type it is. For instance, before, you'd get `anon_enum_1`, `anon_struct_2` and now you just get `__anon1` and `__anon2`. Scope autocompletion should still work, it should resolve the typedefs correctly, it's just the display in the sidebar.

If it's not a problem, I would open a separate pull request for this - it's not just a simple renaming of tag names, the problem is that these anonymous tags may appear in scopes as parents of other tags and then we have to update the scope information too. Also we should start using the information from ctags to detect whether a tag is anonymous and not depend on the detection based on just tag name.

> But its raising the question of how far should we try to go?

Our scope completion but also jumping to tag definition/declaration isn't just ready for enabling local variables yet - there will be too many false positives. As you said, we can't fully rely on the scope information because we don't know what files get parsed and I think we'll have to find some hybrid approach where we use the scope information in some cases and in others not.

> What about function parameters?

They should eventually get enabled too, but again, we aren't ready for them yet. We primarily need to improve our abilities to be able decide what get shown in the symbol tree and how. For instance, while we want the parameters to be parsed by ctags, we don't want to see them below the function name in the sidebar - those would be confused with local variables. 

Once all the currently pending parser pull requests are merged, I'd like to move the tree mappings from symbols.c to tm_parsers and improve their flexibility and also simplify maintenance and adding new parsers. For instance for makefiles the definition would look as follows:

```
/* in addition to what we already have here we could specify the icon for the symbol tree here */
static TMParserMapEntry map_MAKEFILE[] = {
	{'m', tm_tag_macro_t, ICON_MACRO},
	{'t', tm_tag_function_t, ICON_METHOD},
	{'I', tm_tag_undef_t, ICON_NONE},
};

/* This would define the roots in the symbol tree, what icon is used for them and what tags are placed 
under the roots. Note that tm_tag_macro_t is a bit mask so if we wanted to add several kinds under 
the same root, we'd just xor them in the last element. */
static TMParserMapGroup group_MAKEFILE[] = {
	{_("Targets"), ICON_METHOD, tm_tag_macro_t},
	{_("Macros"), ICON_MACRO, tm_tag_function_t},
};
```


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/3032#issuecomment-987984980
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20211207/b482765e/attachment.htm>


More information about the Github-comments mailing list