This is an archive of the discontinued LLVM Phabricator instance.

[clangd][ObjC] Improve completions for protocols + category names
ClosedPublic

Authored by dgoldman on Aug 30 2022, 11:26 AM.

Details

Summary
  • Render protocols as interfaces to differentiate them from classes since a protocol and class can have the same name. Take this one step further though, and only recommend protocols in ObjC protocol completions.
  • Properly call includeSymbolFromIndex even with a cached speculative fuzzy find request
  • Don't use the index to provide completions for category names, symbols there don't make sense

Diff Detail

Event Timeline

dgoldman created this revision.Aug 30 2022, 11:26 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 30 2022, 11:26 AM
Herald added a subscriber: arphaman. · View Herald Transcript
dgoldman requested review of this revision.Aug 30 2022, 11:26 AM
dgoldman edited the summary of this revision. (Show Details)Aug 30 2022, 11:27 AM

can you also add test cases for the other two (filtering both for speculative index queries/regular ones, and making sure we don't suggest symbols from index for category names), so that we don't regress in the future?

can you also add test cases for the other two (filtering both for speculative index queries/regular ones, and making sure we don't suggest symbols from index for category names), so that we don't regress in the future?

Done

dgoldman updated this revision to Diff 457067.Aug 31 2022, 1:07 PM

Run clang format

kadircet added inline comments.Sep 1 2022, 5:57 AM
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
3289

nit: just completions("Fo^", ...)

3335

we actually need to issue the new request in a context that can show FoodClass, as ATM if we were to do filtering during speculative query response, this test would still pass.

dgoldman updated this revision to Diff 457257.Sep 1 2022, 6:55 AM

Fix strings + test

dgoldman updated this revision to Diff 457258.Sep 1 2022, 6:55 AM

Run clang-format again

dgoldman marked 2 inline comments as done.Sep 1 2022, 6:56 AM
kadircet accepted this revision.Sep 8 2022, 1:59 AM

thanks!

clang-tools-extra/clangd/CodeComplete.cpp
1730–1731

nit: while here can you change this to read as:
Incomplete ||= Opts.Index->fuzzyFind(...);

This revision is now accepted and ready to land.Sep 8 2022, 1:59 AM
dgoldman updated this revision to Diff 458724.Sep 8 2022, 6:55 AM

Address comment

dgoldman marked an inline comment as done.Sep 8 2022, 6:55 AM
dgoldman added inline comments.
clang-tools-extra/clangd/CodeComplete.cpp
1730–1731

Done, but there's no ||= and we wouldn't want to short circuit, so used |= instead.

This revision was automatically updated to reflect the committed changes.
dgoldman marked an inline comment as done.