This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Expose qualified symbol names in CompletionItem (C++ structure only, no json).
ClosedPublic

Authored by ioeric on Jun 21 2018, 5:43 AM.

Details

Summary

The qualified name can be used to match a completion item to its corresponding
symbol. This can be useful for tools that measure code completion quality.
Qualified names are not precise for identifying symbols; we need to figure out a
better way to identify completion items.

Diff Detail

Event Timeline

ioeric created this revision.Jun 21 2018, 5:43 AM
ioeric updated this revision to Diff 152265.Jun 21 2018, 5:45 AM
  • Fix build
sammccall added inline comments.Jun 21 2018, 8:08 AM
clangd/CodeComplete.cpp
247

can skip the bool() here if you like

clangd/Protocol.h
743

So this is always set to scope + filterText (except for non-decl completions, where you're not setting it in this patch).

WDYT about just making that "scope", and for now relying on the fact that scope + filtertext gives you a nice readable name?

Advantages:

  • it's a bit smaller
  • as we add more structure to the C++ completion API, I think we'll want to expose scope+name split, so this would be closer to the desired state.
ioeric updated this revision to Diff 152331.Jun 21 2018, 9:52 AM
ioeric marked 2 inline comments as done.
  • store scope in completion item. Add splitQualifiedName for NamedDecl.
clangd/Protocol.h
743

Sounds good. Done.

sammccall accepted this revision.Jun 22 2018, 3:33 AM
sammccall added inline comments.
clangd/SourceCode.h
60 ↗(On Diff #152331)

This is a bit non-orthogonal: the printing of the qname doesn't have much to do with splitting it.
Also, the printing doesn't really belong in SourceCode.h as it's basically AST manipulation.

What about adding e.g. printQualifiedName to AST.h, and calling splitQualifiedName(printQualifiedName(ND))?(

unittests/clangd/CodeCompleteTests.cpp
47

maybe test scope explicitly/directly?

This revision is now accepted and ready to land.Jun 22 2018, 3:33 AM
ioeric updated this revision to Diff 152447.Jun 22 2018, 3:49 AM
ioeric marked 2 inline comments as done.
  • Add printQualifiedName in AST.h
This revision was automatically updated to reflect the committed changes.