[clangd] Implement textDocument/declaration from LSP 3.14


[clangd] Implement textDocument/declaration from LSP 3.14

LSP now reflects the declaration/definition distinction.

Language server changes:

  • textDocument/definition now returns a definition if one is found, otherwise the declaration. It no longer returns declaration + definition if they are distinct.
  • textDocument/declaration returns the best declaration we can find.
  • For macros, the active macro definition is returned for both methods.
  • For include directive, the top of the target file is returned for both.

There doesn't appear to be a discovery mechanism (we can't return everything to
clients that only know about definition), so this changes existing behavior.
In practice, it should greatly reduce the fraction of the time we need to show
the user a menu of options.

C++ API changes:

  • findDefinitions is replaced by locateSymbolAt, which returns a vector<LocatedSymbol> - one for each symbol under the cursor.
  • this contains the preferred declaration, the definition (if found), and the symbol name

This API enables some potentially-neat extensions, like swapping between decl
and def, and exposing the symbol name to the UI in the case of multiple symbols.

Reviewers: hokein

Subscribers: ilya-biryukov, javed.absar, ioeric, MaskRay, jkorous, arphaman, kadircet, cfe-commits

Differential Revision: https://reviews.llvm.org/D57388