From 5a6cf19c68bf676a872c1f92cb1ed962b30225ed Mon Sep 17 00:00:00 2001 From: Toshiaki Kameyama Date: Wed, 29 May 2019 10:40:14 +0200 Subject: [PATCH] Complete statement for class declaration: add '()' to supertype #KT-31668 Fixed --- .../editor/fixers/KotlinClassBodyFixer.kt | 17 +++++- .../codeInsight/smartEnter/SmartEnterTest.kt | 60 +++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) diff --git a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinClassBodyFixer.kt b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinClassBodyFixer.kt index 5b56dec68c6..2c462ce2777 100644 --- a/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinClassBodyFixer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/editor/fixers/KotlinClassBodyFixer.kt @@ -19,8 +19,12 @@ package org.jetbrains.kotlin.idea.editor.fixers import com.intellij.lang.SmartEnterProcessorWithFixers import com.intellij.openapi.editor.Editor import com.intellij.psi.PsiElement +import org.jetbrains.kotlin.idea.caches.resolve.allowResolveInDispatchThread import org.jetbrains.kotlin.idea.editor.KotlinSmartEnterHandler +import org.jetbrains.kotlin.idea.references.mainReference +import org.jetbrains.kotlin.psi.KtClass import org.jetbrains.kotlin.psi.KtClassOrObject +import org.jetbrains.kotlin.psi.KtSuperTypeCallEntry import org.jetbrains.kotlin.psi.psiUtil.endOffset import org.jetbrains.kotlin.psi.psiUtil.getPrevSiblingIgnoringWhitespaceAndComments @@ -28,7 +32,7 @@ class KotlinClassBodyFixer : SmartEnterProcessorWithFixers.Fixer + """ + , + """ + open class A + class B : A() { + + } + """ + ) + + fun testClassBodyHasNotInitializedSuperType() = doFileTest( + """ + open class A + class B : A + """ + , + """ + open class A + class B : A() { + + } + """ + ) + + fun testClassBodyHasNotInitializedSuperType2() = doFileTest( + """ + sealed class A(val s: String) + class B : A + """ + , + """ + sealed class A(val s: String) + class B : A() { + + } + """ + ) + + fun testClassBodyHasNotInitializedSuperType3() = doFileTest( + """ + interface I + interface J + abstract class A + class B : I, A, J + """ + , + """ + interface I + interface J + abstract class A + class B : I, A(), J { + + } + """ + ) + fun testEmptyLine() = doFileTest( """fun foo() {} """,