UL method and parameter Move&Rename refactoring
This commit is contained in:
+8
-11
@@ -62,7 +62,7 @@ internal abstract class KtUltraLightMethod(
|
||||
override fun getParent() = this@KtUltraLightMethod
|
||||
override fun getContainingFile() = this@KtUltraLightMethod.containingFile
|
||||
}
|
||||
computeDescriptor()?.let {
|
||||
methodDescriptor?.let {
|
||||
for (ex in FunctionCodegen.getThrownExceptions(it)) {
|
||||
val psiClassType = ex.defaultType.asPsiType(support, TypeMappingMode.DEFAULT, list) as? PsiClassType ?: continue
|
||||
list.addReference(psiClassType)
|
||||
@@ -92,10 +92,10 @@ internal abstract class KtUltraLightMethod(
|
||||
|
||||
override fun getThrowsList(): PsiReferenceList = _throwsList
|
||||
|
||||
abstract fun computeDescriptor(): FunctionDescriptor?
|
||||
abstract val methodDescriptor: FunctionDescriptor?
|
||||
|
||||
private val lazyTypeErasure = lazyPub {
|
||||
computeDescriptor()
|
||||
methodDescriptor
|
||||
?.getSpecialSignatureInfo()
|
||||
?.isObjectReplacedWithTypeParameter
|
||||
?: false
|
||||
@@ -139,11 +139,11 @@ internal class KtUltraLightMethodForSourceDeclaration(
|
||||
else LightTypeParameterListBuilder(manager, language)
|
||||
}
|
||||
|
||||
override fun computeDescriptor() = kotlinOrigin?.resolve() as? FunctionDescriptor
|
||||
override val methodDescriptor = kotlinOrigin?.resolve() as? FunctionDescriptor
|
||||
}
|
||||
|
||||
internal class KtUltraLightMethodForDescriptor(
|
||||
private val descriptor: FunctionDescriptor,
|
||||
override val methodDescriptor: FunctionDescriptor,
|
||||
delegate: LightMethodBuilder,
|
||||
lightMemberOrigin: LightMemberOrigin?,
|
||||
support: KtUltraLightSupport,
|
||||
@@ -154,14 +154,11 @@ internal class KtUltraLightMethodForDescriptor(
|
||||
support,
|
||||
containingClass
|
||||
) {
|
||||
|
||||
override fun buildTypeParameterList() = buildTypeParameterList(descriptor, this, support)
|
||||
|
||||
override fun computeDescriptor() = descriptor
|
||||
override fun buildTypeParameterList() = buildTypeParameterList(methodDescriptor, this, support)
|
||||
|
||||
override val kotlinTypeForNullabilityAnnotation: KotlinType?
|
||||
get() = descriptor.returnType
|
||||
get() = methodDescriptor.returnType
|
||||
|
||||
override val givenAnnotations: List<KtLightAbstractAnnotation>
|
||||
get() = descriptor.obtainLightAnnotations(support, this)
|
||||
get() = methodDescriptor.obtainLightAnnotations(support, this)
|
||||
}
|
||||
+12
-12
@@ -69,7 +69,7 @@ internal abstract class KtUltraLightParameter(
|
||||
name: String,
|
||||
override val kotlinOrigin: KtParameter?,
|
||||
protected val support: KtUltraLightSupport,
|
||||
method: KtLightMethod
|
||||
method: KtUltraLightMethod
|
||||
) : org.jetbrains.kotlin.asJava.elements.LightParameter(
|
||||
name,
|
||||
PsiType.NULL,
|
||||
@@ -92,7 +92,7 @@ internal abstract class KtUltraLightParameter(
|
||||
override fun isValid() = parent.isValid
|
||||
|
||||
protected abstract val kotlinType: KotlinType?
|
||||
protected abstract fun computeContainingDescriptor(): CallableDescriptor?
|
||||
protected abstract val containingDescriptor: CallableDescriptor?
|
||||
|
||||
override val kotlinTypeForNullabilityAnnotation: KotlinType?
|
||||
get() {
|
||||
@@ -114,12 +114,12 @@ internal abstract class KtUltraLightParameter(
|
||||
if (kotlinType.isSuspendFunctionType) {
|
||||
kotlinType.asPsiType(support, TypeMappingMode.DEFAULT, this)
|
||||
} else {
|
||||
val containingDescriptor = computeContainingDescriptor() ?: return@lazyPub PsiType.NULL
|
||||
val containingDescriptor = containingDescriptor ?: return@lazyPub PsiType.NULL
|
||||
val mappedType = support.mapType(this) { typeMapper, sw ->
|
||||
typeMapper.writeParameterType(sw, kotlinType, containingDescriptor)
|
||||
}
|
||||
|
||||
if (method is KtUltraLightMethod && method.checkNeedToErasureParametersTypes)
|
||||
if (method.checkNeedToErasureParametersTypes)
|
||||
TypeConversionUtil.erasure(mappedType)
|
||||
else mappedType
|
||||
}
|
||||
@@ -142,17 +142,17 @@ internal abstract class KtAbstractUltraLightParameterForDeclaration(
|
||||
name: String,
|
||||
kotlinOrigin: KtParameter?,
|
||||
support: KtUltraLightSupport,
|
||||
method: KtLightMethod,
|
||||
method: KtUltraLightMethod,
|
||||
protected val containingDeclaration: KtCallableDeclaration
|
||||
) : KtUltraLightParameter(name, kotlinOrigin, support, method) {
|
||||
override fun computeContainingDescriptor() = containingDeclaration.resolve() as? CallableMemberDescriptor
|
||||
override val containingDescriptor: CallableDescriptor? = containingDeclaration.resolve() as? CallableMemberDescriptor
|
||||
}
|
||||
|
||||
internal class KtUltraLightParameterForSource(
|
||||
name: String,
|
||||
override val kotlinOrigin: KtParameter,
|
||||
support: KtUltraLightSupport,
|
||||
method: KtLightMethod,
|
||||
method: KtUltraLightMethod,
|
||||
containingDeclaration: KtCallableDeclaration
|
||||
) : KtAbstractUltraLightParameterForDeclaration(name, kotlinOrigin, support, method, containingDeclaration) {
|
||||
|
||||
@@ -173,7 +173,7 @@ internal class KtUltraLightParameterForSetterParameter(
|
||||
// KtProperty or KtParameter from primary constructor
|
||||
private val property: KtDeclaration,
|
||||
support: KtUltraLightSupport,
|
||||
method: KtLightMethod,
|
||||
method: KtUltraLightMethod,
|
||||
containingDeclaration: KtCallableDeclaration
|
||||
) : KtAbstractUltraLightParameterForDeclaration(name, null, support, method, containingDeclaration) {
|
||||
|
||||
@@ -185,18 +185,18 @@ internal class KtUltraLightParameterForSetterParameter(
|
||||
internal class KtUltraLightReceiverParameter(
|
||||
containingDeclaration: KtCallableDeclaration,
|
||||
support: KtUltraLightSupport,
|
||||
method: KtLightMethod
|
||||
method: KtUltraLightMethod
|
||||
) : KtAbstractUltraLightParameterForDeclaration("\$self", null, support, method, containingDeclaration) {
|
||||
|
||||
override fun isVarArgs(): Boolean = false
|
||||
|
||||
override val kotlinType: KotlinType? by lazyPub { computeContainingDescriptor()?.extensionReceiverParameter?.type }
|
||||
override val kotlinType: KotlinType? by lazyPub { containingDescriptor?.extensionReceiverParameter?.type }
|
||||
}
|
||||
|
||||
internal class KtUltraLightParameterForDescriptor(
|
||||
private val descriptor: ParameterDescriptor,
|
||||
support: KtUltraLightSupport,
|
||||
method: KtLightMethod
|
||||
method: KtUltraLightMethod
|
||||
) : KtUltraLightParameter(
|
||||
if (descriptor.name.isSpecial) "\$self" else descriptor.name.identifier,
|
||||
null, support, method
|
||||
@@ -204,7 +204,7 @@ internal class KtUltraLightParameterForDescriptor(
|
||||
override val kotlinType: KotlinType?
|
||||
get() = descriptor.type
|
||||
|
||||
override fun computeContainingDescriptor() = descriptor.containingDeclaration as? CallableMemberDescriptor
|
||||
override val containingDescriptor: CallableDescriptor? = descriptor.containingDeclaration as? CallableMemberDescriptor
|
||||
|
||||
override fun isVarArgs() = (descriptor as? ValueParameterDescriptor)?.varargElementType != null
|
||||
|
||||
|
||||
Reference in New Issue
Block a user