Convert IfThenToElvisIntention to inspection & decrease severity to INFO
#KT-16067 Fixed
This commit is contained in:
@@ -1738,7 +1738,7 @@
|
||||
language="kotlin"
|
||||
/>
|
||||
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection"
|
||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToElvisInspection"
|
||||
displayName="If-Then foldable to '?:'"
|
||||
groupPath="Kotlin"
|
||||
groupName="Style issues"
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
val result = maybeSomething ?: somethingElse
|
||||
@@ -1 +0,0 @@
|
||||
val result = if (maybeSomething != null) maybeSomething else somethingElse
|
||||
@@ -1,5 +0,0 @@
|
||||
<html>
|
||||
<body>
|
||||
This intention converts an <b>if</b> expression to an expression using an elvis operator (if applicable).
|
||||
</body>
|
||||
</html>
|
||||
+59
-52
@@ -1,79 +1,65 @@
|
||||
/*
|
||||
* 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.
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions
|
||||
package org.jetbrains.kotlin.idea.inspections.branchedTransformations
|
||||
|
||||
import com.intellij.codeInspection.ProblemHighlightType
|
||||
import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.util.TextRange
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.KtNodeTypes
|
||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
||||
import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToSafeAccessInspection
|
||||
import org.jetbrains.kotlin.idea.intentions.SelfTargetingOffsetIndependentIntention
|
||||
import org.jetbrains.kotlin.idea.inspections.AbstractApplicabilityBasedInspection
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.*
|
||||
import org.jetbrains.kotlin.idea.util.CommentSaver
|
||||
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.isUsedAsExpression
|
||||
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
|
||||
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
|
||||
import javax.swing.JComponent
|
||||
|
||||
class IfThenToElvisInspection : IntentionBasedInspection<KtIfExpression>(
|
||||
IfThenToElvisIntention::class,
|
||||
{ it -> it.isUsedAsExpression(it.analyze(BodyResolveMode.PARTIAL_WITH_CFA)) }
|
||||
) {
|
||||
override fun inspectionTarget(element: KtIfExpression) = element.ifKeyword
|
||||
class IfThenToElvisInspection(
|
||||
@JvmField var highlightStatement: Boolean = false
|
||||
) : AbstractApplicabilityBasedInspection<KtIfExpression>(KtIfExpression::class.java) {
|
||||
override fun inspectionText(element: KtIfExpression): String = "If-Then foldable to '?:'"
|
||||
|
||||
override fun problemHighlightType(element: KtIfExpression): ProblemHighlightType =
|
||||
if (element.shouldBeTransformed()) super.problemHighlightType(element) else ProblemHighlightType.INFORMATION
|
||||
}
|
||||
override val defaultFixText: String = INTENTION_TEXT
|
||||
|
||||
class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention<KtIfExpression>(KtIfExpression::class.java, intentionText) {
|
||||
override fun isApplicable(element: KtIfExpression): Boolean = isApplicableTo(element, expressionShouldBeStable = true)
|
||||
|
||||
override fun isApplicableTo(element: KtIfExpression): Boolean = isApplicableTo(element, expressionShouldBeStable = true)
|
||||
override fun inspectionHighlightType(element: KtIfExpression): ProblemHighlightType =
|
||||
if (element.shouldBeTransformed() && (highlightStatement || element.isUsedAsExpression(element.analyze(BodyResolveMode.PARTIAL_WITH_CFA))))
|
||||
super.inspectionHighlightType(element)
|
||||
else
|
||||
ProblemHighlightType.INFORMATION
|
||||
|
||||
override fun startInWriteAction() = false
|
||||
override fun applyTo(element: PsiElement, project: Project, editor: Editor?) {
|
||||
convert(
|
||||
element as KtIfExpression,
|
||||
editor
|
||||
)
|
||||
}
|
||||
|
||||
override fun applyTo(element: KtIfExpression, editor: Editor?) = convert(element, editor)
|
||||
override fun inspectionRange(element: KtIfExpression): TextRange? = TextRange(
|
||||
element.ifKeyword.startOffset,
|
||||
element.condition?.endOffset ?: element.ifKeyword.endOffset
|
||||
).shiftLeft(element.startOffset)
|
||||
|
||||
override fun createOptionsPanel(): JComponent? = MultipleCheckboxOptionsPanel(this).also {
|
||||
it.addCheckbox("Report also on statement", "highlightStatement")
|
||||
}
|
||||
|
||||
companion object {
|
||||
private fun KtExpression.isNullOrBlockExpression(): Boolean {
|
||||
val innerExpression = this.unwrapBlockOrParenthesis()
|
||||
return innerExpression is KtBlockExpression || innerExpression.node.elementType == KtNodeTypes.NULL
|
||||
}
|
||||
|
||||
private fun IfThenToSelectData.clausesReplaceableByElvis(): Boolean =
|
||||
when {
|
||||
baseClause == null || negatedClause == null || negatedClause.isNullOrBlockExpression() ->
|
||||
false
|
||||
negatedClause is KtThrowExpression && negatedClause.throwsNullPointerExceptionWithNoArguments() ->
|
||||
false
|
||||
baseClause.evaluatesTo(receiverExpression) ->
|
||||
true
|
||||
baseClause.anyArgumentEvaluatesTo(receiverExpression) ->
|
||||
true
|
||||
hasImplicitReceiverReplaceableBySafeCall() || baseClause.hasFirstReceiverOf(receiverExpression) ->
|
||||
!baseClause.hasNullableType(context)
|
||||
else ->
|
||||
false
|
||||
}
|
||||
|
||||
val intentionText = "Replace 'if' expression with elvis expression"
|
||||
const val INTENTION_TEXT = "Replace 'if' expression with elvis expression"
|
||||
|
||||
fun convert(element: KtIfExpression, editor: Editor?) {
|
||||
val ifThenToSelectData = element.buildSelectTransformationData() ?: return
|
||||
@@ -114,5 +100,26 @@ class IfThenToElvisIntention : SelfTargetingOffsetIndependentIntention<KtIfExpre
|
||||
|
||||
return ifThenToSelectData.clausesReplaceableByElvis()
|
||||
}
|
||||
|
||||
private fun KtExpression.isNullOrBlockExpression(): Boolean {
|
||||
val innerExpression = this.unwrapBlockOrParenthesis()
|
||||
return innerExpression is KtBlockExpression || innerExpression.node.elementType == KtNodeTypes.NULL
|
||||
}
|
||||
|
||||
private fun IfThenToSelectData.clausesReplaceableByElvis(): Boolean =
|
||||
when {
|
||||
baseClause == null || negatedClause == null || negatedClause.isNullOrBlockExpression() ->
|
||||
false
|
||||
negatedClause is KtThrowExpression && negatedClause.throwsNullPointerExceptionWithNoArguments() ->
|
||||
false
|
||||
baseClause.evaluatesTo(receiverExpression) ->
|
||||
true
|
||||
baseClause.anyArgumentEvaluatesTo(receiverExpression) ->
|
||||
true
|
||||
hasImplicitReceiverReplaceableBySafeCall() || baseClause.hasFirstReceiverOf(receiverExpression) ->
|
||||
!baseClause.hasNullableType(context)
|
||||
else ->
|
||||
false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -27,12 +27,12 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze
|
||||
import org.jetbrains.kotlin.idea.core.replaced
|
||||
import org.jetbrains.kotlin.idea.core.setVisibility
|
||||
import org.jetbrains.kotlin.idea.inspections.*
|
||||
import org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToElvisInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToSafeAccessInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceGetOrSetInspection
|
||||
import org.jetbrains.kotlin.idea.intentions.*
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isTrivialStatementBody
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
|
||||
import org.jetbrains.kotlin.idea.quickfix.RemoveUselessCastFix
|
||||
@@ -96,7 +96,7 @@ object J2KPostProcessingRegistrarImpl : J2KPostProcessingRegistrar {
|
||||
}
|
||||
|
||||
registerInspectionBasedProcessing(IfThenToSafeAccessInspection())
|
||||
registerIntentionBasedProcessing(IfThenToElvisIntention())
|
||||
registerInspectionBasedProcessing(IfThenToElvisInspection(true))
|
||||
registerInspectionBasedProcessing(SimplifyNegatedBinaryExpressionInspection())
|
||||
registerInspectionBasedProcessing(ReplaceGetOrSetInspection())
|
||||
registerInspectionBasedProcessing(AddOperatorModifierInspection())
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -9,8 +9,8 @@ import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.editor.Editor
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToElvisInspection
|
||||
import org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToSafeAccessInspection
|
||||
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
|
||||
import org.jetbrains.kotlin.psi.KtContainerNodeForControlStructureBody
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtIfExpression
|
||||
@@ -32,9 +32,9 @@ object SmartCastImpossibleInIfThenFactory : KotlinIntentionActionsFactory() {
|
||||
),
|
||||
createQuickFix(
|
||||
ifExpression,
|
||||
{ IfThenToElvisIntention.intentionText },
|
||||
{ IfThenToElvisIntention.isApplicableTo(it, expressionShouldBeStable = false) },
|
||||
{ ifExpr, _, editor -> IfThenToElvisIntention.convert(ifExpr, editor) }
|
||||
{ IfThenToElvisInspection.INTENTION_TEXT },
|
||||
{ IfThenToElvisInspection.isApplicableTo(it, expressionShouldBeStable = false) },
|
||||
{ ifExpr, _, editor -> IfThenToElvisInspection.convert(ifExpr, editor) }
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToElvisInspection
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
val a = "a"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (null == <caret>null) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
operator fun <T> T.compareTo(a: T): Int = 0
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
// 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'.
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
val bar = "foo"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = null
|
||||
if (foo != null<caret>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val bar = "bar"
|
||||
+101
@@ -0,0 +1,101 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>ifAsPartOfExpression.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>ifAsPartOfExpression</package>
|
||||
<entry_point TYPE="method" FQNAME="ifAsPartOfExpression.IfAsPartOfExpressionKt void main(java.lang.String[] args)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>comparisonInElse.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>comparisonInElse</package>
|
||||
<entry_point TYPE="method" FQNAME="comparisonInElse.ComparisonInElseKt boolean foo(comparisonInElse.Your your)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>willNotInlineClassProperty.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>willNotInlineClassProperty</package>
|
||||
<entry_point TYPE="field" FQNAME="willNotInlineClassProperty.F c" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>applicableForLocalStableVar.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>applicableForLocalStableVar</package>
|
||||
<entry_point TYPE="method" FQNAME="applicableForLocalStableVar.ApplicableForLocalStableVarKt java.lang.String test()" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelector.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>nullCheckWithSelector</package>
|
||||
<entry_point TYPE="method" FQNAME="nullCheckWithSelector.NullCheckWithSelectorKt int foo(nullCheckWithSelector.My arg)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelectorCall.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>nullCheckWithSelectorCall</package>
|
||||
<entry_point TYPE="field" FQNAME="nullCheckWithSelectorCall.NullCheckWithSelectorCallKt foo" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>implicitReceiver.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>implicitReceiver</package>
|
||||
<entry_point TYPE="method" FQNAME="implicitReceiver.ImplicitReceiverKt boolean foo(java.lang.String $self)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelectorCallChain.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>nullCheckWithSelectorCallChain</package>
|
||||
<entry_point TYPE="field" FQNAME="nullCheckWithSelectorCallChain.NullCheckWithSelectorCallChainKt foo" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>extensionFunctionInClass.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>extensionFunctionInClass</package>
|
||||
<entry_point TYPE="method" FQNAME="extensionFunctionInClass.ExtensionFunctionInClassKt int test(extensionFunctionInClass.Foo $self, extensionFunctionInClass.Foo foo)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>doesNotInlineVariableInMultiDeclaration.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>doesNotInlineVariableInMultiDeclaration</package>
|
||||
<entry_point TYPE="method" FQNAME="doesNotInlineVariableInMultiDeclaration.DoesNotInlineVariableInMultiDeclarationKt int f(doesNotInlineVariableInMultiDeclaration.IntPair pair)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ifAsExpression.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<package>ifAsExpression</package>
|
||||
<entry_point TYPE="method" FQNAME="ifAsExpression.IfAsExpressionKt void main(java.lang.String[] args)" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>If-Then foldable to '?:'</description>
|
||||
</problem>
|
||||
</problems>
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.branchedTransformations.IfThenToElvisInspection
|
||||
// WITH_RUNTIME
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
|
||||
fun foo(x: CharSequence?) {
|
||||
val y = if (x is String?) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
|
||||
interface A
|
||||
interface B
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val bar = "bar"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
val bar = "bar"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo = "foo"
|
||||
val bar = "bar"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
//IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
// WITH_RUNTIME
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun maybeFoo(): String? {
|
||||
return "foo"
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val t: String? = "abc"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
// WITH_RUNTIME
|
||||
fun main(args: Array<String>) {
|
||||
val t: String? = "abc"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo: String? = "foo"
|
||||
if (foo == null<caret>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
|
||||
class Something {
|
||||
fun nullable(): Int? = null
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
|
||||
fun foo(p: String?): String? {
|
||||
return <caret>if (p != null) p.bar() else "a"
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun <T> doSomething(a: T) {}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
fun main(args: Array<String>) {
|
||||
val foo = null
|
||||
if (foo == null<caret>) {
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
// IS_APPLICABLE: false
|
||||
// PROBLEM: none
|
||||
|
||||
open class Some {
|
||||
fun bar() {}
|
||||
@@ -1 +0,0 @@
|
||||
org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
|
||||
@@ -1,90 +0,0 @@
|
||||
<problems>
|
||||
<problem>
|
||||
<file>willNotInlineClassProperty.kt</file>
|
||||
<line>3</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/willNotInlineClassProperty.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ifAsExpression.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAsExpression.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>ifAsPartOfExpression.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/ifAsPartOfExpression.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>doesNotInlineVariableInMultiDeclaration.kt</file>
|
||||
<line>7</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/src/doesNotInlineVariableInMultiDeclaration.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'.</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelector.kt</file>
|
||||
<line>4</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="nullCheckWithSelector.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelectorCall.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="nullCheckWithSelectorCall.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>nullCheckWithSelectorCallChain.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="nullCheckWithSelectorCallChain.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>comparisonInElse.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/comparisonInElse.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>implicitReceiver.kt</file>
|
||||
<line>2</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/implicitReceiver.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>applicableForLocalStableVar.kt</file>
|
||||
<line>8</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/applicableForLocalStableVar.kt" />
|
||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
<problem>
|
||||
<file>extensionFunctionInClass.kt</file>
|
||||
<line>5</line>
|
||||
<module>light_idea_test_case</module>
|
||||
<entry_point TYPE="file" FQNAME="temp:///src/extensionFunctionInClass.kt" />
|
||||
<problem_class severity="INFO" attribute_key="INFO_ATTRIBUTES">If-Then foldable to '?:'</problem_class>
|
||||
<description>Replace 'if' expression with elvis expression</description>
|
||||
</problem>
|
||||
</problems>
|
||||
-2
@@ -1,2 +0,0 @@
|
||||
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection
|
||||
// WITH_RUNTIME
|
||||
+5
-5
@@ -31,11 +31,6 @@ public class InspectionTestGenerated extends AbstractInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/intentions"), Pattern.compile("^(inspections\\.test)$"), TargetBackend.ANY);
|
||||
}
|
||||
|
||||
@TestMetadata("branched/ifThenToElvis/inspectionData/inspections.test")
|
||||
public void testBranched_ifThenToElvis_inspectionData_Inspections_test() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test");
|
||||
}
|
||||
|
||||
@TestMetadata("convertToStringTemplate/inspectionData/inspections.test")
|
||||
public void testConvertToStringTemplate_inspectionData_Inspections_test() throws Exception {
|
||||
runTest("idea/testData/intentions/convertToStringTemplate/inspectionData/inspections.test");
|
||||
@@ -467,6 +462,11 @@ public class InspectionTestGenerated extends AbstractInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/inspectionsLocal"), Pattern.compile("^(inspections\\.test)$"), TargetBackend.ANY);
|
||||
}
|
||||
|
||||
@TestMetadata("branched/ifThenToElvis/inspectionData/inspections.test")
|
||||
public void testBranched_ifThenToElvis_inspectionData_Inspections_test() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/inspectionData/inspections.test");
|
||||
}
|
||||
|
||||
@TestMetadata("branched/ifThenToSafeAccess/inspectionData/inspections.test")
|
||||
public void testBranched_ifThenToSafeAccess_inspectionData_Inspections_test() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToSafeAccess/inspectionData/inspections.test");
|
||||
|
||||
+296
@@ -180,6 +180,302 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/branched"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/branched/ifThenToElvis")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class IfThenToElvis extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIfThenToElvis() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/branched/ifThenToElvis"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("applicableForLocalStableVar.kt")
|
||||
public void testApplicableForLocalStableVar() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/applicableForLocalStableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasMoreThanOneStatement.kt")
|
||||
public void testBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/blockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockUsesDifferentVar.kt")
|
||||
public void testBlockUsesDifferentVar() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/blockUsesDifferentVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonInElse.kt")
|
||||
public void testComparisonInElse() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/comparisonInElse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionComparesNullWithNull.kt")
|
||||
public void testConditionComparesNullWithNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/conditionComparesNullWithNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionInvalidBinaryExp.kt")
|
||||
public void testConditionInvalidBinaryExp() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/conditionInvalidBinaryExp.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionNotBinaryExpr.kt")
|
||||
public void testConditionNotBinaryExpr() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/conditionNotBinaryExpr.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotInlineVariableInMultiDeclaration.kt")
|
||||
public void testDoesNotInlineVariableInMultiDeclaration() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/doesNotInlineVariableInMultiDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueIfUsedMoreThanOnce.kt")
|
||||
public void testDoesNotinlineValueIfUsedMoreThanOnce() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/doesNotinlineValueIfUsedMoreThanOnce.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueOutsideOfScope.kt")
|
||||
public void testDoesNotinlineValueOutsideOfScope() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/doesNotinlineValueOutsideOfScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyCondition.kt")
|
||||
public void testEmptyCondition() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/emptyCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyElseBlock.kt")
|
||||
public void testEmptyElseBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/emptyElseBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyThenBlock.kt")
|
||||
public void testEmptyThenBlock() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/emptyThenBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionInClass.kt")
|
||||
public void testExtensionFunctionInClass() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/extensionFunctionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseBothInBlocks.kt")
|
||||
public void testIfAndElseBothInBlocks() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/ifAndElseBothInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseNotInBlocks.kt")
|
||||
public void testIfAndElseNotInBlocks() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/ifAndElseNotInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAsExpression.kt")
|
||||
public void testIfAsExpression() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/ifAsExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAsPartOfExpression.kt")
|
||||
public void testIfAsPartOfExpression() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/ifAsPartOfExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifToElvisSwallowComments.kt")
|
||||
public void testIfToElvisSwallowComments() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/ifToElvisSwallowComments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiver.kt")
|
||||
public void testImplicitReceiver() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/implicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheck.kt")
|
||||
public void testIsCheck() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/isCheck.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckForNullableType.kt")
|
||||
public void testIsCheckForNullableType() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/isCheckForNullableType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckForUnrelatedType.kt")
|
||||
public void testIsCheckForUnrelatedType() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/isCheckForUnrelatedType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckWithSelector.kt")
|
||||
public void testIsCheckWithSelector() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/isCheckWithSelector.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckWithSelectorChain.kt")
|
||||
public void testIsCheckWithSelectorChain() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/isCheckWithSelectorChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt19666.kt")
|
||||
public void testKt19666() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/kt19666.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsEqualsNull.kt")
|
||||
public void testLhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/lhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsNotEqualsNull.kt")
|
||||
public void testLhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/lhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingElseClause.kt")
|
||||
public void testMissingElseClause() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/missingElseClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingThenClause.kt")
|
||||
public void testMissingThenClause() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/missingThenClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noCondition.kt")
|
||||
public void testNoCondition() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/noCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noNullInCondition.kt")
|
||||
public void testNoNullInCondition() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/noNullInCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForFunction.kt")
|
||||
public void testNotApplicableForFunction() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/notApplicableForFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForLocalUnstableVar.kt")
|
||||
public void testNotApplicableForLocalUnstableVar() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/notApplicableForLocalUnstableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForSimpleKotlinNPE.kt")
|
||||
public void testNotApplicableForSimpleKotlinNPE() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/notApplicableForSimpleKotlinNPE.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForSimpleNPE.kt")
|
||||
public void testNotApplicableForSimpleNPE() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/notApplicableForSimpleNPE.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notIsCheck.kt")
|
||||
public void testNotIsCheck() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/notIsCheck.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullBranchAlsoNull.kt")
|
||||
public void testNullBranchAlsoNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullBranchAlsoNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelector.kt")
|
||||
public void testNullCheckWithSelector() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullCheckWithSelector.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelectorCall.kt")
|
||||
public void testNullCheckWithSelectorCall() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullCheckWithSelectorCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelectorCallChain.kt")
|
||||
public void testNullCheckWithSelectorCallChain() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullCheckWithSelectorCallChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableResultWithImplicitReceiver.kt")
|
||||
public void testNullableResultWithImplicitReceiver() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullableResultWithImplicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableThen.kt")
|
||||
public void testNullableThen() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/nullableThen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("otherBlockHasMoreThanOneStatement.kt")
|
||||
public void testOtherBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/otherBlockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLet.kt")
|
||||
public void testReplaceWithLet() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/replaceWithLet.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetAndRenameIt.kt")
|
||||
public void testReplaceWithLetAndRenameIt() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/replaceWithLetAndRenameIt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetInMember.kt")
|
||||
public void testReplaceWithLetInMember() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/replaceWithLetInMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetInMemberWithIs.kt")
|
||||
public void testReplaceWithLetInMemberWithIs() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/replaceWithLetInMemberWithIs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsEqualsNull.kt")
|
||||
public void testRhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/rhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsNotEqualsNull.kt")
|
||||
public void testRhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/rhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("thenAndElseBothNull.kt")
|
||||
public void testThenAndElseBothNull() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/thenAndElseBothNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwsNPEwithArgument.kt")
|
||||
public void testThrowsNPEwithArgument() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/throwsNPEwithArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unitResult.kt")
|
||||
public void testUnitResult() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/unitResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("willNotInlineClassProperty.kt")
|
||||
public void testWillNotInlineClassProperty() throws Exception {
|
||||
runTest("idea/testData/inspectionsLocal/branched/ifThenToElvis/willNotInlineClassProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/branched/ifThenToElvis/inspectionData")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class InspectionData extends AbstractLocalInspectionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInspectionData() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/branched/ifThenToElvis/inspectionData"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/inspectionsLocal/branched/ifThenToSafeAccess")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
-296
@@ -2289,302 +2289,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/branched/ifThenToElvis")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class IfThenToElvis extends AbstractIntentionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInIfThenToElvis() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/branched/ifThenToElvis"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
|
||||
@TestMetadata("applicableForLocalStableVar.kt")
|
||||
public void testApplicableForLocalStableVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/applicableForLocalStableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockHasMoreThanOneStatement.kt")
|
||||
public void testBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/blockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("blockUsesDifferentVar.kt")
|
||||
public void testBlockUsesDifferentVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/blockUsesDifferentVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("comparisonInElse.kt")
|
||||
public void testComparisonInElse() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/comparisonInElse.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionComparesNullWithNull.kt")
|
||||
public void testConditionComparesNullWithNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/conditionComparesNullWithNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionInvalidBinaryExp.kt")
|
||||
public void testConditionInvalidBinaryExp() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/conditionInvalidBinaryExp.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("conditionNotBinaryExpr.kt")
|
||||
public void testConditionNotBinaryExpr() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/conditionNotBinaryExpr.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotInlineVariableInMultiDeclaration.kt")
|
||||
public void testDoesNotInlineVariableInMultiDeclaration() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/doesNotInlineVariableInMultiDeclaration.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueIfUsedMoreThanOnce.kt")
|
||||
public void testDoesNotinlineValueIfUsedMoreThanOnce() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/doesNotinlineValueIfUsedMoreThanOnce.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("doesNotinlineValueOutsideOfScope.kt")
|
||||
public void testDoesNotinlineValueOutsideOfScope() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/doesNotinlineValueOutsideOfScope.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyCondition.kt")
|
||||
public void testEmptyCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/emptyCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyElseBlock.kt")
|
||||
public void testEmptyElseBlock() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/emptyElseBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("emptyThenBlock.kt")
|
||||
public void testEmptyThenBlock() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/emptyThenBlock.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("extensionFunctionInClass.kt")
|
||||
public void testExtensionFunctionInClass() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/extensionFunctionInClass.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseBothInBlocks.kt")
|
||||
public void testIfAndElseBothInBlocks() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/ifAndElseBothInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAndElseNotInBlocks.kt")
|
||||
public void testIfAndElseNotInBlocks() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/ifAndElseNotInBlocks.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAsExpression.kt")
|
||||
public void testIfAsExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/ifAsExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifAsPartOfExpression.kt")
|
||||
public void testIfAsPartOfExpression() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/ifAsPartOfExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("ifToElvisSwallowComments.kt")
|
||||
public void testIfToElvisSwallowComments() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/ifToElvisSwallowComments.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("implicitReceiver.kt")
|
||||
public void testImplicitReceiver() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/implicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheck.kt")
|
||||
public void testIsCheck() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/isCheck.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckForNullableType.kt")
|
||||
public void testIsCheckForNullableType() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/isCheckForNullableType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckForUnrelatedType.kt")
|
||||
public void testIsCheckForUnrelatedType() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/isCheckForUnrelatedType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckWithSelector.kt")
|
||||
public void testIsCheckWithSelector() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/isCheckWithSelector.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("isCheckWithSelectorChain.kt")
|
||||
public void testIsCheckWithSelectorChain() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/isCheckWithSelectorChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt19666.kt")
|
||||
public void testKt19666() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/kt19666.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsEqualsNull.kt")
|
||||
public void testLhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/lhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("lhsNotEqualsNull.kt")
|
||||
public void testLhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/lhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingElseClause.kt")
|
||||
public void testMissingElseClause() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/missingElseClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("missingThenClause.kt")
|
||||
public void testMissingThenClause() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/missingThenClause.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noCondition.kt")
|
||||
public void testNoCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/noCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("noNullInCondition.kt")
|
||||
public void testNoNullInCondition() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/noNullInCondition.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForFunction.kt")
|
||||
public void testNotApplicableForFunction() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/notApplicableForFunction.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForLocalUnstableVar.kt")
|
||||
public void testNotApplicableForLocalUnstableVar() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/notApplicableForLocalUnstableVar.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForSimpleKotlinNPE.kt")
|
||||
public void testNotApplicableForSimpleKotlinNPE() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/notApplicableForSimpleKotlinNPE.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notApplicableForSimpleNPE.kt")
|
||||
public void testNotApplicableForSimpleNPE() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/notApplicableForSimpleNPE.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("notIsCheck.kt")
|
||||
public void testNotIsCheck() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/notIsCheck.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullBranchAlsoNull.kt")
|
||||
public void testNullBranchAlsoNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullBranchAlsoNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelector.kt")
|
||||
public void testNullCheckWithSelector() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullCheckWithSelector.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelectorCall.kt")
|
||||
public void testNullCheckWithSelectorCall() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullCheckWithSelectorCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullCheckWithSelectorCallChain.kt")
|
||||
public void testNullCheckWithSelectorCallChain() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullCheckWithSelectorCallChain.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableResultWithImplicitReceiver.kt")
|
||||
public void testNullableResultWithImplicitReceiver() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullableResultWithImplicitReceiver.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("nullableThen.kt")
|
||||
public void testNullableThen() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/nullableThen.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("otherBlockHasMoreThanOneStatement.kt")
|
||||
public void testOtherBlockHasMoreThanOneStatement() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/otherBlockHasMoreThanOneStatement.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLet.kt")
|
||||
public void testReplaceWithLet() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/replaceWithLet.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetAndRenameIt.kt")
|
||||
public void testReplaceWithLetAndRenameIt() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/replaceWithLetAndRenameIt.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetInMember.kt")
|
||||
public void testReplaceWithLetInMember() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/replaceWithLetInMember.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("replaceWithLetInMemberWithIs.kt")
|
||||
public void testReplaceWithLetInMemberWithIs() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/replaceWithLetInMemberWithIs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsEqualsNull.kt")
|
||||
public void testRhsEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/rhsEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("rhsNotEqualsNull.kt")
|
||||
public void testRhsNotEqualsNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/rhsNotEqualsNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("thenAndElseBothNull.kt")
|
||||
public void testThenAndElseBothNull() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/thenAndElseBothNull.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("throwsNPEwithArgument.kt")
|
||||
public void testThrowsNPEwithArgument() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/throwsNPEwithArgument.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("unitResult.kt")
|
||||
public void testUnitResult() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/unitResult.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("willNotInlineClassProperty.kt")
|
||||
public void testWillNotInlineClassProperty() throws Exception {
|
||||
runTest("idea/testData/intentions/branched/ifThenToElvis/willNotInlineClassProperty.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/branched/ifThenToElvis/inspectionData")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
public static class InspectionData extends AbstractIntentionTest {
|
||||
private void runTest(String testDataFilePath) throws Exception {
|
||||
KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath);
|
||||
}
|
||||
|
||||
public void testAllFilesPresentInInspectionData() throws Exception {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/branched/ifThenToElvis/inspectionData"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@TestMetadata("idea/testData/intentions/branched/ifWhen")
|
||||
@TestDataPath("$PROJECT_ROOT")
|
||||
@RunWith(JUnit3RunnerWithInners.class)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user