In some circumstances we provide bad completions or no completions, because of
problems in the code. This can be puzzling and opaque to users.
If we can tell the user that this is the case and why, they'll be happy.
Experiments with go language servers have shown this to be a big win.
Two major problems:
- Sema doesn't provide the information we need
- LSP provides no protocol mechanims, and editors don't have UI for this
This patch attempts to guess the information, looking at diagnostics on the line.
Other heuristics are possible (e.g. using completion context). It's unclear how
useful or successful they will be. This is mostly a quick hack to test viability.
This is exposed as an extension of the C++ API only (not bound to LSP).
The idea is to test viability with a non-public editor that happens to have the
right UI already (and doesn't use LSP), and experiment with approaches.
If something fairly simple works well, we'll keep this and expose an LSP extension.
If it's not useful, we should drop this idea.
It took some time to figure out what "excuse" means here.
Maybe be more straightforward in naming/comments about what this class does? I.e. finds a last diagnostic on the same line.
It's private to this file, so it's easy to rename if we'll want to expand the heuristics.