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