[PATCH] D53406: [clangd] Provide excuses for bad code completions, based on diagnostics. C++ API only.

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Oct 18 10:50:42 PDT 2018


sammccall created this revision.
sammccall added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay, ioeric.

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.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D53406

Files:
  clangd/ClangdLSPServer.cpp
  clangd/CodeComplete.cpp
  clangd/CodeComplete.h
  unittests/clangd/CodeCompleteTests.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D53406.170104.patch
Type: text/x-patch
Size: 7099 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181018/9d31c5e1/attachment-0001.bin>


More information about the cfe-commits mailing list