From abd3ac4e9695fdd738e059bafd0b11d46ab3c04a Mon Sep 17 00:00:00 2001 From: Vyacheslav Gerasimov Date: Tue, 26 Jun 2018 20:57:30 +0300 Subject: [PATCH] UAST: Reformat KotlinUObjectLiteralExpression.kt --- .../KotlinUObjectLiteralExpression.kt | 30 ++++++++-------- .../KotlinUObjectLiteralExpression.kt.172 | 34 ++++++++++--------- .../KotlinUObjectLiteralExpression.kt.173 | 32 ++++++++--------- 3 files changed, 49 insertions(+), 47 deletions(-) diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt index b4b70818cd3..40e3c72b6a7 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt @@ -29,46 +29,46 @@ import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.uast.* class KotlinUObjectLiteralExpression( - override val psi: KtObjectLiteralExpression, - givenParent: UElement? + override val psi: KtObjectLiteralExpression, + givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UObjectLiteralExpression, UCallExpressionEx, KotlinUElementWithType { override val declaration: UClass by lz { val lightClass: KtLightClass? = psi.objectDeclaration.toLightClass() if (lightClass != null) { getLanguagePlugin().convert(lightClass, this) - } - else { + } else { logger.error( - "Failed to create light class for object declaration", - Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text)) + "Failed to create light class for object declaration", + Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text) + ) getLanguagePlugin().convert(LightPsiClassBuilder(psi, ""), this) } } - + override fun getExpressionType() = psi.objectDeclaration.toPsiType() private val superClassConstructorCall by lz { psi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry } - + override val classReference: UReferenceExpression? by lz { superClassConstructorCall?.let { ObjectLiteralClassReference(it, this) } } - + override val valueArgumentCount: Int get() = superClassConstructorCall?.valueArguments?.size ?: 0 override val valueArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } + psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } - + override val typeArgumentCount: Int get() = superClassConstructorCall?.typeArguments?.size ?: 0 override val typeArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } + psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } override fun resolve() = superClassConstructorCall?.resolveCallToDeclaration(this) as? PsiMethod @@ -77,8 +77,8 @@ class KotlinUObjectLiteralExpression( superClassConstructorCall?.let { it.getResolvedCall(it.analyze()) }?.let { getArgumentExpressionByIndex(i, it, this) } private class ObjectLiteralClassReference( - override val psi: KtSuperTypeCallEntry, - givenParent: UElement? + override val psi: KtSuperTypeCallEntry, + givenParent: UElement? ) : KotlinAbstractUElement(givenParent), USimpleNameReferenceExpression { override val javaPsi = null @@ -91,7 +91,7 @@ class KotlinUObjectLiteralExpression( override val resolvedName: String? get() = identifier - + override val identifier: String get() = psi.name ?: "" } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.172 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.172 index 546c5c405f9..51fe5966265 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.172 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.172 @@ -28,53 +28,55 @@ import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry import org.jetbrains.uast.* class KotlinUObjectLiteralExpression( - override val psi: KtObjectLiteralExpression, - givenParent: UElement? + override val psi: KtObjectLiteralExpression, + givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UObjectLiteralExpression, KotlinUElementWithType { + override val declaration: UClass by lz { val lightClass: KtLightClass? = psi.objectDeclaration.toLightClass() if (lightClass != null) { getLanguagePlugin().convert(lightClass, this) - } - else { + } else { logger.error( - "Failed to create light class for object declaration", - Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text)) + "Failed to create light class for object declaration", + Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text) + ) getLanguagePlugin().convert(LightPsiClassBuilder(psi, ""), this) } } - + override fun getExpressionType() = psi.objectDeclaration.toPsiType() private val superClassConstructorCall by lz { psi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry } - + override val classReference: UReferenceExpression? by lz { superClassConstructorCall?.let { ObjectLiteralClassReference(it, this) } } - + override val valueArgumentCount: Int get() = superClassConstructorCall?.valueArguments?.size ?: 0 override val valueArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } + psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } - + override val typeArgumentCount: Int get() = superClassConstructorCall?.typeArguments?.size ?: 0 override val typeArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } + psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } override fun resolve() = superClassConstructorCall?.resolveCallToDeclaration(this) as? PsiMethod - + private class ObjectLiteralClassReference( - override val psi: KtSuperTypeCallEntry, - givenParent: UElement? + override val psi: KtSuperTypeCallEntry, + givenParent: UElement? ) : KotlinAbstractUElement(givenParent), USimpleNameReferenceExpression { + override fun resolve() = (psi.resolveCallToDeclaration(this) as? PsiMethod)?.containingClass override val annotations: List @@ -82,7 +84,7 @@ class KotlinUObjectLiteralExpression( override val resolvedName: String? get() = identifier - + override val identifier: String get() = psi.name ?: "" } diff --git a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.173 b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.173 index b65009c9809..1b91c631f1f 100644 --- a/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.173 +++ b/plugins/uast-kotlin/src/org/jetbrains/uast/kotlin/expressions/KotlinUObjectLiteralExpression.kt.173 @@ -28,52 +28,52 @@ import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry import org.jetbrains.uast.* class KotlinUObjectLiteralExpression( - override val psi: KtObjectLiteralExpression, - givenParent: UElement? + override val psi: KtObjectLiteralExpression, + givenParent: UElement? ) : KotlinAbstractUExpression(givenParent), UObjectLiteralExpression, KotlinUElementWithType { override val declaration: UClass by lz { val lightClass: KtLightClass? = psi.objectDeclaration.toLightClass() if (lightClass != null) { getLanguagePlugin().convert(lightClass, this) - } - else { + } else { logger.error( - "Failed to create light class for object declaration", - Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text)) + "Failed to create light class for object declaration", + Attachment(psi.containingFile.virtualFile?.path ?: "", psi.containingFile.text) + ) getLanguagePlugin().convert(LightPsiClassBuilder(psi, ""), this) } } - + override fun getExpressionType() = psi.objectDeclaration.toPsiType() private val superClassConstructorCall by lz { psi.objectDeclaration.superTypeListEntries.firstOrNull { it is KtSuperTypeCallEntry } as? KtSuperTypeCallEntry } - + override val classReference: UReferenceExpression? by lz { superClassConstructorCall?.let { ObjectLiteralClassReference(it, this) } } - + override val valueArgumentCount: Int get() = superClassConstructorCall?.valueArguments?.size ?: 0 override val valueArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } + psi.valueArguments.map { KotlinConverter.convertOrEmpty(it.getArgumentExpression(), this) } } - + override val typeArgumentCount: Int get() = superClassConstructorCall?.typeArguments?.size ?: 0 override val typeArguments by lz { val psi = superClassConstructorCall ?: return@lz emptyList() - psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } + psi.typeArguments.map { it.typeReference.toPsiType(this, boxed = true) } } override fun resolve() = superClassConstructorCall?.resolveCallToDeclaration(this) as? PsiMethod - + private class ObjectLiteralClassReference( - override val psi: KtSuperTypeCallEntry, - givenParent: UElement? + override val psi: KtSuperTypeCallEntry, + givenParent: UElement? ) : KotlinAbstractUElement(givenParent), USimpleNameReferenceExpression { override val javaPsi = null @@ -86,7 +86,7 @@ class KotlinUObjectLiteralExpression( override val resolvedName: String? get() = identifier - + override val identifier: String get() = psi.name ?: "" }