xref: /aosp_15_r20/external/ksp/test-utils/testData/api/getSymbolsFromAnnotation.kt (revision af87fb4bb8e3042070d2a054e912924f599b22b7)
1*af87fb4bSXin Li /*
2*af87fb4bSXin Li  * Copyright 2022 Google LLC
3*af87fb4bSXin Li  * Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
4*af87fb4bSXin Li  *
5*af87fb4bSXin Li  * Licensed under the Apache License, Version 2.0 (the "License");
6*af87fb4bSXin Li  * you may not use this file except in compliance with the License.
7*af87fb4bSXin Li  * You may obtain a copy of the License at
8*af87fb4bSXin Li  *
9*af87fb4bSXin Li  * http://www.apache.org/licenses/LICENSE-2.0
10*af87fb4bSXin Li  *
11*af87fb4bSXin Li  * Unless required by applicable law or agreed to in writing, software
12*af87fb4bSXin Li  * distributed under the License is distributed on an "AS IS" BASIS,
13*af87fb4bSXin Li  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14*af87fb4bSXin Li  * See the License for the specific language governing permissions and
15*af87fb4bSXin Li  * limitations under the License.
16*af87fb4bSXin Li  */
17*af87fb4bSXin Li 
18*af87fb4bSXin Li // TEST PROCESSOR: GetSymbolsFromAnnotationProcessor
19*af87fb4bSXin Li // EXPECTED:
20*af87fb4bSXin Li // ==== Anno superficial====
21*af87fb4bSXin Li // Foo:KSClassDeclaration
22*af87fb4bSXin Li // <init>:KSFunctionDeclaration
23*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
24*af87fb4bSXin Li // param:KSValueParameter
25*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
26*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
27*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
28*af87fb4bSXin Li // p1:KSValueParameter
29*af87fb4bSXin Li // Bar:KSClassDeclaration
30*af87fb4bSXin Li // Baz:KSClassDeclaration
31*af87fb4bSXin Li // Burp:KSClassDeclaration
32*af87fb4bSXin Li // Flux:KSTypeAlias
33*af87fb4bSXin Li // ==== Anno in depth ====
34*af87fb4bSXin Li // Foo:KSClassDeclaration
35*af87fb4bSXin Li // <init>:KSFunctionDeclaration
36*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
37*af87fb4bSXin Li // param:KSValueParameter
38*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
39*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
40*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
41*af87fb4bSXin Li // p1:KSValueParameter
42*af87fb4bSXin Li // local:KSPropertyDeclaration
43*af87fb4bSXin Li // Bar:KSClassDeclaration
44*af87fb4bSXin Li // Baz:KSClassDeclaration
45*af87fb4bSXin Li // Burp:KSClassDeclaration
46*af87fb4bSXin Li // Flux:KSTypeAlias
47*af87fb4bSXin Li // ==== Bnno superficial====
48*af87fb4bSXin Li // File: Foo.kt:KSFile
49*af87fb4bSXin Li // <init>:KSFunctionDeclaration
50*af87fb4bSXin Li // propertyFoo.getter():KSPropertyAccessorImpl
51*af87fb4bSXin Li // p2:KSValueParameter
52*af87fb4bSXin Li // ==== Bnno in depth ====
53*af87fb4bSXin Li // File: Foo.kt:KSFile
54*af87fb4bSXin Li // <init>:KSFunctionDeclaration
55*af87fb4bSXin Li // propertyFoo.getter():KSPropertyAccessorImpl
56*af87fb4bSXin Li // p2:KSValueParameter
57*af87fb4bSXin Li // ==== A1 superficial====
58*af87fb4bSXin Li // Foo:KSClassDeclaration
59*af87fb4bSXin Li // <init>:KSFunctionDeclaration
60*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
61*af87fb4bSXin Li // param:KSValueParameter
62*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
63*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
64*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
65*af87fb4bSXin Li // p1:KSValueParameter
66*af87fb4bSXin Li // Bar:KSClassDeclaration
67*af87fb4bSXin Li // Baz:KSClassDeclaration
68*af87fb4bSXin Li // Burp:KSClassDeclaration
69*af87fb4bSXin Li // Flux:KSTypeAlias
70*af87fb4bSXin Li // ==== A1 in depth ====
71*af87fb4bSXin Li // Foo:KSClassDeclaration
72*af87fb4bSXin Li // <init>:KSFunctionDeclaration
73*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
74*af87fb4bSXin Li // param:KSValueParameter
75*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
76*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
77*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
78*af87fb4bSXin Li // p1:KSValueParameter
79*af87fb4bSXin Li // local:KSPropertyDeclaration
80*af87fb4bSXin Li // Bar:KSClassDeclaration
81*af87fb4bSXin Li // Baz:KSClassDeclaration
82*af87fb4bSXin Li // Burp:KSClassDeclaration
83*af87fb4bSXin Li // Flux:KSTypeAlias
84*af87fb4bSXin Li // ==== A2 superficial====
85*af87fb4bSXin Li // Foo:KSClassDeclaration
86*af87fb4bSXin Li // <init>:KSFunctionDeclaration
87*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
88*af87fb4bSXin Li // param:KSValueParameter
89*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
90*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
91*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
92*af87fb4bSXin Li // p1:KSValueParameter
93*af87fb4bSXin Li // Bar:KSClassDeclaration
94*af87fb4bSXin Li // Baz:KSClassDeclaration
95*af87fb4bSXin Li // Burp:KSClassDeclaration
96*af87fb4bSXin Li // Flux:KSTypeAlias
97*af87fb4bSXin Li // ==== A2 in depth ====
98*af87fb4bSXin Li // Foo:KSClassDeclaration
99*af87fb4bSXin Li // <init>:KSFunctionDeclaration
100*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
101*af87fb4bSXin Li // param:KSValueParameter
102*af87fb4bSXin Li // constructorParameterFoo:KSPropertyDeclaration
103*af87fb4bSXin Li // propertyFoo:KSPropertyDeclaration
104*af87fb4bSXin Li // functionFoo:KSFunctionDeclaration
105*af87fb4bSXin Li // p1:KSValueParameter
106*af87fb4bSXin Li // local:KSPropertyDeclaration
107*af87fb4bSXin Li // Bar:KSClassDeclaration
108*af87fb4bSXin Li // Baz:KSClassDeclaration
109*af87fb4bSXin Li // Burp:KSClassDeclaration
110*af87fb4bSXin Li // Flux:KSTypeAlias
111*af87fb4bSXin Li // ==== Cnno in depth ====
112*af87fb4bSXin Li // constructorParameterFoo:KSValueParameter
113*af87fb4bSXin Li // <set-?>:KSValueParameter
114*af87fb4bSXin Li // x:KSValueParameter
115*af87fb4bSXin Li // x:KSPropertyDeclaration
116*af87fb4bSXin Li // END
117*af87fb4bSXin Li //FILE: annotations.kt
118*af87fb4bSXin Li annotation class Anno
119*af87fb4bSXin Li annotation class Bnno
120*af87fb4bSXin Li annotation class Cnno
121*af87fb4bSXin Li typealias A1 = Anno
122*af87fb4bSXin Li typealias A2 = A1
123*af87fb4bSXin Li 
124*af87fb4bSXin Li //FILE: Foo.kt
125*af87fb4bSXin Li @file:Bnno
126*af87fb4bSXin Li 
127*af87fb4bSXin Li import Anno
128*af87fb4bSXin Li import Anno as A3
129*af87fb4bSXin Li 
130*af87fb4bSXin Li @Anno
131*af87fb4bSXin Li class Foo @Anno constructor(@Anno @param:Cnno val constructorParameterFoo: Int, @Anno param: Int){
132*af87fb4bSXin Li     @Bnno constructor() {
133*af87fb4bSXin Li 
134*af87fb4bSXin Li     }
135*af87fb4bSXin Li 
136*af87fb4bSXin Li     @Anno
137*af87fb4bSXin Li     val propertyFoo: String
138*af87fb4bSXin Li     @Bnno get() = TODO()
139*af87fb4bSXin Li 
140*af87fb4bSXin Li     @Anno
functionFoonull141*af87fb4bSXin Li     fun functionFoo(@Anno p1: Int, @Bnno p2: Int) {
142*af87fb4bSXin Li         @Anno val local = 1
143*af87fb4bSXin Li     }
144*af87fb4bSXin Li 
145*af87fb4bSXin Li     @setparam:Cnno
146*af87fb4bSXin Li     var a = 1
147*af87fb4bSXin Li }
148*af87fb4bSXin Li 
149*af87fb4bSXin Li class C(@Cnno val x: Int)
150*af87fb4bSXin Li 
151*af87fb4bSXin Li @A1
152*af87fb4bSXin Li class Bar
153*af87fb4bSXin Li 
154*af87fb4bSXin Li @A2
155*af87fb4bSXin Li class Baz
156*af87fb4bSXin Li 
157*af87fb4bSXin Li @A3
158*af87fb4bSXin Li class Burp
159*af87fb4bSXin Li 
160*af87fb4bSXin Li @Anno
161*af87fb4bSXin Li typealias Flux = String
162