[Github-comments] [geany/geany] Enable local variables for C/C++ and improve autocompletion (PR #3185)

Jiří Techet notifications at github.com
Sat Apr 30 22:44:04 UTC 2022


>I'm not really happy with https://github.com/geany/geany/commit/b710cf3aa1300dd43e4edfcf152f7f3a10f9a686

> it makes a lot of assumption

Basically the only assumption that this makes is that sources and corresponding headers have the same file name and headers have some of the commonly used header extensions.

> it seems really expensive

Note that this doesn't use any file system operations - this works over TMSourceFile structures which represent parsed source files, which, without any extensions, are only open documents (with something like ProjectOrganizer it can be whole projects). It's true this function does string comparisons which can be a bit expensive but the number of files tends to be 2 orders of magnitude less than the number of tags.

> works only for C/C++ by hardcoding

This is true but I don't see any sign that any of the other ctags parsers would get the capabilities of the cxx parser soon so scope autocompletion will unfortunately be C/C++ only feature for the foreseeable future.

> has nothing to do with local variables

It doesn't but neither other things in this PR do - this is about improving scope autocompletion. When you type something like
```
void MyClass::myFunction() {
    name.  // <--
}
```
it makes a difference whether the code first looks for a member `name` in the header or an arbitrary member `name` in the workspace - in which case you get incorrect results.

In fact, I was thinking about improving this by looking at `#include` tags (we currently ignore them) and using tags from the included files first.

Now thinking about it I should have implemented it differently - I could do it inside `sort_found_tags()` and compare the file name of the sorted tag with the source file name there Will be less comparisons and shorter code.

> Please lets discuss that feature in a separate PR.

I can separate it but in some form I want to keep this feature because it improves the results of scope autocompletion.

> Also, if we want that, then it may make sense to expose that "find header" logic somehow to implement a "go to header" feature (I think ProjectOrganizer already has something like that?)

The difference between ProjectOrganizer and Geany is that Geany doesn't know about all project files (there's no notion of a file belonging to a project in Geany). For every project file in ProjectOrganizer there is TMSourceFile, in Geany just for open files and this functionality cannot be easily replicated in Geany itself unless Geany would search the file system for the header.

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

Message ID: <geany/geany/pull/3185/c1114065878 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20220430/ff21af87/attachment.htm>


More information about the Github-comments mailing list