10
10
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(IndexMacros) -module-name=IndexMacros %t/IndexMacros.swift -g -no-toolchain-stdlib-rpath
11
11
12
12
// Check indexed symbols
13
- // RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %t/IndexTest.swift -load-plugin-library %t/%target-library-name(IndexMacros) -parse-as-library 2>&1 | tee %t/test.idx | %FileCheck %s
13
+ // RUN: %target-swift-ide-test -print-indexed-symbols -source-filename %t/IndexTest.swift -load-plugin-library %t/%target-library-name(IndexMacros) -parse-as-library > %t/index.out
14
+ // RUN: %FileCheck %s --input-file %t/index.out
14
15
15
16
//--- IndexTest.swift
16
17
@freestanding ( expression)
17
- macro freestandingExpr( ) = #externalMacro( module: " IndexMacros " , type: " FreestandingExprMacro " )
18
- // CHECK: [[@LINE-1]]:7 | macro/Swift | freestandingExpr() | [[EXPR_USR:.*]] | Def
18
+ macro freestandingExpr< T > ( arg : T ) = #externalMacro( module: " IndexMacros " , type: " FreestandingExprMacro " )
19
+ // CHECK: [[@LINE-1]]:7 | macro/Swift | freestandingExpr(arg: ) | [[EXPR_USR:.*]] | Def
19
20
20
21
@freestanding ( declaration, names: named ( TestFree) )
21
- macro freestandingDecl( ) = #externalMacro( module: " IndexMacros " , type: " FreestandingDeclMacro " )
22
- // CHECK: [[@LINE-1]]:7 | macro/Swift | freestandingDecl() | [[DECL_USR:.*]] | Def
22
+ macro freestandingDecl< T > ( arg : T ) = #externalMacro( module: " IndexMacros " , type: " FreestandingDeclMacro " )
23
+ // CHECK: [[@LINE-1]]:7 | macro/Swift | freestandingDecl(arg: ) | [[DECL_USR:.*]] | Def
23
24
24
25
@attached ( accessor)
25
26
macro Accessor( ) = #externalMacro( module: " IndexMacros " , type: " SomeAccessorMacro " )
@@ -38,8 +39,8 @@ macro MemberAttribute() = #externalMacro(module: "IndexMacros", type: "SomeMembe
38
39
// CHECK: [[@LINE-1]]:7 | macro/Swift | MemberAttribute() | [[MEMBER_ATTRIBUTE_USR:.*]] | Def
39
40
40
41
@attached ( peer, names: named ( TestPeer) )
41
- macro Peer( ) = #externalMacro( module: " IndexMacros " , type: " SomePeerMacro " )
42
- // CHECK: [[@LINE-1]]:7 | macro/Swift | Peer() | [[PEER_USR:.*]] | Def
42
+ macro Peer< T > ( arg : T ) = #externalMacro( module: " IndexMacros " , type: " SomePeerMacro " )
43
+ // CHECK: [[@LINE-1]]:7 | macro/Swift | Peer(arg: ) | [[PEER_USR:.*]] | Def
43
44
44
45
@attached ( peer, names: named ( peerMember) )
45
46
macro PeerMember( ) = #externalMacro( module: " IndexMacros " , type: " SomePeerMemberMacro " )
@@ -72,26 +73,30 @@ struct AddOne {
72
73
}
73
74
}
74
75
76
+ // CHECK: [[@LINE+2]]:2 | macro/Swift | freestandingDecl(arg:) | [[DECL_USR]] | Ref
77
+ // CHECK: [[@LINE+1]]:19 | struct/Swift | Double | s:Sd | Ref
78
+ #freestandingDecl< Double> ( arg: 1.0 )
75
79
// Creates a `TestFree` struct with `freeFunc` calling `freeLog`
76
- #freestandingDecl
77
- // CHECK: [[@LINE-1]]:2 | macro/Swift | freestandingDecl() | [[DECL_USR]] | Ref
78
80
// CHECK: [[@LINE-2]]:1 | struct/Swift | TestFree | [[FREE_STRUCT_USR:.*]] | Def,Impl
79
81
// CHECK: [[@LINE-3]]:1 | instance-method/Swift | freeFunc() | [[FREE_FUNC_USR:.*]] | Def,Impl,RelChild
80
82
// CHECK-NEXT: RelChild | struct/Swift | TestFree | [[FREE_STRUCT_USR]]
81
83
// CHECK: [[@LINE-5]]:1 | function/Swift | freeLog() | [[FREE_LOG_USR]] | Ref,Call,Impl,RelCall,RelCont
82
84
// CHECK-NEXT: RelCall,RelCont | instance-method/Swift | freeFunc() | [[FREE_FUNC_USR]]
83
85
84
86
func testExpr( ) {
85
- #freestandingExpr
87
+ // CHECK: [[@LINE+2]]:4 | macro/Swift | freestandingExpr(arg:) | [[EXPR_USR]] | Ref
88
+ // CHECK: [[@LINE+1]]:21 | struct/Swift | Double | s:Sd | Ref
89
+ #freestandingExpr< Double> ( arg: 1.0 )
86
90
// CHECK: [[@LINE-1]]:3 | function/Swift | exprLog() | [[EXPR_LOG_USR]] | Ref,Call,Impl,RelCall,RelCont
87
91
// CHECK-NEXT: RelCall,RelCont | function/Swift | testExpr()
88
92
}
89
93
90
- // CHECK: [[@LINE+4]]:40 | macro/Swift | Peer() | [[PEER_USR]] | Ref
94
+ // CHECK: [[@LINE+5]]:40 | macro/Swift | Peer(arg:) | [[PEER_USR]] | Ref
95
+ // CHECK: [[@LINE+4]]:45 | struct/Swift | Double | s:Sd | Ref
91
96
// CHECK: [[@LINE+3]]:23 | macro/Swift | MemberAttribute() | [[MEMBER_ATTRIBUTE_USR]] | Ref
92
97
// CHECK: [[@LINE+2]]:15 | macro/Swift | Member() | [[MEMBER_USR]] | Ref
93
98
// CHECK: [[@LINE+1]]:2 | macro/Swift | Conformance() | [[CONFORMANCE_USR]] | Ref
94
- @Conformance @Member @MemberAttribute @Peer
99
+ @Conformance @Member @MemberAttribute @Peer < Double > ( arg : 1.0 )
95
100
struct TestAttached {
96
101
var attachedMember : Int
97
102
@@ -151,7 +156,6 @@ struct Outer {
151
156
// CHECK: [[@LINE-19]]:3 | protocol/Swift | TestProto | [[PROTO_USR]] | Ref,Impl,RelBase
152
157
// CHECK-NEXT: RelBase | extension/ext-struct/Swift | TestInner
153
158
154
-
155
159
//--- IndexMacros.swift
156
160
import SwiftSyntax
157
161
import SwiftSyntaxBuilder
0 commit comments