Completion of strictly typed enum values
Hello. Suppose we have
enum class Shape
{
kCircle,
kRectangle,
kTriangle
};
void drawShape(Shape shape)
{
switch (shape) {
case k|
}
}
Irony suggests kCircle, kRectangle, kTriangle here, and if I choose one, it will insert exactly this value, i.e. kCircle. But it is incorrect because it leads to broken code, so I have to insert Shape:: manually.
It would be great if irony can detect such cases (afaik only enums are affected) and add type name in front of enum value. What do you think about it? Btw Xcode does it and its really handy
Adding examples from Xcode:
Before choose

After choose

That's a great remark. It looks like I discard this information but libclang exposes it. It should be possible to achieve the desired results with company, but this require some work.
Thank you very much! Yes, company reports that type in compilation popup, also if enums type is inside long namespace chain, it reports full type name with all namespaces, so it could be achievable
One of the issue, is also to get company work with what it calls a "non-prefix" completion, quoting C-h v company-backends RET:
Non-prefix matches are also supported (candidates that don’t start with the prefix, but match it in some backend-defined way). Backends that use this feature must disable cache (return t to ‘no-cache’) and might also want to respond to ‘match’.
The good thing, is we have a good, simple test case. But now I have to convert the backend to be non-prefix and see how to "repair" the information I discard.
This makes me think, the actual method used by company-irony is slightly broken anyway and need an overhaul (https://github.com/Sarcasm/company-irony/issues/40).
Oh, I see. If I can help somehow, just say and I'll try to do my best)
I guess if implementing it is too challenging, the best you can do, is ask me update on this on a regular basis, that will keep my attention on this issue and not bother me. :P
Deal :+1: