diff --git a/idea/resources/inspectionDescriptions/RemoveUnnecessaryLateinit.html b/idea/resources/inspectionDescriptions/RemoveUnnecessaryLateinit.html
deleted file mode 100644
index 2d6647dd968..00000000000
--- a/idea/resources/inspectionDescriptions/RemoveUnnecessaryLateinit.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-This inspection detects lateinit that can be safely removed
-
-
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/after.kt.template b/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/after.kt.template
deleted file mode 100644
index 5b7cd1e2379..00000000000
--- a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/after.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-class My {
- var x: String
-
- init {
- x = "My"
- }
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/before.kt.template b/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/before.kt.template
deleted file mode 100644
index 7924d662dbf..00000000000
--- a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/before.kt.template
+++ /dev/null
@@ -1,7 +0,0 @@
-class My {
- lateinit var x: String
-
- init {
- x = "My"
- }
-}
\ No newline at end of file
diff --git a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/description.html b/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/description.html
deleted file mode 100644
index b01afecd641..00000000000
--- a/idea/resources/intentionDescriptions/RemoveUnnecessaryLateinitIntention/description.html
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-This intention removes unnecessary lateinit modifiers.
-
-
\ No newline at end of file
diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml
index 0c88e154913..0feb8f069ee 100644
--- a/idea/src/META-INF/plugin.xml
+++ b/idea/src/META-INF/plugin.xml
@@ -1314,11 +1314,6 @@
Kotlin
-
- org.jetbrains.kotlin.idea.intentions.RemoveUnnecessaryLateinitIntention
- Kotlin
-
-
org.jetbrains.kotlin.idea.intentions.RemoveSingleExpressionStringTemplateIntention
Kotlin
@@ -1736,14 +1731,6 @@
language="kotlin"
/>
-
-
(RemoveUnnecessaryLateinitIntention::class) {
- override val problemHighlightType = ProblemHighlightType.LIKE_UNUSED_SYMBOL
-
- override val problemText = "Unnecessary lateinit"
-}
-
-class RemoveUnnecessaryLateinitIntention : SelfTargetingRangeIntention(KtProperty::class.java, "Remove unnecessary lateinit") {
- override fun applicabilityRange(element: KtProperty): TextRange? {
- if (!element.hasModifier(KtTokens.LATEINIT_KEYWORD)) return null
- val ktClass = element.getStrictParentOfType() ?: return null
- if (ktClass.getAnonymousInitializers().any { hasAssignmentStatements(it.body, element) }) {
- return element.lateinitTextRange()
- }
- if (ktClass.hasPrimaryConstructor()) return null
- val secondaryConstructors = ktClass.getSecondaryConstructors()
-
- val secondaryConstructorsInfo = secondaryConstructors.map { secondaryConstructor ->
- val delegationCall = secondaryConstructor.getDelegationCall()
- val hasAssignmentStatements = hasAssignmentStatements(secondaryConstructor.bodyExpression, element)
- if (!hasAssignmentStatements && !delegationCall.isCallToThis) return null
- val resolvedCall = delegationCall.getResolvedCall(delegationCall.analyzeFully()) ?: return null
- val delegationCallIndex = secondaryConstructors.indexOfFirst {
- DescriptorToSourceUtils.descriptorToDeclaration(resolvedCall.resultingDescriptor) == it
- }
- SecondaryConstructorInfo(hasAssignmentStatements, delegationCallIndex)
- }
- return if (assignmentReachableFromAnySecondaryConstructor(secondaryConstructorsInfo)) element.lateinitTextRange()
- else null
- }
-
- private fun assignmentReachableFromAnySecondaryConstructor(constructorsInfo: List): Boolean {
- constructorsInfo.forEach {
- val visitedInfo = hashSetOf()
- var currentConstructor = it
- while (!currentConstructor.hasAssignmentStatement) {
- if (!visitedInfo.add(currentConstructor)) return false
- currentConstructor = constructorsInfo.getOrNull(currentConstructor.delegationCallIndex) ?: return false
- }
- }
- return true
- }
-
- private fun KtProperty.lateinitTextRange() = modifierList?.getModifier(KtTokens.LATEINIT_KEYWORD)?.range
-
- private fun hasAssignmentStatements(body: KtExpression?, property: KtProperty) =
- body?.children?.any {
- it is KtBinaryExpression &&
- it.operationToken === KtTokens.EQ &&
- it.left?.text == property.name
- } ?: false
-
- override fun applyTo(element: KtProperty, editor: Editor?) {
- element.removeModifier(KtTokens.LATEINIT_KEYWORD)
- }
-}
-
-private data class SecondaryConstructorInfo(val hasAssignmentStatement: Boolean, val delegationCallIndex: Int)
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/.intention b/idea/testData/intentions/removeUnnecessaryLateinit/.intention
deleted file mode 100644
index f6e91edcea8..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/.intention
+++ /dev/null
@@ -1 +0,0 @@
-org.jetbrains.kotlin.idea.intentions.RemoveUnnecessaryLateinitIntention
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt
deleted file mode 100644
index 8721d280e41..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- lateinit var bar: String
-
- constructor(baz: Int) {
- bar = ""
- }
-}
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt.after
deleted file mode 100644
index b731a7b979c..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt.after
+++ /dev/null
@@ -1,9 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- var bar: String
-
- constructor(baz: Int) {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithErroneousDelegation.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithErroneousDelegation.kt
deleted file mode 100644
index 3d660fe7e1e..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithErroneousDelegation.kt
+++ /dev/null
@@ -1,12 +0,0 @@
-// IS_APPLICABLE: false
-// ERROR: None of the following functions can be called with the arguments supplied:
public constructor Foo() defined in Foo
public constructor Foo(x: String, y: String) defined in Foo
-
-class Foo {
- lateinit var x: String
-
- constructor() {
- x = "Foo"
- }
-
- constructor(x: String, y: String): this(y.hashCode())
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt
deleted file mode 100644
index 3edcc6dea88..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- lateinit var bar: String
-
- init {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt.after
deleted file mode 100644
index 8e75eb92fce..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt.after
+++ /dev/null
@@ -1,9 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- var bar: String
-
- init {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt
deleted file mode 100644
index f8bc360ff75..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt
+++ /dev/null
@@ -1,13 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- lateinit var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(baz: Int) {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt.after
deleted file mode 100644
index a697dc99bc3..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt.after
+++ /dev/null
@@ -1,13 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(baz: Int) {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt
deleted file mode 100644
index 62551652dbb..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt
+++ /dev/null
@@ -1,15 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- lateinit var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(a: Int) : this() {
- }
-
- constructor(a: Int, b: Int) : this(a) {
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt.after
deleted file mode 100644
index 98f2d958c46..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt.after
+++ /dev/null
@@ -1,15 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(a: Int) : this() {
- }
-
- constructor(a: Int, b: Int) : this(a) {
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt
deleted file mode 100644
index 15de7563f5c..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- lateinit var bar: String
- var baz: Int
-
- init {
- baz = 1
- }
-
- init {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt.after
deleted file mode 100644
index b97dd3391e8..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt.after
+++ /dev/null
@@ -1,14 +0,0 @@
-// INTENTION_TEXT: Remove unnecessary lateinit
-
-class Foo {
- var bar: String
- var baz: Int
-
- init {
- baz = 1
- }
-
- init {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPlusAssign.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPlusAssign.kt
deleted file mode 100644
index 9f79369317c..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPlusAssign.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-// IS_APPLICABLE: false
-
-class Foo {
- lateinit var bar: String
-
- constructor(baz: Int) {
- bar += baz
- }
-}
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPrimaryConstructorAndConstructor.kt b/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPrimaryConstructorAndConstructor.kt
deleted file mode 100644
index 7fb92d4e2e9..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPrimaryConstructorAndConstructor.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-// IS_APPLICABLE: false
-
-class Foo() {
- lateinit var bar: String
-
- constructor(baz: Int) : this() {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/normalLateinit.kt b/idea/testData/intentions/removeUnnecessaryLateinit/normalLateinit.kt
deleted file mode 100644
index bb31f11ba94..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/normalLateinit.kt
+++ /dev/null
@@ -1,9 +0,0 @@
-// IS_APPLICABLE: false
-
-class Foo {
- lateinit var bar: String
-
- fun init() {
- bar = ""
- }
-}
\ No newline at end of file
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt b/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt
deleted file mode 100644
index fd8139b4dd3..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-// IS_APPLICABLE: true
-// ERROR: There's a cycle in the delegation calls chain
-
-class Foo {
- lateinit var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(a: Int) : this(a) {
- bar = "a"
- }
-}
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt.after b/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt.after
deleted file mode 100644
index bfc1aa5e888..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt.after
+++ /dev/null
@@ -1,14 +0,0 @@
-// IS_APPLICABLE: true
-// ERROR: There's a cycle in the delegation calls chain
-
-class Foo {
- var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(a: Int) : this(a) {
- bar = "a"
- }
-}
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateLoop.kt b/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateLoop.kt
deleted file mode 100644
index b2dc4b78cbc..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateLoop.kt
+++ /dev/null
@@ -1,21 +0,0 @@
-// IS_APPLICABLE: false
-// ERROR: There's a cycle in the delegation calls chain
-// ERROR: There's a cycle in the delegation calls chain
-// ERROR: There's a cycle in the delegation calls chain
-
-class Foo {
- lateinit var bar: String
-
- constructor() {
- bar = ""
- }
-
- constructor(a: Int) : this(a, 0, 0) {
- }
-
- constructor(a: Int, b: Int) : this(a) {
- }
-
- constructor(a: Int, b: Int, c: Int) : this(a, b) {
- }
-}
diff --git a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateSuper.kt b/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateSuper.kt
deleted file mode 100644
index bae359bf99d..00000000000
--- a/idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateSuper.kt
+++ /dev/null
@@ -1,14 +0,0 @@
-// IS_APPLICABLE: false
-
-open class Bar(val a: Int = 0)
-
-class Foo : Bar {
- lateinit var bar: String
-
- constructor() : super() {
- bar = ""
- }
-
- constructor(a: Int) : super(a) {
- }
-}
\ 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 9903ab564ff..70572bb0625 100644
--- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
+++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java
@@ -10292,87 +10292,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
- @TestMetadata("idea/testData/intentions/removeUnnecessaryLateinit")
- @TestDataPath("$PROJECT_ROOT")
- @RunWith(JUnit3RunnerWithInners.class)
- public static class RemoveUnnecessaryLateinit extends AbstractIntentionTest {
- public void testAllFilesPresentInRemoveUnnecessaryLateinit() throws Exception {
- KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/removeUnnecessaryLateinit"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
- }
-
- @TestMetadata("lateinitWithConstructor.kt")
- public void testLateinitWithConstructor() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithConstructor.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithErroneousDelegation.kt")
- public void testLateinitWithErroneousDelegation() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithErroneousDelegation.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithInit.kt")
- public void testLateinitWithInit() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithInit.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithMultipleConstructors.kt")
- public void testLateinitWithMultipleConstructors() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructors.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithMultipleConstructorsAndDelegation.kt")
- public void testLateinitWithMultipleConstructorsAndDelegation() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleConstructorsAndDelegation.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithMultipleInit.kt")
- public void testLateinitWithMultipleInit() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithMultipleInit.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithPlusAssign.kt")
- public void testLateinitWithPlusAssign() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPlusAssign.kt");
- doTest(fileName);
- }
-
- @TestMetadata("lateinitWithPrimaryConstructorAndConstructor.kt")
- public void testLateinitWithPrimaryConstructorAndConstructor() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/lateinitWithPrimaryConstructorAndConstructor.kt");
- doTest(fileName);
- }
-
- @TestMetadata("normalLateinit.kt")
- public void testNormalLateinit() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/normalLateinit.kt");
- doTest(fileName);
- }
-
- @TestMetadata("secondaryConstructorDelegateItself.kt")
- public void testSecondaryConstructorDelegateItself() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateItself.kt");
- doTest(fileName);
- }
-
- @TestMetadata("secondaryConstructorDelegateLoop.kt")
- public void testSecondaryConstructorDelegateLoop() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateLoop.kt");
- doTest(fileName);
- }
-
- @TestMetadata("secondaryConstructorDelegateSuper.kt")
- public void testSecondaryConstructorDelegateSuper() throws Exception {
- String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/removeUnnecessaryLateinit/secondaryConstructorDelegateSuper.kt");
- doTest(fileName);
- }
- }
-
@TestMetadata("idea/testData/intentions/removeUnnecessaryParentheses")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)