This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Show function documentation in sigHelp
ClosedPublic

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

Details

Summary

Previously, clangd was trying to show documentation for the active
parameter instead, which is wrong per LSP specification.

Moreover, the code path that attempts to get parameter comments never
succeds, because no attempt is made to parse function doc comment and
extract parameter-specific parts out of it. So we also remove the code
that claims to fetch parameter comments: it is not used anymore and is
incorrect.

Diff Detail

Repository
rL LLVM

Event Timeline

ilya-biryukov created this revision.Aug 14 2018, 11:02 AM

There's a test for the new behavior in D50726

ioeric added inline comments.Aug 16 2018, 5:00 AM
clangd/CodeCompletionStrings.cpp
81 ↗(On Diff #160639)

The function doesn't seem to carry its weight, and the difference from the other overload is a bit subtle. Maybe we could expose getDeclComent instead?

ilya-biryukov marked an inline comment as done.
  • Expose getDeclComment instead of getDocComment
ioeric accepted this revision.Aug 17 2018, 2:17 AM

lgtm

clangd/CodeCompletionStrings.cpp
52 ↗(On Diff #161011)

RK_Pattern can also have declaration. Do we want to consider those?

57 ↗(On Diff #161011)

nit: maybe return Decl ? getDeclComment(...) : "";

77 ↗(On Diff #161011)

nit: return looksLikeDocComment(Doc) ? Doc : "";

This revision is now accepted and ready to land.Aug 17 2018, 2:17 AM
ilya-biryukov marked 2 inline comments as done.
  • Turn ifs to ternary ops
ilya-biryukov added inline comments.Aug 17 2018, 2:24 AM
clangd/CodeCompletionStrings.cpp
52 ↗(On Diff #161011)

See the FIXME at the top, we don't have the API exposed from clang to get the proper declarations (IIRC, this only shows up for ObjC properties and we need to look at both getters and setters when looking for a comment, and the clang code does not expose the API to do that).

We should probably fix this, but that's a separate issue.

ioeric added inline comments.Aug 17 2018, 2:28 AM
clangd/CodeCompletionStrings.cpp
52 ↗(On Diff #161011)

getDeclaration() has started supporting RK_Pattern recently, so this should be fixable now. But feel free to leave it to future.

This revision was automatically updated to reflect the committed changes.