This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Do not insert parentheses when completing a using declaration
ClosedPublic

Authored by ilya-biryukov on Oct 24 2019, 6:32 AM.

Details

Summary

Would be nice to also fix this in clang, but that looks like more work
if we want to preserve signatures in informative chunks.

Fixes https://github.com/clangd/clangd/issues/118

Diff Detail

Event Timeline

ilya-biryukov created this revision.Oct 24 2019, 6:32 AM
Herald added a project: Restricted Project. · View Herald TranscriptOct 24 2019, 6:32 AM
  • Fix name of a constructor parameter

Build result: fail - 59611 tests passed, 1 failed and 763 were skipped.

failed: libc++.libcxx/thread/thread_threads/thread_thread_this/sleep_for.pass.cpp

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

Build result: fail - 59587 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

kadircet added inline comments.Oct 24 2019, 9:55 AM
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
463

I believe AllScopes and this feature is orthogonal what exactly is this part of the test checking for?

clang/lib/Sema/SemaCodeComplete.cpp
5377–5378

CC in here and above(in the SS.isInvalid case) seems to be the same, why not use only a single one?

ilya-biryukov marked 3 inline comments as done.Oct 24 2019, 10:37 AM
ilya-biryukov added inline comments.
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
463

There are two different code paths in code completion that trigger here:

  1. one coming from ParseOptionalCXXScopeSpecifier, this is checked with using ns::^
  2. one coming from ParseUsingDeclarator, this is checked with using ^.

I haven't checked, but the second one shouldn't provide completions from the same namespace, it's a bit more reliable long-term to assume we only provide results from other scopes.
Although maybe I'm overthinking, our index is definitely not smart enough to filter out results from the current scope in that situation (at least now)

clang/lib/Sema/SemaCodeComplete.cpp
5377–5378

Good point, thanks!

ilya-biryukov marked an inline comment as done.
  • Use the same CodeCompletionContext
ilya-biryukov marked an inline comment as not done.Oct 24 2019, 10:37 AM

Build result: pass - 59630 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

kadircet added inline comments.Oct 25 2019, 3:43 AM
clang-tools-extra/clangd/CodeComplete.cpp
1466

why not handle SnippetSuffix in here ?

instead of propagating IsUsingDeclaration, we can just drop Output.Completions.back().SnippetSuffix in here, which sounds like a more appropriate layering.
considering we don't really have context specific knowledge in CodeCompletionBuilder ?

ilya-biryukov added inline comments.Oct 25 2019, 6:05 AM
clang-tools-extra/clangd/CodeComplete.cpp
1466

I was trying to keep all processing of snippets in one place.
Code completion code is hard enough to navigate as it stands today...

Although I agree doing this when summarizing items in a bundles looks like the wrong layer, but this place is also after bundling, so I'm not sure if it's actually winning us much.

kadircet added inline comments.Oct 25 2019, 6:40 AM
clang-tools-extra/clangd/CodeComplete.cpp
482

maybe rather use GenerateSnippets? Since this doesn't generate completions for the snippets, but rather disables generation of any snippets at all.

also I think it makes sense to document this one, because of the field just above it.

1466

ah ok, that's also a good concern. feel free to choose one or the other then.

ilya-biryukov marked an inline comment as done.
  • Rename flag to GenerateSnippets, document it

Build result: pass - 59630 tests passed, 0 failed and 763 were skipped.
Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

kadircet accepted this revision.Oct 25 2019, 8:04 AM

oops, thought I've LGTM'd it on previous cycle :D

clang-tools-extra/clangd/CodeComplete.cpp
482

not just function, also template arguments.

This revision is now accepted and ready to land.Oct 25 2019, 8:04 AM
ilya-biryukov marked 2 inline comments as done.
  • Update the comment
clang-tools-extra/clangd/CodeComplete.cpp
482

Right... That was too specific.

Build result: fail - 59587 tests passed, 1 failed and 805 were skipped.

failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt, ninja_check_all-log.txt, CMakeCache.txt

This revision was automatically updated to reflect the committed changes.