[clangd][ObjC] Fix ObjC method definition completion

D124637 improved filtering of method expressions, but not method
definitions. With this change, clangd will now filter ObjC method
definition completions based on their entire selector instead of
only the first selector fragment.

Differential Revision: https://reviews.llvm.org/D128821
This commit is contained in:
David Goldman 2022-06-29 10:04:21 -04:00
parent befa8cf087
commit dc6c1f181b
2 changed files with 21 additions and 1 deletions

View File

@ -861,7 +861,7 @@ struct CompletionRecorder : public CodeCompleteConsumer {
case CodeCompletionResult::RK_Macro:
return Result.Macro->getName();
case CodeCompletionResult::RK_Pattern:
return Result.Pattern->getTypedText();
break;
}
auto *CCS = codeCompletionString(Result);
const CodeCompletionString::Chunk *OnlyText = nullptr;

View File

@ -3131,6 +3131,26 @@ TEST(CompletionTest, ObjectiveCMethodDeclaration) {
EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
}
TEST(CompletionTest, ObjectiveCMethodDeclarationFilterOnEntireSelector) {
auto Results = completions(R"objc(
@interface Foo
- (int)valueForCharacter:(char)c secondArgument:(id)object;
@end
@implementation Foo
secondArg^
@end
)objc",
/*IndexSymbols=*/{},
/*Opts=*/{}, "Foo.m");
auto C = Results.Completions;
EXPECT_THAT(C, ElementsAre(named("valueForCharacter:")));
EXPECT_THAT(C, ElementsAre(filterText("valueForCharacter:secondArgument:")));
EXPECT_THAT(C, ElementsAre(kind(CompletionItemKind::Method)));
EXPECT_THAT(C, ElementsAre(qualifier("- (int)")));
EXPECT_THAT(C, ElementsAre(signature("(char)c secondArgument:(id)object")));
}
TEST(CompletionTest, ObjectiveCMethodDeclarationPrefixTyped) {
auto Results = completions(R"objc(
@interface Foo