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.binary 19 20 import com.google.devtools.ksp.memoized 21 import com.google.devtools.ksp.symbol.* 22 import com.google.devtools.ksp.symbol.impl.toKSPropertyDeclaration 23 import com.google.devtools.ksp.toFunctionKSModifiers 24 import com.google.devtools.ksp.toKSModifiers 25 import org.jetbrains.kotlin.descriptors.PropertyAccessorDescriptor 26 27 abstract class KSPropertyAccessorDescriptorImpl(val descriptor: PropertyAccessorDescriptor) : KSPropertyAccessor { <lambda>null28 override val origin: Origin by lazy { 29 when (receiver.origin) { 30 // if receiver is kotlin source, that means we are a synthetic where developer 31 // didn't declare an explicit accessor so we used the descriptor instead 32 Origin.KOTLIN -> Origin.SYNTHETIC 33 else -> descriptor.origin 34 } 35 } 36 <lambda>null37 override val receiver: KSPropertyDeclaration by lazy { 38 descriptor.correspondingProperty.toKSPropertyDeclaration() 39 } 40 <lambda>null41 override val parent: KSNode? by lazy { 42 receiver 43 } 44 45 override val location: Location 46 get() { 47 // if receiver is kotlin source, that means `this` is synthetic hence we want the property's location 48 // Otherwise, receiver is also from a .class file where the location will be NoLocation 49 return receiver.location 50 } 51 <lambda>null52 override val annotations: Sequence<KSAnnotation> by lazy { 53 descriptor.annotations.asSequence().map { KSAnnotationDescriptorImpl.getCached(it, this) }.memoized() 54 } 55 <lambda>null56 override val modifiers: Set<Modifier> by lazy { 57 val modifiers = mutableSetOf<Modifier>() 58 modifiers.addAll(descriptor.toKSModifiers()) 59 modifiers.addAll(descriptor.toFunctionKSModifiers()) 60 modifiers 61 } 62 } 63