Sarcasm / irony-mode

A C/C++ minor mode for Emacs powered by libclang
GNU General Public License v3.0
904 stars 99 forks source link

irony-get-type is broken #377

Closed hotpxl closed 7 years ago

hotpxl commented 7 years ago

Looks like the merge with iotask-engine is the cause. I don't have time yet to find the source of the problem and wonder if you knew anything about it

Sarcasm commented 7 years ago

Should be fixed, let me know if that's ok for you.

Sarcasm commented 7 years ago

Just a thought, it would be nice if this information could be shown on mouse over with C-h f tooltip-show RET.

hotpxl commented 7 years ago

Great. It works now! I wonder that's doable. Since getting type information still takes around one second on my computer. I wonder if that's going to freeze the GUI.

Sarcasm commented 7 years ago

Agreed, but out of curiosity, do you use flycheck?

I assume when the mouse is in use, it's because the keyboard is less so. Flycheck would already have reparsed the file eventually. In any way this would not be done automatically by default.

hotpxl commented 7 years ago

Yes. But in flycheck, the tooltip show if you put "keyboard caret" on the location. I think you want a mouse hover over behavior. I wonder if that is the same. Also flycheck parse the file ones and reuse that information to display everything. But in our case, we cannot simply calculate every type of every symbol in the file. We need to use a "incremental compiler" or a compilation database, instead of clang I think. I don't know if clang does any level of caching. Otherwise it would take too long.

Sarcasm commented 7 years ago

For flycheck there are actually 2 operations going on:

For get-type, there are also 2 operations:

So with something like flycheck it will be quite cheap already, and without flycheck one can just do it asynchronously.

I know gdb gives a tooltip information about the value of variables when hovering, I find this useful, that's why I was thinking about this.

hotpxl commented 7 years ago

I guess this is doable then. Another possible improvement I can think of right now, is that the type returned by clang is not always friendly. On one hand, templates often have many more default parameters that eventually show up in get-type. On the other, implementation types also leak out to get-type. I wonder if it could be simplified somehow.