diff --git a/idea/resources/inspectionDescriptions/RemoveEmptyClassBody.html b/idea/resources/inspectionDescriptions/RemoveEmptyClassBody.html
new file mode 100644
index 00000000000..71e4de32489
--- /dev/null
+++ b/idea/resources/inspectionDescriptions/RemoveEmptyClassBody.html
@@ -0,0 +1,5 @@
+
+
+This inspection reports and offers to remove an empty class body
+
+
diff --git a/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/after.kt.template b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/after.kt.template
new file mode 100644
index 00000000000..43c42f1453b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/after.kt.template
@@ -0,0 +1 @@
+class Foo
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/before.kt.template b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/before.kt.template
new file mode 100644
index 00000000000..0bb94d67482
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/before.kt.template
@@ -0,0 +1,3 @@
+class Foo {
+
+}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/description.html b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/description.html
new file mode 100644
index 00000000000..79ecafb685d
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyClassBodyIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention removes an empty class body.
+
+
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 003bdbe99f0..fd99c671ab8 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -1390,6 +1390,11 @@
Kotlin
+
+ org.jetbrains.kotlin.idea.intentions.RemoveEmptyClassBodyIntention
+ Kotlin
+
+
+
+
diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt
new file mode 100644
index 00000000000..9d493f82fdb
--- /dev/null
+++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyClassBodyIntention.kt
@@ -0,0 +1,34 @@
+/*
+ * Copyright 2010-2016 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.jetbrains.kotlin.idea.intentions
+
+import com.intellij.codeInspection.CleanupLocalInspectionTool
+import com.intellij.codeInspection.ProblemHighlightType
+import com.intellij.openapi.editor.Editor
+import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
+import org.jetbrains.kotlin.psi.KtClassBody
+
+class RemoveEmptyClassBodyInspection : IntentionBasedInspection(RemoveEmptyClassBodyIntention::class), CleanupLocalInspectionTool {
+ override val problemHighlightType: ProblemHighlightType
+ get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL
+}
+
+class RemoveEmptyClassBodyIntention : SelfTargetingOffsetIndependentIntention(KtClassBody::class.java, "Remove empty class body") {
+ override fun applyTo(element: KtClassBody, editor: Editor?) = element.delete()
+
+ override fun isApplicableTo(element: KtClassBody) = element.text.replace("{", "").replace("}", "").isBlank()
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/.intention b/idea/testData/intentions/removeEmptyClassBody/.intention
new file mode 100644
index 00000000000..f70869c4cf6
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/.intention
@@ -0,0 +1 @@
+org.jetbrains.kotlin.idea.intentions.RemoveEmptyClassBodyIntention
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt b/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt
new file mode 100644
index 00000000000..5d775eb63c2
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt
@@ -0,0 +1,4 @@
+class Foo() {
+
+
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt.after b/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt.after
new file mode 100644
index 00000000000..5ff6c09c578
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyClass.kt.after
@@ -0,0 +1 @@
+class Foo()
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt b/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt
new file mode 100644
index 00000000000..a417287e8fa
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt
@@ -0,0 +1,4 @@
+data class Foo(val bar: Int) {
+
+
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt.after b/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt.after
new file mode 100644
index 00000000000..e59586b95f8
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt.after
@@ -0,0 +1 @@
+data class Foo(val bar: Int)
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt b/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt
new file mode 100644
index 00000000000..f13887ea96a
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt
@@ -0,0 +1,4 @@
+interface Foo {
+
+
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt.after b/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt.after
new file mode 100644
index 00000000000..1258184b652
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt.after
@@ -0,0 +1 @@
+interface Foo
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyClassBody/noneEmptyClass.kt b/idea/testData/intentions/removeEmptyClassBody/noneEmptyClass.kt
new file mode 100644
index 00000000000..8e8c85c90b3
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyClassBody/noneEmptyClass.kt
@@ -0,0 +1,6 @@
+// IS_APPLICABLE: false
+class Foo() {
+
+ // comment
+
+}
\ No newline at end of file
diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
index 34391b7a375..a09b6a18550 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
@@ -10251,6 +10251,39 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
+ @TestMetadata("idea/testData/intentions/removeEmptyClassBody")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class RemoveEmptyClassBody extends AbstractIntentionTest {
+ public void testAllFilesPresentInRemoveEmptyClassBody() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/removeEmptyClassBody"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
+ }
+
+ @TestMetadata("emptyClass.kt")
+ public void testEmptyClass() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyClassBody/emptyClass.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("emptyDataClass.kt")
+ public void testEmptyDataClass() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyClassBody/emptyDataClass.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("emptyInterface.kt")
+ public void testEmptyInterface() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyClassBody/emptyInterface.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("noneEmptyClass.kt")
+ public void testNoneEmptyClass() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyClassBody/noneEmptyClass.kt");
+ doTest(fileName);
+ }
+ }
+
@TestMetadata("idea/testData/intentions/removeEmptyParenthesesFromLambdaCall")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)