This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fetch documentation from the Index during signature help
ClosedPublic

Authored by ilya-biryukov on Aug 14 2018, 11:13 AM.

Event Timeline

ilya-biryukov created this revision.Aug 14 2018, 11:13 AM
  • run clang-format
This revision is now accepted and ready to land.Aug 16 2018, 1:40 AM
hokein accepted this revision.Aug 16 2018, 1:53 AM

looks good, a few nits.

clangd/CodeComplete.cpp
742

nit: do we want to log anything here? It may be useful for debug.

clangd/index/Index.h
65

We already have this similar function in clangd/AST.h.

ilya-biryukov marked 2 inline comments as done.
  • Log on index request, remove FIXME that was addressed
  • Remove SymbolID::forDecl, use existing helper instead
ioeric added inline comments.Aug 16 2018, 3:40 AM
clangd/CodeComplete.cpp
756

drive by: I think this should be vlog or dlog.

ilya-biryukov added inline comments.Aug 16 2018, 4:17 AM
clangd/CodeComplete.cpp
742

Definitely useful. Thanks!

clangd/index/Index.h
65

Thanks for pointing this out.
It's somewhat hard to find. WDYT about moving it to Index.h? The concern would probably be a somewhat broken layering, right? E.g. Index.h should not directly depend on anything AST-specific

hokein added inline comments.Aug 16 2018, 4:32 AM
clangd/index/Index.h
65

Yes, I think we will not add any AST-specific stuff to Index.h, that's why we have AST.h.

ilya-biryukov added inline comments.Aug 16 2018, 4:35 AM
clangd/CodeComplete.cpp
756

Code completion also logs the number of results from sema, index, etc. using the log() call.
The added log message looks similar, so trying to be consistent with the rest of the code in this file.

Maybe we should turn all of them into vlog or dlog, but I'd rather leave it to a separate patch.

ioeric added inline comments.Aug 16 2018, 4:43 AM
clangd/CodeComplete.cpp
756

I'm not sure which level code completion log messages should be in, but I think we should follow the guidelines in the logger documentation instead of the existing uses.

Quote from Logger.h

// log() is used for information important to understanding a clangd session.
// e.g. the names of LSP messages sent are logged at this level.
// This level could be enabled in production builds to allow later inspection.

// vlog() is used for details often needed for debugging clangd sessions.
// This level would typically be enabled for clangd developers.
hokein added inline comments.Aug 16 2018, 4:52 AM
clangd/CodeComplete.cpp
756

My recent experience of debugging some weird GotoDef issues tells me that log of index should be on production (since it is a non-trivial part in a clangd session), it would be really helpful to understand what is going on.

ioeric added inline comments.Aug 16 2018, 4:58 AM
clangd/CodeComplete.cpp
756

I agree that they are useful for debugging, but they might not be interesting to end-users. And I think that's why there is vlog. Clangd developers could use a different log level with --log flag.

ilya-biryukov added inline comments.Aug 16 2018, 5:43 AM
clangd/CodeComplete.cpp
756

I agree that vlog is probably a better fit here, but still think we should change it across CodeComplete.cpp in a single commit, rather than partially apply the guidelines to different parts of the file.

However, if everyone agrees we should use vlog here, happy to use vlog too and also send a patch to update all the rest of the usages.
The situation I'm trying to avoid is:

  1. We commit vlog here.
  2. Someone argues that using log is actually better and we decide to not change other usages to log.
  3. We end up with inconsistent choices across this file: vlog for signature help and log for code completion.

But if there's an agreement that we should use vlog everywhere, more than happy to change it :-)

ioeric added inline comments.Aug 16 2018, 5:45 AM
clangd/CodeComplete.cpp
756

That sounds good to me. Thanks!

This revision was automatically updated to reflect the committed changes.