This is an archive of the discontinued LLVM Phabricator instance.

[CodeComplete] Tweak code completion for `typename`.
ClosedPublic

Authored by lh123 on Jun 23 2020, 5:48 AM.

Details

Summary

Currently, clangd always completes typename as typename qualifier::name, I think the current behavior is not useful when the code completion is triggered in template <>. So I tweak it to typename identifier.

Diff Detail

Event Timeline

lh123 created this revision.Jun 23 2020, 5:48 AM
lh123 retitled this revision from [CodeComplete] Tweak code completion for "typename to [CodeComplete] Tweak code completion for `typename`.Jun 23 2020, 5:49 AM
kadircet accepted this revision.Jun 23 2020, 1:52 PM

LGTM, as previous version only saves a single character, i.e. pressing a single tab after qualifier vs hitting : twice, while it is annoying for the non-qualified case, now you need to delete the rest.

let me know if I should land this for you.

clang/lib/Sema/SemaCodeComplete.cpp
1693

nit: let's use name instead of identifier

This revision is now accepted and ready to land.Jun 23 2020, 1:52 PM
lh123 updated this revision to Diff 272994.Jun 24 2020, 5:24 AM
lh123 edited the summary of this revision. (Show Details)

address comment.
Also tweak code completion behavior for using.

lh123 edited the summary of this revision. (Show Details)Jun 24 2020, 5:25 AM
lh123 marked an inline comment as done.Jun 24 2020, 5:29 AM
lh123 added a comment.EditedJun 24 2020, 5:54 AM

If this patch looks good, please land it for me.

lh123 retitled this revision from [CodeComplete] Tweak code completion for `typename` to [CodeComplete] Tweak code completion for `typename` and `using`..Jun 24 2020, 5:55 AM
kadircet added inline comments.Jun 24 2020, 7:59 AM
clang/lib/Sema/SemaCodeComplete.cpp
2058

unfortunately the reasoning above doesn't apply here, as a using declaration *must* have a nested-name-specifier. e.g. using X; is not allowed. so please revert this (and following on using typename it requires a nested-name-specifier too)

lh123 marked an inline comment as done.Jun 24 2020, 8:31 AM
lh123 added inline comments.
clang/lib/Sema/SemaCodeComplete.cpp
2058

Yes, you are right. but I think complete using as using qualifier::name is not useful when user want input something like using A = B.

lh123 marked an inline comment as done.Jun 24 2020, 8:38 AM
lh123 added inline comments.
clang/lib/Sema/SemaCodeComplete.cpp
2058

I think we just need revert change for using typename qualifier::name. WDYT.

kadircet added inline comments.Jun 24 2020, 8:49 AM
clang/lib/Sema/SemaCodeComplete.cpp
2058

right but using declarations vs aliases are two different use cases, I would suggest adding a separate completion item for that in form:

using $alias$ = $type$;

lh123 updated this revision to Diff 273074.Jun 24 2020, 9:30 AM
lh123 retitled this revision from [CodeComplete] Tweak code completion for `typename` and `using`. to [CodeComplete] Tweak code completion for `typename`..

Address comment.
I will add using $alias$ = $type$; in a separate patch.

lh123 marked 2 inline comments as done.Jun 24 2020, 9:31 AM
This revision was automatically updated to reflect the committed changes.