• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2020 Google LLC
3  * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 package com.google.devtools.ksp.symbol.impl.kotlin
19 
20 import com.google.devtools.ksp.processing.impl.findAnnotationFromUseSiteTarget
21 import com.google.devtools.ksp.symbol.*
22 import com.google.devtools.ksp.symbol.impl.toLocation
23 import com.google.devtools.ksp.toKSModifiers
24 import org.jetbrains.kotlin.psi.KtProperty
25 import org.jetbrains.kotlin.psi.KtPropertyAccessor
26 
27 abstract class KSPropertyAccessorImpl(val ktPropertyAccessor: KtPropertyAccessor) : KSPropertyAccessor {
28     companion object {
getCachednull29         fun getCached(ktPropertyAccessor: KtPropertyAccessor): KSPropertyAccessor {
30             return if (ktPropertyAccessor.isGetter) {
31                 KSPropertyGetterImpl.getCached(ktPropertyAccessor)
32             } else {
33                 KSPropertySetterImpl.getCached(ktPropertyAccessor)
34             }
35         }
36     }
<lambda>null37     override val receiver: KSPropertyDeclaration by lazy {
38         KSPropertyDeclarationImpl.getCached(ktPropertyAccessor.property as KtProperty)
39     }
<lambda>null40     override val annotations: Sequence<KSAnnotation> by lazy {
41         ktPropertyAccessor.filterUseSiteTargetAnnotations().map { KSAnnotationImpl.getCached(it) }
42             .plus(this.findAnnotationFromUseSiteTarget())
43     }
44 
<lambda>null45     override val parent: KSNode? by lazy {
46         receiver
47     }
48 
<lambda>null49     override val location: Location by lazy {
50         ktPropertyAccessor.toLocation()
51     }
52 
<lambda>null53     override val modifiers: Set<Modifier> by lazy {
54         ktPropertyAccessor.toKSModifiers()
55     }
56 
57     override val origin: Origin = Origin.KOTLIN
58 
acceptnull59     override fun <D, R> accept(visitor: KSVisitor<D, R>, data: D): R {
60         return visitor.visitPropertyAccessor(this, data)
61     }
62 
<lambda>null63     internal val originalAnnotations: List<KSAnnotation> by lazy {
64         ktPropertyAccessor.annotationEntries.map { KSAnnotationImpl.getCached(it) }
65     }
66 }
67