diff --git a/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/after.kt.template b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/after.kt.template
new file mode 100644
index 00000000000..43c42f1453b
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/after.kt.template
@@ -0,0 +1 @@
+class Foo
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/before.kt.template b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/before.kt.template
new file mode 100644
index 00000000000..2664d7fabcd
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/before.kt.template
@@ -0,0 +1 @@
+class Foo()
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/description.html b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/description.html
new file mode 100644
index 00000000000..b8b8a8c8448
--- /dev/null
+++ b/idea/resources/intentionDescriptions/RemoveEmptyPrimaryConstructorIntention/description.html
@@ -0,0 +1,5 @@
+
+
+This intention removes an empty primary constructor when it would be implicitly available anyway
+
+
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 8ea34abcb53..9f6b25e94a8 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -1415,6 +1415,11 @@
Kotlin
+
+ org.jetbrains.kotlin.idea.intentions.RemoveEmptyPrimaryConstructorIntention
+ Kotlin
+
+
+
+
diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt
new file mode 100644
index 00000000000..1a91a466e44
--- /dev/null
+++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveEmptyPrimaryConstructorIntention.kt
@@ -0,0 +1,42 @@
+/*
+ * 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.KtPrimaryConstructor
+import org.jetbrains.kotlin.psi.psiUtil.containingClass
+
+class RemoveEmptyPrimaryConstructorInspection : IntentionBasedInspection(RemoveEmptyPrimaryConstructorIntention::class), CleanupLocalInspectionTool {
+ override val problemHighlightType: ProblemHighlightType
+ get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL
+}
+
+class RemoveEmptyPrimaryConstructorIntention : SelfTargetingOffsetIndependentIntention(KtPrimaryConstructor::class.java, "Remove empty primary constructor") {
+
+ override fun applyTo(element: KtPrimaryConstructor, editor: Editor?) = element.delete()
+
+ override fun isApplicableTo(element: KtPrimaryConstructor) = when {
+ element.valueParameters.isNotEmpty() -> false
+ element.annotations.isNotEmpty() -> false
+ element.modifierList?.text?.isBlank() == false -> false
+ element.containingClass()?.getSecondaryConstructors()?.isNotEmpty() == true -> false
+ else -> true
+ }
+}
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/.intention b/idea/testData/intentions/removeEmptyPrimaryConstructor/.intention
new file mode 100644
index 00000000000..822b89828da
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/.intention
@@ -0,0 +1,2 @@
+org.jetbrains.kotlin.idea.intentions.RemoveEmptyPrimaryConstructorIntention
+
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/annotation.kt b/idea/testData/intentions/removeEmptyPrimaryConstructor/annotation.kt
new file mode 100644
index 00000000000..ee400781555
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/annotation.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+
+annotation class Ann
+
+class Foo @Ann constructor()
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt b/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt
new file mode 100644
index 00000000000..75cd4a99615
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt
@@ -0,0 +1 @@
+class Foo constructor()
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt.after b/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt.after
new file mode 100644
index 00000000000..40857176ec7
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt.after
@@ -0,0 +1 @@
+class Foo
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/modifier.kt b/idea/testData/intentions/removeEmptyPrimaryConstructor/modifier.kt
new file mode 100644
index 00000000000..7169c4d15ca
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/modifier.kt
@@ -0,0 +1,3 @@
+// IS_APPLICABLE: false
+
+class Foo private constructor()
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/secondary.kt b/idea/testData/intentions/removeEmptyPrimaryConstructor/secondary.kt
new file mode 100644
index 00000000000..6d5f561327b
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/secondary.kt
@@ -0,0 +1,5 @@
+// IS_APPLICABLE: false
+
+class Foo() {
+ constructor(a: Int): this()
+}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt b/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt
new file mode 100644
index 00000000000..48f690ca7c7
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt
@@ -0,0 +1 @@
+class Foo()
\ No newline at end of file
diff --git a/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt.after b/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt.after
new file mode 100644
index 00000000000..2689a664dcc
--- /dev/null
+++ b/idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt.after
@@ -0,0 +1 @@
+class Foo
\ 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 1684175a2e8..bf9cf902ebb 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
@@ -10804,6 +10804,45 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
+ @TestMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor")
+ @TestDataPath("$PROJECT_ROOT")
+ @RunWith(JUnit3RunnerWithInners.class)
+ public static class RemoveEmptyPrimaryConstructor extends AbstractIntentionTest {
+ public void testAllFilesPresentInRemoveEmptyPrimaryConstructor() throws Exception {
+ KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/removeEmptyPrimaryConstructor"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
+ }
+
+ @TestMetadata("annotation.kt")
+ public void testAnnotation() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor/annotation.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("keyword.kt")
+ public void testKeyword() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor/keyword.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("modifier.kt")
+ public void testModifier() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor/modifier.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("secondary.kt")
+ public void testSecondary() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor/secondary.kt");
+ doTest(fileName);
+ }
+
+ @TestMetadata("simple.kt")
+ public void testSimple() throws Exception {
+ String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeEmptyPrimaryConstructor/simple.kt");
+ doTest(fileName);
+ }
+ }
+
@TestMetadata("idea/testData/intentions/removeExplicitLambdaParameterTypes")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)