forked from OSchip/llvm-project
[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:
parent
befa8cf087
commit
dc6c1f181b
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue