This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Add parameter and return type information to completion results
ClosedPublic

Authored by krasimir on Jun 8 2017, 6:58 AM.

Details

Summary

This patch adds information about the parameters and return types of completion
candidates.
Previously, for the following code:

struct S {
  int func(int a, double b) const;
};

the completer would only return the label of the candidate func.
Now it will also return the return type int and will format the label for the
candidate as func(int a, double b) const.

Event Timeline

krasimir created this revision.Jun 8 2017, 6:58 AM
krasimir updated this revision to Diff 101906.Jun 8 2017, 7:02 AM
  • Add a test case
krasimir edited the summary of this revision. (Show Details)Jun 8 2017, 7:03 AM
krasimir updated this revision to Diff 101909.Jun 8 2017, 7:04 AM
  • Fix indentation
krasimir updated this revision to Diff 101911.Jun 8 2017, 7:05 AM
  • Remove unused method
krasimir updated this revision to Diff 101912.Jun 8 2017, 7:06 AM
  • Remove newline
krasimir added a project: Restricted Project.
krasimir added a subscriber: cfe-commits.
ilya-biryukov added inline comments.Jun 8 2017, 7:25 AM
clangd/ClangdUnit.cpp
154

Should we also update sortText and filterText, which use label by default, just like insertText?

test/clangd/completion.test
31

Should we repeat repeat the checks added above here too?

40

Again.
Should we repeat repeat the checks added above here too?

krasimir updated this revision to Diff 101919.Jun 8 2017, 7:41 AM
  • Remove optional chunks. They might contain control characters
krasimir updated this revision to Diff 101921.Jun 8 2017, 7:48 AM
krasimir marked an inline comment as done.
  • Add sortText and filterText
krasimir marked an inline comment as done.Jun 8 2017, 7:48 AM
krasimir added inline comments.
clangd/ClangdUnit.cpp
154

Good point!

test/clangd/completion.test
31

This test case is about understanding 'file:/main.cpp', so I don't think repeating everything would be beneficial.

krasimir marked an inline comment as done.Jun 8 2017, 7:49 AM
ilya-biryukov accepted this revision.Jun 8 2017, 8:05 AM
ilya-biryukov added inline comments.
test/clangd/completion.test
31

Makes sense.
Testing that the output is the same on repeated runs of completion wouldn't probably hurt either.
But if you feel it makes tests too clunky, let's not have it here.

This revision is now accepted and ready to land.Jun 8 2017, 8:05 AM
This revision was automatically updated to reflect the committed changes.