[AA] KtSymbol: add context receiver to 'createPointer'
^KT-54051
This commit is contained in:
committed by
Space Team
parent
73372e557e
commit
e27ffada26
+4
-2
@@ -132,7 +132,7 @@ internal open class SymbolLightClass(classOrObject: KtClassOrObject, ktModule: K
|
||||
}
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
private fun addMethodsFromDataClass(result: MutableList<KtLightMethod>, classOrObjectSymbol: KtNamedClassOrObjectSymbol) {
|
||||
if (!classOrObjectSymbol.isData) return
|
||||
|
||||
@@ -141,6 +141,7 @@ internal open class SymbolLightClass(classOrObject: KtClassOrObject, ktModule: K
|
||||
val lightMemberOrigin = LightMemberOriginForDeclaration(classOrObject, JvmDeclarationOriginKind.OTHER)
|
||||
result.add(
|
||||
SymbolLightSimpleMethod(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
ktFunctionSymbol, lightMemberOrigin, this, METHOD_INDEX_BASE, false,
|
||||
suppressStatic = false
|
||||
)
|
||||
@@ -185,13 +186,14 @@ internal open class SymbolLightClass(classOrObject: KtClassOrObject, ktModule: K
|
||||
private val Name.isFromAny: Boolean
|
||||
get() = this == EQUALS || this == HASHCODE_NAME || this == TO_STRING
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
private fun addDelegatesToInterfaceMethods(result: MutableList<KtLightMethod>, classOrObjectSymbol: KtNamedClassOrObjectSymbol) {
|
||||
fun createDelegateMethod(ktFunctionSymbol: KtFunctionSymbol) {
|
||||
val kotlinOrigin = ktFunctionSymbol.psiSafe<KtDeclaration>() ?: classOrObject
|
||||
val lightMemberOrigin = LightMemberOriginForDeclaration(kotlinOrigin, JvmDeclarationOriginKind.DELEGATION)
|
||||
result.add(
|
||||
SymbolLightSimpleMethod(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
ktFunctionSymbol,
|
||||
lightMemberOrigin,
|
||||
this,
|
||||
|
||||
+1
@@ -161,6 +161,7 @@ abstract class SymbolLightClassForClassOrObject(protected val classOrObject: KtC
|
||||
}
|
||||
?.mapTo(result) {
|
||||
SymbolLightFieldForProperty(
|
||||
ktAnalysisSession = this,
|
||||
propertySymbol = it,
|
||||
fieldName = it.name.asString(),
|
||||
containingClass = this@SymbolLightClassForClassOrObject,
|
||||
|
||||
+28
-38
@@ -71,7 +71,7 @@ private fun lightClassForEnumEntry(ktEnumEntry: KtEnumEntry): KtLightClass? {
|
||||
return (targetField as? SymbolLightFieldForEnumEntry)?.initializingClass as? KtLightClass
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
internal fun SymbolLightClassForClassOrObject.createConstructors(
|
||||
declarations: Sequence<KtConstructorSymbol>,
|
||||
result: MutableList<KtLightMethod>,
|
||||
@@ -87,6 +87,7 @@ internal fun SymbolLightClassForClassOrObject.createConstructors(
|
||||
|
||||
result.add(
|
||||
SymbolLightConstructor(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
constructorSymbol = constructor,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createConstructors,
|
||||
@@ -96,6 +97,7 @@ internal fun SymbolLightClassForClassOrObject.createConstructors(
|
||||
|
||||
createJvmOverloadsIfNeeded(constructor, result) { methodIndex, argumentSkipMask ->
|
||||
SymbolLightConstructor(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
constructorSymbol = constructor,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createConstructors,
|
||||
@@ -152,7 +154,7 @@ private fun SymbolLightClassForClassOrObject.noArgConstructor(
|
||||
methodIndex,
|
||||
)
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
internal fun SymbolLightClassBase.createMethods(
|
||||
declarations: Sequence<KtCallableSymbol>,
|
||||
result: MutableList<KtLightMethod>,
|
||||
@@ -161,7 +163,7 @@ internal fun SymbolLightClassBase.createMethods(
|
||||
) {
|
||||
val (ctorProperties, regularMembers) = declarations.partition { it is KtPropertySymbol && it.isFromPrimaryConstructor }
|
||||
|
||||
fun handleDeclaration(declaration: KtCallableSymbol) {
|
||||
fun KtAnalysisSession.handleDeclaration(declaration: KtCallableSymbol) {
|
||||
when (declaration) {
|
||||
is KtFunctionSymbol -> {
|
||||
// TODO: check if it has expect modifier
|
||||
@@ -170,6 +172,7 @@ internal fun SymbolLightClassBase.createMethods(
|
||||
|
||||
result.add(
|
||||
SymbolLightSimpleMethod(
|
||||
ktAnalysisSession = this,
|
||||
functionSymbol = declaration,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createMethods,
|
||||
@@ -181,6 +184,7 @@ internal fun SymbolLightClassBase.createMethods(
|
||||
|
||||
createJvmOverloadsIfNeeded(declaration, result) { methodIndex, argumentSkipMask ->
|
||||
SymbolLightSimpleMethod(
|
||||
ktAnalysisSession = this,
|
||||
functionSymbol = declaration,
|
||||
lightMemberOrigin = null,
|
||||
containingClass = this@createMethods,
|
||||
@@ -206,11 +210,11 @@ internal fun SymbolLightClassBase.createMethods(
|
||||
|
||||
// Regular members
|
||||
regularMembers.forEach {
|
||||
handleDeclaration(it)
|
||||
this@ktAnalysisSession.handleDeclaration(it)
|
||||
}
|
||||
// Then, properties from the primary constructor parameters
|
||||
ctorProperties.forEach {
|
||||
handleDeclaration(it)
|
||||
this@ktAnalysisSession.handleDeclaration(it)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,7 +236,7 @@ private inline fun <T : KtFunctionLikeSymbol> SymbolLightClassBase.createJvmOver
|
||||
}
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
internal fun SymbolLightClassBase.createPropertyAccessors(
|
||||
result: MutableList<KtLightMethod>,
|
||||
declaration: KtPropertySymbol,
|
||||
@@ -257,8 +261,7 @@ internal fun SymbolLightClassBase.createPropertyAccessors(
|
||||
if (declaration.hasReifiedParameters) return false
|
||||
if (!hasBody && visibility.isPrivateOrPrivateToThis()) return false
|
||||
if (declaration.isHiddenOrSynthetic(siteTarget)) return false
|
||||
if (isHiddenOrSynthetic()) return false
|
||||
return true
|
||||
return !isHiddenOrSynthetic()
|
||||
}
|
||||
|
||||
val originalElement = declaration.sourcePsiSafe<KtDeclaration>()
|
||||
@@ -267,54 +270,40 @@ internal fun SymbolLightClassBase.createPropertyAccessors(
|
||||
it.needToCreateAccessor(AnnotationUseSiteTarget.PROPERTY_GETTER)
|
||||
}
|
||||
|
||||
if (getter != null) {
|
||||
fun createSymbolLightAccessorMethod(accessor: KtPropertyAccessorSymbol): SymbolLightAccessorMethod {
|
||||
val lightMemberOrigin = originalElement?.let {
|
||||
LightMemberOriginForDeclaration(
|
||||
originalElement = it,
|
||||
originKind = JvmDeclarationOriginKind.OTHER,
|
||||
auxiliaryOriginalElement = getter.sourcePsiSafe<KtDeclaration>()
|
||||
auxiliaryOriginalElement = accessor.sourcePsiSafe<KtDeclaration>()
|
||||
)
|
||||
}
|
||||
|
||||
result.add(
|
||||
SymbolLightAccessorMethod(
|
||||
propertyAccessorSymbol = getter,
|
||||
containingPropertySymbol = declaration,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = this@createPropertyAccessors,
|
||||
isTopLevel = isTopLevel,
|
||||
suppressStatic = suppressStatic,
|
||||
)
|
||||
return SymbolLightAccessorMethod(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
propertyAccessorSymbol = accessor,
|
||||
containingPropertySymbol = declaration,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = this@createPropertyAccessors,
|
||||
isTopLevel = isTopLevel,
|
||||
suppressStatic = suppressStatic,
|
||||
)
|
||||
}
|
||||
|
||||
if (getter != null) {
|
||||
result.add(createSymbolLightAccessorMethod(getter))
|
||||
}
|
||||
|
||||
val setter = declaration.setter?.takeIf {
|
||||
!isAnnotationType && it.needToCreateAccessor(AnnotationUseSiteTarget.PROPERTY_SETTER)
|
||||
}
|
||||
|
||||
if (isMutable && setter != null) {
|
||||
val lightMemberOrigin = originalElement?.let {
|
||||
LightMemberOriginForDeclaration(
|
||||
originalElement = it,
|
||||
originKind = JvmDeclarationOriginKind.OTHER,
|
||||
auxiliaryOriginalElement = setter.sourcePsiSafe<KtDeclaration>()
|
||||
)
|
||||
}
|
||||
|
||||
result.add(
|
||||
SymbolLightAccessorMethod(
|
||||
propertyAccessorSymbol = setter,
|
||||
containingPropertySymbol = declaration,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = this@createPropertyAccessors,
|
||||
isTopLevel = isTopLevel,
|
||||
suppressStatic = suppressStatic,
|
||||
)
|
||||
)
|
||||
result.add(createSymbolLightAccessorMethod(setter))
|
||||
}
|
||||
}
|
||||
|
||||
context(KtAnalysisSession)
|
||||
context(ktAnalysisSession@KtAnalysisSession)
|
||||
internal fun SymbolLightClassBase.createField(
|
||||
declaration: KtPropertySymbol,
|
||||
nameGenerator: SymbolLightField.FieldNameGenerator,
|
||||
@@ -348,6 +337,7 @@ internal fun SymbolLightClassBase.createField(
|
||||
|
||||
result.add(
|
||||
SymbolLightFieldForProperty(
|
||||
ktAnalysisSession = this@ktAnalysisSession,
|
||||
propertySymbol = declaration,
|
||||
fieldName = fieldName,
|
||||
containingClass = this,
|
||||
|
||||
+22
-4
@@ -31,17 +31,35 @@ import org.jetbrains.kotlin.name.JvmNames.VOLATILE_ANNOTATION_CLASS_ID
|
||||
import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtProperty
|
||||
|
||||
internal class SymbolLightFieldForProperty(
|
||||
propertySymbol: KtPropertySymbol,
|
||||
internal class SymbolLightFieldForProperty private constructor(
|
||||
private val propertySymbolPointer: KtSymbolPointer<KtPropertySymbol>,
|
||||
private val fieldName: String,
|
||||
containingClass: SymbolLightClassBase,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
isTopLevel: Boolean,
|
||||
forceStatic: Boolean,
|
||||
takePropertyVisibility: Boolean,
|
||||
override val kotlinOrigin: KtCallableDeclaration?,
|
||||
) : SymbolLightField(containingClass, lightMemberOrigin) {
|
||||
override val kotlinOrigin: KtCallableDeclaration? = propertySymbol.sourcePsiSafe<KtCallableDeclaration>()
|
||||
private val propertySymbolPointer: KtSymbolPointer<KtPropertySymbol> = propertySymbol.createPointer()
|
||||
internal constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
propertySymbol: KtPropertySymbol,
|
||||
fieldName: String,
|
||||
containingClass: SymbolLightClassBase,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
isTopLevel: Boolean,
|
||||
forceStatic: Boolean,
|
||||
takePropertyVisibility: Boolean,
|
||||
) : this(
|
||||
propertySymbolPointer = with(ktAnalysisSession) { propertySymbol.createPointer() },
|
||||
fieldName = fieldName,
|
||||
containingClass = containingClass,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
isTopLevel = isTopLevel,
|
||||
forceStatic = forceStatic,
|
||||
takePropertyVisibility = takePropertyVisibility,
|
||||
kotlinOrigin = propertySymbol.sourcePsiSafe<KtCallableDeclaration>(),
|
||||
)
|
||||
|
||||
private fun <T> withPropertySymbol(action: context (KtAnalysisSession) (KtPropertySymbol) -> T): T {
|
||||
return propertySymbolPointer.withSymbol(ktModule, action)
|
||||
|
||||
+33
-13
@@ -39,31 +39,48 @@ import org.jetbrains.kotlin.psi.KtParameter
|
||||
import org.jetbrains.kotlin.psi.KtPropertyAccessor
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||
|
||||
internal class SymbolLightAccessorMethod(
|
||||
propertyAccessorSymbol: KtPropertyAccessorSymbol,
|
||||
containingPropertySymbol: KtPropertySymbol,
|
||||
internal class SymbolLightAccessorMethod private constructor(
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
methodIndex: Int,
|
||||
private val isGetter: Boolean,
|
||||
private val propertyAccessorDeclaration: KtPropertyAccessor?,
|
||||
private val propertyAccessorSymbolPointer: KtSymbolPointer<KtPropertyAccessorSymbol>,
|
||||
private val containingPropertyDeclaration: KtCallableDeclaration?,
|
||||
private val containingPropertySymbolPointer: KtSymbolPointer<KtPropertySymbol>,
|
||||
private val isTopLevel: Boolean,
|
||||
private val suppressStatic: Boolean = false,
|
||||
private val suppressStatic: Boolean,
|
||||
) : SymbolLightMethodBase(
|
||||
lightMemberOrigin,
|
||||
containingClass,
|
||||
if (propertyAccessorSymbol is KtPropertyGetterSymbol) METHOD_INDEX_FOR_GETTER else METHOD_INDEX_FOR_SETTER,
|
||||
methodIndex,
|
||||
) {
|
||||
private val isGetter: Boolean = propertyAccessorSymbol is KtPropertyGetterSymbol
|
||||
|
||||
private val propertyAccessorDeclaration: KtPropertyAccessor? = propertyAccessorSymbol.sourcePsiSafe()
|
||||
private val propertyAccessorSymbolPointer: KtSymbolPointer<KtPropertyAccessorSymbol> = propertyAccessorSymbol.createPointer()
|
||||
internal constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
propertyAccessorSymbol: KtPropertyAccessorSymbol,
|
||||
containingPropertySymbol: KtPropertySymbol,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
isTopLevel: Boolean,
|
||||
suppressStatic: Boolean = false,
|
||||
) : this(
|
||||
lightMemberOrigin,
|
||||
containingClass,
|
||||
methodIndex = if (propertyAccessorSymbol is KtPropertyGetterSymbol) METHOD_INDEX_FOR_GETTER else METHOD_INDEX_FOR_SETTER,
|
||||
isGetter = propertyAccessorSymbol is KtPropertyGetterSymbol,
|
||||
propertyAccessorDeclaration = propertyAccessorSymbol.sourcePsiSafe(),
|
||||
propertyAccessorSymbolPointer = with(ktAnalysisSession) { propertyAccessorSymbol.createPointer() },
|
||||
containingPropertyDeclaration = containingPropertySymbol.sourcePsiSafe(),
|
||||
containingPropertySymbolPointer = with(ktAnalysisSession) { containingPropertySymbol.createPointer() },
|
||||
isTopLevel = isTopLevel,
|
||||
suppressStatic = suppressStatic,
|
||||
)
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun propertyAccessorSymbol(): KtPropertyAccessorSymbol {
|
||||
return propertyAccessorSymbolPointer.restoreSymbolOrThrowIfDisposed()
|
||||
}
|
||||
|
||||
private val containingPropertyDeclaration: KtCallableDeclaration? = containingPropertySymbol.sourcePsiSafe()
|
||||
private val containingPropertySymbolPointer: KtSymbolPointer<KtPropertySymbol> = containingPropertySymbol.createPointer()
|
||||
|
||||
context(KtAnalysisSession)
|
||||
private fun propertySymbol(): KtPropertySymbol {
|
||||
return containingPropertySymbolPointer.restoreSymbolOrThrowIfDisposed()
|
||||
@@ -226,7 +243,10 @@ internal class SymbolLightAccessorMethod(
|
||||
if (propertyParameter != null) {
|
||||
builder.addParameter(
|
||||
SymbolLightSetterParameter(
|
||||
containingPropertySymbolPointer, propertyParameter, this@SymbolLightAccessorMethod
|
||||
ktAnalysisSession = this,
|
||||
containingPropertySymbolPointer = containingPropertySymbolPointer,
|
||||
parameterSymbol = propertyParameter,
|
||||
containingMethod = this@SymbolLightAccessorMethod,
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
+3
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.methods
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||
import org.jetbrains.kotlin.asJava.builder.LightMemberOrigin
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
@@ -18,19 +19,20 @@ import org.jetbrains.kotlin.light.classes.symbol.toPsiVisibilityForMember
|
||||
import java.util.*
|
||||
|
||||
internal class SymbolLightConstructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
constructorSymbol: KtConstructorSymbol,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
methodIndex: Int,
|
||||
argumentsSkipMask: BitSet? = null,
|
||||
) : SymbolLightMethod<KtConstructorSymbol>(
|
||||
ktAnalysisSession = ktAnalysisSession,
|
||||
functionSymbol = constructorSymbol,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = containingClass,
|
||||
methodIndex = methodIndex,
|
||||
argumentsSkipMask = argumentsSkipMask
|
||||
) {
|
||||
|
||||
private val _name: String? = containingClass.name
|
||||
|
||||
override fun getName(): String = _name ?: ""
|
||||
|
||||
+25
-10
@@ -28,21 +28,38 @@ import org.jetbrains.kotlin.psi.KtCallableDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import java.util.*
|
||||
|
||||
internal abstract class SymbolLightMethod<FType : KtFunctionLikeSymbol>(
|
||||
functionSymbol: FType,
|
||||
internal abstract class SymbolLightMethod<FType : KtFunctionLikeSymbol> private constructor(
|
||||
protected val functionSymbolPointer: KtSymbolPointer<FType>,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
methodIndex: Int,
|
||||
private val argumentsSkipMask: BitSet? = null,
|
||||
private val argumentsSkipMask: BitSet?,
|
||||
protected val functionDeclaration: KtCallableDeclaration?,
|
||||
override val kotlinOrigin: KtDeclaration?,
|
||||
) : SymbolLightMethodBase(
|
||||
lightMemberOrigin,
|
||||
containingClass,
|
||||
methodIndex,
|
||||
) {
|
||||
protected val functionDeclaration: KtCallableDeclaration? = functionSymbol.sourcePsiSafe()
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
protected val functionSymbolPointer: KtSymbolPointer<FType> = functionSymbol.createPointer() as KtSymbolPointer<FType>
|
||||
internal constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
functionSymbol: FType,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
methodIndex: Int,
|
||||
argumentsSkipMask: BitSet? = null,
|
||||
) : this(
|
||||
functionSymbolPointer = with(ktAnalysisSession) {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
functionSymbol.createPointer() as KtSymbolPointer<FType>
|
||||
},
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = containingClass,
|
||||
methodIndex = methodIndex,
|
||||
argumentsSkipMask = argumentsSkipMask,
|
||||
functionDeclaration = functionSymbol.sourcePsiSafe(),
|
||||
kotlinOrigin = functionSymbol.sourcePsiSafe() ?: lightMemberOrigin?.originalElement ?: functionSymbol.psiSafe<KtDeclaration>(),
|
||||
)
|
||||
|
||||
protected fun <T> withFunctionSymbol(action: KtAnalysisSession.(FType) -> T): T = functionSymbolPointer.withSymbol(ktModule, action)
|
||||
|
||||
@@ -65,6 +82,7 @@ internal abstract class SymbolLightMethod<FType : KtFunctionLikeSymbol>(
|
||||
if (!needToSkip) {
|
||||
builder.addParameter(
|
||||
SymbolLightParameter(
|
||||
ktAnalysisSession = this,
|
||||
parameterSymbol = parameter,
|
||||
containingMethod = this@SymbolLightMethod,
|
||||
)
|
||||
@@ -101,9 +119,6 @@ internal abstract class SymbolLightMethod<FType : KtFunctionLikeSymbol>(
|
||||
|
||||
override fun getParameterList(): PsiParameterList = _parametersList
|
||||
|
||||
override val kotlinOrigin: KtDeclaration? =
|
||||
functionDeclaration ?: lightMemberOrigin?.originalElement ?: functionSymbol.psiSafe<KtDeclaration>()
|
||||
|
||||
override fun isValid(): Boolean = super.isValid() && functionDeclaration?.isValid ?: functionSymbolPointer.isValid(ktModule)
|
||||
|
||||
override fun isOverride(): Boolean = withFunctionSymbol { it.getDirectlyOverriddenSymbols().isNotEmpty() }
|
||||
|
||||
+3
-1
@@ -27,14 +27,16 @@ import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||
import java.util.*
|
||||
|
||||
internal class SymbolLightSimpleMethod(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
functionSymbol: KtFunctionSymbol,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
containingClass: SymbolLightClassBase,
|
||||
methodIndex: Int,
|
||||
private val isTopLevel: Boolean,
|
||||
argumentsSkipMask: BitSet? = null,
|
||||
private val suppressStatic: Boolean = false
|
||||
private val suppressStatic: Boolean = false,
|
||||
) : SymbolLightMethod<KtFunctionSymbol>(
|
||||
ktAnalysisSession = ktAnalysisSession,
|
||||
functionSymbol = functionSymbol,
|
||||
lightMemberOrigin = lightMemberOrigin,
|
||||
containingClass = containingClass,
|
||||
|
||||
+4
-2
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.light.classes.symbol.parameters
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||
import org.jetbrains.kotlin.asJava.classes.lazyPub
|
||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||
@@ -18,9 +19,10 @@ import org.jetbrains.kotlin.light.classes.symbol.withSymbol
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.ifTrue
|
||||
|
||||
internal class SymbolLightParameter(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
parameterSymbol: KtValueParameterSymbol,
|
||||
containingMethod: SymbolLightMethodBase
|
||||
) : SymbolLightParameterCommon(parameterSymbol, containingMethod) {
|
||||
) : SymbolLightParameterCommon(ktAnalysisSession, parameterSymbol, containingMethod) {
|
||||
private val isConstructorParameterSymbol = containingMethod.isConstructor
|
||||
|
||||
private val _annotations: List<PsiAnnotation> by lazyPub {
|
||||
@@ -33,7 +35,7 @@ internal class SymbolLightParameter(
|
||||
val nullability = if (parameterSymbol.isVararg) NullabilityType.NotNull else super.nullabilityType
|
||||
|
||||
parameterSymbol.computeAnnotations(
|
||||
parent = this,
|
||||
parent = this@SymbolLightParameter,
|
||||
nullability = nullability,
|
||||
annotationUseSiteTarget = annotationSite,
|
||||
includeAnnotationsWithoutSite = true
|
||||
|
||||
+15
-6
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.light.classes.symbol.parameters
|
||||
|
||||
import com.intellij.psi.*
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.psiSafe
|
||||
@@ -18,11 +19,21 @@ import org.jetbrains.kotlin.light.classes.symbol.methods.SymbolLightMethodBase
|
||||
import org.jetbrains.kotlin.psi.KtParameter
|
||||
|
||||
internal abstract class SymbolLightParameterCommon(
|
||||
parameterSymbol: KtValueParameterSymbol,
|
||||
private val containingMethod: SymbolLightMethodBase
|
||||
protected val parameterSymbolPointer: KtSymbolPointer<KtValueParameterSymbol>,
|
||||
protected val parameterDeclaration: KtParameter?,
|
||||
private val containingMethod: SymbolLightMethodBase,
|
||||
override val kotlinOrigin: KtParameter?,
|
||||
) : SymbolLightParameterBase(containingMethod) {
|
||||
protected val parameterSymbolPointer: KtSymbolPointer<KtValueParameterSymbol> = parameterSymbol.createPointer()
|
||||
protected val parameterDeclaration: KtParameter? = parameterSymbol.sourcePsiSafe()
|
||||
internal constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
parameterSymbol: KtValueParameterSymbol,
|
||||
containingMethod: SymbolLightMethodBase,
|
||||
) : this(
|
||||
parameterSymbolPointer = with(ktAnalysisSession) { parameterSymbol.createPointer() },
|
||||
parameterDeclaration = parameterSymbol.sourcePsiSafe(),
|
||||
containingMethod = containingMethod,
|
||||
kotlinOrigin = parameterSymbol.psiSafe(),
|
||||
)
|
||||
|
||||
private val _name: String by lazy {
|
||||
parameterSymbolPointer.withSymbol(ktModule) {
|
||||
@@ -34,8 +45,6 @@ internal abstract class SymbolLightParameterCommon(
|
||||
|
||||
override fun hasModifierProperty(name: String): Boolean = modifierList.hasModifierProperty(name)
|
||||
|
||||
override val kotlinOrigin: KtParameter? = parameterDeclaration ?: parameterSymbol.psiSafe()
|
||||
|
||||
abstract override fun getModifierList(): PsiModifierList
|
||||
|
||||
private val _identifier: PsiIdentifier by lazy {
|
||||
|
||||
+3
-1
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.light.classes.symbol.parameters
|
||||
|
||||
import com.intellij.psi.PsiAnnotation
|
||||
import com.intellij.psi.PsiModifierList
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtPropertySymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||
@@ -22,10 +23,11 @@ import org.jetbrains.kotlin.light.classes.symbol.withSymbol
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
|
||||
internal class SymbolLightSetterParameter(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
private val containingPropertySymbolPointer: KtSymbolPointer<KtPropertySymbol>,
|
||||
parameterSymbol: KtValueParameterSymbol,
|
||||
containingMethod: SymbolLightMethodBase,
|
||||
) : SymbolLightParameterCommon(parameterSymbol, containingMethod) {
|
||||
) : SymbolLightParameterCommon(ktAnalysisSession, parameterSymbol, containingMethod) {
|
||||
override fun getName(): String {
|
||||
if (isDefaultSetterParameter) return SpecialNames.IMPLICIT_SET_PARAMETER.asString()
|
||||
return super.getName()
|
||||
|
||||
+7
-2
@@ -42,10 +42,15 @@ internal class SymbolLightTypeParameter private constructor(
|
||||
) : LightElement(parent.manager, KotlinLanguage.INSTANCE), PsiTypeParameter,
|
||||
KtLightDeclaration<KtTypeParameter, PsiTypeParameter> {
|
||||
|
||||
constructor(parent: SymbolLightTypeParameterList, index: Int, typeParameterSymbol: KtTypeParameterSymbol) : this(
|
||||
constructor(
|
||||
ktAnalysisSession: KtAnalysisSession,
|
||||
parent: SymbolLightTypeParameterList,
|
||||
index: Int,
|
||||
typeParameterSymbol: KtTypeParameterSymbol,
|
||||
) : this(
|
||||
parent = parent,
|
||||
index = index,
|
||||
typeParameterSymbolPointer = typeParameterSymbol.createPointer(),
|
||||
typeParameterSymbolPointer = with(ktAnalysisSession) { typeParameterSymbol.createPointer() },
|
||||
typeParameterDeclaration = typeParameterSymbol.sourcePsiSafe(),
|
||||
kotlinOrigin = typeParameterSymbol.psiSafe(),
|
||||
)
|
||||
|
||||
+2
-1
@@ -43,7 +43,8 @@ internal class SymbolLightTypeParameterList(
|
||||
symbolWithTypeParameterPointer.withSymbol(ktModule) {
|
||||
it.typeParameters.mapIndexed { index, parameter ->
|
||||
SymbolLightTypeParameter(
|
||||
parent = this,
|
||||
ktAnalysisSession = this,
|
||||
parent = this@SymbolLightTypeParameterList,
|
||||
index = index,
|
||||
typeParameterSymbol = parameter,
|
||||
)
|
||||
|
||||
+1
-1
@@ -311,5 +311,5 @@ internal fun <T : KtSymbol> compareSymbolPointers(ktModule: KtModule, left: KtSy
|
||||
|
||||
internal inline fun <T : KtSymbol, R> KtSymbolPointer<T>.withSymbol(
|
||||
ktModule: KtModule,
|
||||
crossinline action: context(KtAnalysisSession) (T) -> R,
|
||||
crossinline action: KtAnalysisSession.(T) -> R,
|
||||
): R = analyzeForLightClasses(ktModule) { action(this, restoreSymbolOrThrowIfDisposed()) }
|
||||
|
||||
Reference in New Issue
Block a user