Generate constructor light methods with origin set to Kotlin class/object declaration

This commit is contained in:
Alexey Sedunov
2014-01-24 15:23:18 +04:00
parent 001d95f4b8
commit 5f69317f1e
2 changed files with 11 additions and 4 deletions
@@ -1114,7 +1114,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
assert constructorDescriptor != null;
final JvmMethodSignature constructorSignature = typeMapper.mapSignature(constructorDescriptor);
functionCodegen.generateMethod(null, constructorSignature, constructorDescriptor, constructorContext,
functionCodegen.generateMethod(myClass, constructorSignature, constructorDescriptor, constructorContext,
new FunctionGenerationStrategy.CodegenBased<ConstructorDescriptor>(state, constructorDescriptor) {
@NotNull
@Override
@@ -38,6 +38,8 @@ import org.jetbrains.jet.lang.psi.JetPropertyAccessor
import org.jetbrains.jet.lang.psi.psiUtil.getParentByType
import org.jetbrains.jet.lang.psi.JetProperty
import com.intellij.psi.PsiTypeParameter
import org.jetbrains.jet.lang.psi.JetClassOrObject
import com.intellij.psi.impl.light.LightTypeParameterListBuilder
public class KotlinLightMethodForDeclaration(
manager: PsiManager, override val delegate: PsiMethod, override val origin: JetDeclaration, containingClass: PsiClass
@@ -59,9 +61,14 @@ public class KotlinLightMethodForDeclaration(
private val typeParamsList: CachedValue<PsiTypeParameterList> by Delegates.blockingLazy {
val cacheManager = CachedValuesManager.getManager(delegate.getProject())
cacheManager.createCachedValue<PsiTypeParameterList>({
val declaration =
if (origin is JetPropertyAccessor) origin.getParentByType(javaClass<JetProperty>()) else origin
val list = LightClassUtil.buildLightTypeParameterList(this@KotlinLightMethodForDeclaration, origin)
val declaration = if (origin is JetPropertyAccessor) origin.getParentByType(javaClass<JetProperty>()) else origin
val list = if (origin is JetClassOrObject) {
LightTypeParameterListBuilder(getManager(), getLanguage())
}
else {
LightClassUtil.buildLightTypeParameterList(this@KotlinLightMethodForDeclaration, origin)
}
CachedValueProvider.Result.create(list, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT)
}, false)
}