@@ -1058,6 +1058,73 @@ final class SwiftCompletionTests: XCTestCase {
10581058 )
10591059 }
10601060
1061+ func testExpandMacroClosurePlaceholder( ) async throws {
1062+ try await SkipUnless . sourcekitdSupportsPlugin ( )
1063+
1064+ let testClient = try await TestSourceKitLSPClient ( capabilities: snippetCapabilities)
1065+ let uri = DocumentURI ( for: . swift)
1066+ let positions = testClient. openDocument (
1067+ """
1068+ @freestanding(expression)
1069+ macro myMacroExpr(fn: (Int) -> String) = #externalMacro(module: " " , type: " " )
1070+
1071+ @freestanding(declaration)
1072+ macro myMacroDecl(fn1: (Int) -> String, fn2: () -> Void) = #externalMacro(module: " " , type: " " )
1073+
1074+ func test() {
1075+ #1️⃣
1076+ }
1077+ """ ,
1078+ uri: uri
1079+ )
1080+ let completions = try await testClient. send (
1081+ CompletionRequest ( textDocument: TextDocumentIdentifier ( uri) , position: positions [ " 1️⃣ " ] )
1082+ )
1083+ XCTAssertEqual (
1084+ completions. items. clearingUnstableValues. filter { $0. label. contains ( " myMacro " ) } ,
1085+ [
1086+ CompletionItem (
1087+ label: " myMacroDecl(fn1: (Int) -> String, fn2: () -> Void) " ,
1088+ kind: . value,
1089+ detail: " Declaration Macro " ,
1090+ deprecated: false ,
1091+ filterText: " myMacroDecl(fn1:fn2:) " ,
1092+ insertText: #"""
1093+ myMacroDecl(fn1: ${1:{ ${2:Int} in ${3:String} \}}, fn2: ${4:{ ${5:Void} \}})
1094+ """# ,
1095+ insertTextFormat: . snippet,
1096+ textEdit: . textEdit(
1097+ TextEdit (
1098+ range: Range ( positions [ " 1️⃣ " ] ) ,
1099+ newText: #"""
1100+ myMacroDecl(fn1: ${1:{ ${2:Int} in ${3:String} \}}, fn2: ${4:{ ${5:Void} \}})
1101+ """#
1102+ )
1103+ )
1104+ ) ,
1105+ CompletionItem (
1106+ label: " myMacroExpr(fn: (Int) -> String) " ,
1107+ kind: . value,
1108+ detail: " Void " ,
1109+ deprecated: false ,
1110+ filterText: " myMacroExpr(fn:) " ,
1111+ insertText: #"""
1112+ myMacroExpr(fn: ${1:{ ${2:Int} in ${3:String} \}})
1113+ """# ,
1114+ insertTextFormat: . snippet,
1115+ textEdit: . textEdit(
1116+ TextEdit (
1117+ range: Range ( positions [ " 1️⃣ " ] ) ,
1118+ newText: #"""
1119+ myMacroExpr(fn: ${1:{ ${2:Int} in ${3:String} \}})
1120+ """#
1121+ )
1122+ )
1123+ ) ,
1124+ ]
1125+ )
1126+ }
1127+
10611128 func testCompletionScoring( ) async throws {
10621129 try await SkipUnless . sourcekitdSupportsPlugin ( )
10631130
0 commit comments