Remove IfThenToDoubleBangIntention
Relates to #KT-31502
This commit is contained in:
@@ -953,11 +953,6 @@
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToDoubleBangIntention</className>
|
||||
<category>Kotlin</category>
|
||||
</intentionAction>
|
||||
|
||||
<intentionAction>
|
||||
<className>org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.ElvisToIfThenIntention</className>
|
||||
<category>Kotlin</category>
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
foo(maybeSomething!!)
|
||||
@@ -1 +0,0 @@
|
||||
foo(if (maybeSomething != null) maybeSomething else throw KotlinNullPointerException())
|
||||
@@ -1,6 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts an <b>if-then</b> expression that checks if a value is null to an equivalent expression
|
||||
using the <b>!!</b> operator.
|
||||
</body>
|
||||
</html>
|
||||
-65
@@ -1,65 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 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.branchedTransformations.intentions
|
||||
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.*
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||
import org.jetbrains.kotlin.psi.psiUtil.startOffset
|
||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsStatement
|
||||
|
||||
class IfThenToDoubleBangIntention : SelfTargetingRangeIntention<KtIfExpression>(
|
||||
KtIfExpression::class.java, "Replace 'if' expression with '!!' expression"
|
||||
) {
|
||||
override fun applicabilityRange(element: KtIfExpression): TextRange? {
|
||||
val (context, condition, receiverExpression, baseClause, negatedClause) = element.buildSelectTransformationData() ?: return null
|
||||
// TODO: here "Replace with as" can be supported
|
||||
if (condition is KtIsExpression) return null
|
||||
|
||||
val throwExpression = negatedClause as? KtThrowExpression ?: return null
|
||||
|
||||
val matchesAsStatement = element.isUsedAsStatement(context) && (baseClause?.isNullExpressionOrEmptyBlock() ?: true)
|
||||
if (!matchesAsStatement &&
|
||||
!(baseClause?.evaluatesTo(receiverExpression) ?: false && receiverExpression.isStableSimpleExpression())) return null
|
||||
|
||||
var text = "Replace 'if' expression with '!!' expression"
|
||||
if (!throwExpression.throwsNullPointerExceptionWithNoArguments()) {
|
||||
text += " (will remove exception)"
|
||||
}
|
||||
|
||||
setText(text)
|
||||
val rParen = element.rightParenthesis ?: return null
|
||||
return TextRange(element.startOffset, rParen.endOffset)
|
||||
}
|
||||
|
||||
override fun startInWriteAction() = false
|
||||
|
||||
override fun applyTo(element: KtIfExpression, editor: Editor?) {
|
||||
val (_, _, receiverExpression) = element.buildSelectTransformationData() ?: return
|
||||
val result = runWriteAction {
|
||||
element.replace(KtPsiFactory(element).createExpressionByPattern("$0!!", receiverExpression)) as KtPostfixExpression
|
||||
}
|
||||
|
||||
if (editor != null) {
|
||||
result.inlineBaseExpressionIfApplicableWithPrompt(editor)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToDoubleBangIntention
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
Vendored
-9
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo != null<caret>) {
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
Vendored
-4
@@ -1,4 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (foo() == null<caret>) {
|
||||
throw KotlinNullPointerException()
|
||||
}
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()!!
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
"foo"!!
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
return foo
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun test(): String? {
|
||||
var foo = maybeFoo()
|
||||
val bar = foo!!
|
||||
return foo
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
|
||||
if (foo != null<caret>) {
|
||||
print ("Hello")
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
val a = "a"
|
||||
|
||||
if (foo != null<caret>) {
|
||||
a
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (null == <caret>null) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
|
||||
operator fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
if (foo > null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-17
@@ -1,17 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// ERROR: Type mismatch: inferred type is Int but Boolean was expected
|
||||
// ERROR: Type mismatch: inferred type is Int but Boolean was expected
|
||||
// ERROR: Operator call corresponds to a dot-qualified call 'foo.times(10)' which is not allowed on a nullable receiver 'foo'.
|
||||
|
||||
fun String?.times(a: Int): Boolean = a == 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo: Int? = 4
|
||||
if (foo * 10<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
Vendored
-15
@@ -1,15 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
print(foo)
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
print(foo)
|
||||
foo!!
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
val x = maybeFoo()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (x !=<caret> null) {
|
||||
x
|
||||
} else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
val x = maybeFoo()
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
x!!
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
if (<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
-14
@@ -1,14 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
val x = if (foo == null<caret>) {
|
||||
throw KotlinNullPointerException()
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val x = maybeFoo()!!
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (foo != null<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException("'foo' must not be null")
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>)
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if<caret> {
|
||||
foo
|
||||
} else throw NullPointerException()
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
val bar = "bar"
|
||||
if (foo == bar<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
//IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (maybeFoo() == null<caret>)
|
||||
maybeFoo()
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun capture(block: () -> Unit): Unit = Unit
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
var foo = maybeFoo()
|
||||
|
||||
capture {
|
||||
foo = null
|
||||
}
|
||||
|
||||
if (foo == null<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
foo
|
||||
}
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
|
||||
if (foo != null<caret>) {
|
||||
foo
|
||||
}
|
||||
else {
|
||||
print ("Hello")
|
||||
throw NullPointerException("'foo' must not be null")
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (null == foo<caret>)
|
||||
throw NullPointerException()
|
||||
else
|
||||
foo
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
val foo = maybeFoo()
|
||||
if (null != foo<caret>)
|
||||
foo
|
||||
else
|
||||
throw NullPointerException()
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
maybeFoo()!!
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
if (foo == null<caret>) {
|
||||
null
|
||||
}
|
||||
else {
|
||||
null
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun String?.foo() = if (this == <caret>null) throw NullPointerException() else this
|
||||
@@ -1,2 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
fun String?.foo() = this!!
|
||||
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
class NullPointerException : Exception()
|
||||
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
if (foo() == null<caret>) {
|
||||
throw java.lang.NullPointerException()
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
class NullPointerException : Exception()
|
||||
|
||||
fun foo(): Any? = "foo"
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo()!!
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// IS_APPLICABLE: false
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val y = if (foo == null<caret>) {
|
||||
throw NullPointerException()
|
||||
}
|
||||
else {
|
||||
}
|
||||
}
|
||||
Vendored
-10
@@ -1,10 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: FALSE
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val y = if (foo == null<caret>) {
|
||||
}
|
||||
else {
|
||||
throw NullPointerException()
|
||||
}
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
class F(a: Int?) {
|
||||
val b = a
|
||||
val c = if (b != <caret> null) b else throw NullPointerException()
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
F(1).c
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// WITH_RUNTIME
|
||||
class F(a: Int?) {
|
||||
val b = a
|
||||
val c = b!!
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
F(1).c
|
||||
}
|
||||
-193
@@ -2337,199 +2337,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/branched/ifThenToDoubleBang")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class IfThenToDoubleBang extends AbstractIntentionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
@TestMetadata("acceptableEmptyElseBlockForStatement.kt")
|
||||
public void testAcceptableEmptyElseBlockForStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/acceptableEmptyElseBlockForStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("acceptableEmptyThenBlockForStatement.kt")
|
||||
public void testAcceptableEmptyThenBlockForStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/acceptableEmptyThenBlockForStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("acceptableWithoutElseBlockForStatementWithFun.kt")
|
||||
public void testAcceptableWithoutElseBlockForStatementWithFun() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/acceptableWithoutElseBlockForStatementWithFun.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("acceptableWithoutElseBlockForStatementWithVal.kt")
|
||||
public void testAcceptableWithoutElseBlockForStatementWithVal() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/acceptableWithoutElseBlockForStatementWithVal.kt");
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIfThenToDoubleBang() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/branched/ifThenToDoubleBang"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("applicableForLocalStableVar.kt")
|
||||
public void testApplicableForLocalStableVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/applicableForLocalStableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasMoreThanOneStatement.kt")
|
||||
public void testBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/blockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockUsesDifferentVar.kt")
|
||||
public void testBlockUsesDifferentVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/blockUsesDifferentVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionComparesNullWithNull.kt")
|
||||
public void testConditionComparesNullWithNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/conditionComparesNullWithNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionInvalidBinaryExp.kt")
|
||||
public void testConditionInvalidBinaryExp() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/conditionInvalidBinaryExp.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionNotBinaryExpr.kt")
|
||||
public void testConditionNotBinaryExpr() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/conditionNotBinaryExpr.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueIfUsedMoreThanOnce.kt")
|
||||
public void testDoesNotinlineValueIfUsedMoreThanOnce() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/doesNotinlineValueIfUsedMoreThanOnce.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueOutsideOfScope.kt")
|
||||
public void testDoesNotinlineValueOutsideOfScope() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/doesNotinlineValueOutsideOfScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyCondition.kt")
|
||||
public void testEmptyCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/emptyCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyElseBlock.kt")
|
||||
public void testEmptyElseBlock() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/emptyElseBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyThenBlock.kt")
|
||||
public void testEmptyThenBlock() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/emptyThenBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseBothInBlocks.kt")
|
||||
public void testIfAndElseBothInBlocks() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/ifAndElseBothInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseNotInBlocks.kt")
|
||||
public void testIfAndElseNotInBlocks() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/ifAndElseNotInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAsExpression.kt")
|
||||
public void testIfAsExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/ifAsExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsEqualsNull.kt")
|
||||
public void testLhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/lhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsNotEqualsNull.kt")
|
||||
public void testLhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/lhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingElseClause.kt")
|
||||
public void testMissingElseClause() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/missingElseClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingThenClause.kt")
|
||||
public void testMissingThenClause() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/missingThenClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noCondition.kt")
|
||||
public void testNoCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/noCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noNullInCondition.kt")
|
||||
public void testNoNullInCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/noNullInCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForFunction.kt")
|
||||
public void testNotApplicableForFunction() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/notApplicableForFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForLocalUnstableVar.kt")
|
||||
public void testNotApplicableForLocalUnstableVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/notApplicableForLocalUnstableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullBranchAlsoNull.kt")
|
||||
public void testNullBranchAlsoNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/nullBranchAlsoNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("otherBlockHasMoreThanOneStatement.kt")
|
||||
public void testOtherBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/otherBlockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsEqualsNull.kt")
|
||||
public void testRhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/rhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsNotEqualsNull.kt")
|
||||
public void testRhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/rhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("thenAndElseBothNull.kt")
|
||||
public void testThenAndElseBothNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/thenAndElseBothNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("this.kt")
|
||||
public void testThis() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/this.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwByFqName.kt")
|
||||
public void testThrowByFqName() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/throwByFqName.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unacceptableEmptyElseBlockForExpression.kt")
|
||||
public void testUnacceptableEmptyElseBlockForExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/unacceptableEmptyElseBlockForExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unacceptableEmptyThenBlockForExpression.kt")
|
||||
public void testUnacceptableEmptyThenBlockForExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/unacceptableEmptyThenBlockForExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("willNotInlineClassProperty.kt")
|
||||
public void testWillNotInlineClassProperty() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToDoubleBang/willNotInlineClassProperty.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/branched/ifThenToElvis")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Reference in New Issue
Block a user