[PATCH] D54529: [clangd] Add USR to textDocument/definition response

Sam McCall via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Nov 15 00:41:01 PST 2018


sammccall added a comment.

OK, sounds like we have something to move forward with. I'd suggest we start with an operation returning {SymbolID, scope qualifiers, unqualified name, USR} and ignoring location for now, unless you have an immediate need. Reason being this sidesteps the index question, what the semantics of the location are, which redecl to use etc. Hmm, this looks a lot like `SymbolInformation` as used by `textDocument/documentSymbol` with a USR extension. We could consider reusing that type...

> A declaration in this case is perfectly fine. You can leverage existing code like clang::tooling::getNamedDeclAt that will return the declaration for a location, and that's used by things like clang-rename.

I'd suggest putting this operation in XRefs.cpp and reusing `getSymbolAtPosition`, because that's consistent with how we handle other "symbol at cursor" operations, and is aware of our preamble handling. If the implementation can be improved or reuse other libraries that's a good idea, but it should be uniform.
(getNamedDeclAt looks simpler/cleaner, but I assume you want this to work when the cursor is on a reference rather than a decl? If I'm reading getNamedDeclAt correctly, it doesn't seem to handle that).


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D54529





More information about the cfe-commits mailing list