Skip to content

Commit 4c4f3c0

Browse files
authored
Merge pull request #71063 from ahoppen/ahoppen/delete-dot-in-call
[CodeComplete] Delete `.` in completion suggestions of call pattern
2 parents 5001980 + 88275d4 commit 4c4f3c0

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

lib/IDE/CompletionLookup.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,6 +1233,10 @@ void CompletionLookup::addFunctionCallPattern(
12331233
: CodeCompletionResultKind::Pattern,
12341234
SemanticContext ? *SemanticContext : getSemanticContextKind(AFD));
12351235
Builder.addFlair(CodeCompletionFlairBit::ArgumentLabels);
1236+
if (DotLoc) {
1237+
Builder.setNumBytesToErase(Ctx.SourceMgr.getByteDistance(
1238+
DotLoc, Ctx.SourceMgr.getIDEInspectionTargetLoc()));
1239+
}
12361240
if (AFD)
12371241
Builder.setAssociatedDecl(AFD);
12381242

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// RUN: %batch-code-completion
2+
3+
struct Foo {
4+
func bar(argLabel: Int) -> Int { 1 }
5+
}
6+
let x = Foo().bar
7+
x.#^AFTER_DOT^#
8+
// AFTER_DOT: Pattern/CurrModule/Flair[ArgLabels]/Erase[1]: ({#Int#})[#Int#]; name=()
9+
10+
x. #^AFTER_DOT_AND_SPACE^#
11+
// AFTER_DOT_AND_SPACE: Pattern/CurrModule/Flair[ArgLabels]/Erase[2]: ({#Int#})[#Int#]; name=()
12+
13+
x.#^AFTER_DOT_FOLLOWING_DOT?check=AFTER_DOT^#.
14+
15+
Foo().bar.#^UNRESOLVED_MEMBER_REF^#
16+
// UNRESOLVED_MEMBER_REF: Decl[InstanceMethod]/CurrNominal/Flair[ArgLabels]/Erase[1]: ({#argLabel: Int#})[#Int#]; name=(argLabel:)

0 commit comments

Comments
 (0)