Skip to content

Commit b4ce34a

Browse files
committed
[CodeCompletion] Remove ... and & from function filter names
The filter name of a function should match the spelling of the function name according to the language except that we don't insert _ for unnamed parameters because underscores are legal inside identifiers and we don't want to introduce spurious matches (also, we keep the () on a parameterless function for disambiguation). rdar://problem/26118915
1 parent b4dbdc4 commit b4ce34a

File tree

4 files changed

+10
-4
lines changed

4 files changed

+10
-4
lines changed

test/SourceKit/CodeComplete/complete_name.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
struct S {
55
init(a: Int, b: Int, _ c: Int) {}
66
init(_ a: Int, _ b: Int) {}
7-
func foo1(_ a: Int, _ b: Int, _ c: Int) {}
8-
func foo2(a a: Int, b: Int, c: Int) {}
7+
func foo1(_ a: Int, _ b: Int, _ c: Int, _ d: Int..., _ e: inout Int) {}
8+
func foo2(a a: Int, b: Int, c: Int, d: Int..., e: inout Int) {}
99
}
1010

1111
func test01() {
@@ -16,5 +16,5 @@ func test01() {
1616
func test02(_ x: S) {
1717
x.#^METHOD_NAME^#
1818
}
19-
// METHOD_NAME: key.name: "foo1(:::)"
20-
// METHOD_NAME: key.name: "foo2(a:b:c:)"
19+
// METHOD_NAME: key.name: "foo1(:::::)"
20+
// METHOD_NAME: key.name: "foo2(a:b:c:d:e:)"

test/SourceKit/CodeComplete/complete_popular_api.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ func okay() {}
1010
struct Foo {
1111
func bad() { }
1212
func good() { }
13+
func good(_ p1: Int, p2: Any..., p3: ()->(), p4: (Int, Int), p5: inout Int) { }
1314
func okay() {}
1415
var sad: Int
1516
var xhappy: Int
@@ -38,11 +39,13 @@ struct Foo {
3839

3940
// NOPOP_FOO: key.name: "bad()
4041
// NOPOP_FOO: key.name: "good()
42+
// NOPOP_FOO: key.name: "good(:p2:p3:p4:p5:)
4143
// NOPOP_FOO: key.name: "okay()
4244
// NOPOP_FOO: key.name: "sad
4345
// NOPOP_FOO: key.name: "xhappy
4446
// NOPOP_FOO: key.name: "zmeh
4547

48+
// POP_FOO: key.name: "good(:p2:p3:p4:p5:)
4649
// POP_FOO: key.name: "good()
4750
// POP_FOO: key.name: "xhappy
4851
// POP_FOO: key.name: "okay()

test/SourceKit/CodeComplete/complete_popular_api.swift.popular

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
good(:p2:p3:p4:p5:)
12
good()
23
xhappy
34
EEModuleColor

tools/SourceKit/lib/SwiftLang/CodeCompletionOrganizer.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,8 @@ void CompletionBuilder::getFilterName(CodeCompletionString *str,
11801180
case ChunkKind::DeclAttrParamEqual:
11811181
case ChunkKind::Comma:
11821182
case ChunkKind::Whitespace:
1183+
case ChunkKind::Ellipsis:
1184+
case ChunkKind::Ampersand:
11831185
continue;
11841186
case ChunkKind::CallParameterColon:
11851187
// Since we don't add the type, also don't add the space after ':'.

0 commit comments

Comments
 (0)