Refactoring: make "replace call with binary operator" an inspection

This commit is contained in:
Mikhail Glukhikh
2017-12-20 16:02:15 +03:00
parent 6d4b5bc48f
commit ada7287c66
69 changed files with 320 additions and 321 deletions
@@ -0,0 +1,4 @@
<html><body>
This inspection reports function calls that can be replaced with binary operators, especially comparison-related.
Example: <code>2.compareTo(1) > 0</code> can be replaced by <code>2 > 1</code>.
</body></html>
@@ -1,4 +0,0 @@
<html><body>
This inspection reports equals() and compareTo() calls that can be replaced with binary comparison.
Example: <code>2.compareTo(1) > 0</code> can be replaced by <code>2 > 1</code>.
</body></html>
@@ -1,6 +0,0 @@
a + b
a - b
a * b
a / b
a % b
a .. b
@@ -1,6 +0,0 @@
a.plus(b)
a.minus(b)
a.times(b)
a.div(b)
a.mod(b)
a.rangeTo(b)
@@ -1,6 +0,0 @@
<html>
<body>
This intention replaces any calls to infix operators
(<code>plus</code>, <code>minus</code>, <code>div</code>, <code>times</code>, <code>mod</code>, <code>rangeTo</code>) with their respective infixes.
</body>
</html>
+2 -7
View File
@@ -827,11 +827,6 @@
<category>Kotlin</category>
</intentionAction>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithBinaryOperatorIntention</className>
<category>Kotlin</category>
</intentionAction>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention</className>
<category>Kotlin</category>
@@ -2005,8 +2000,8 @@
language="kotlin"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithComparisonInspection"
displayName="Can be replaced with comparison"
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceCallWithBinaryOperatorInspection"
displayName="Can be replaced with binary operator"
groupPath="Kotlin"
groupName="Style issues"
enabledByDefault="true"
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2017 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.
@@ -14,43 +14,39 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.intentions.conventionNameCalls
package org.jetbrains.kotlin.idea.inspections.conventionNameCalls
import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.codeInspection.LocalInspectionToolSession
import com.intellij.codeInspection.ProblemHighlightType
import com.intellij.codeInspection.ProblemsHolder
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.TextRange
import com.intellij.openapi.project.Project
import com.intellij.psi.PsiElement
import com.intellij.psi.tree.IElementType
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
import org.jetbrains.kotlin.idea.inspections.AbstractApplicabilityBasedInspection
import org.jetbrains.kotlin.idea.intentions.callExpression
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.isAnyEquals
import org.jetbrains.kotlin.idea.intentions.isReceiverExpressionWithValue
import org.jetbrains.kotlin.idea.intentions.toResolvedCall
import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getLastParentOfTypeInRow
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
import org.jetbrains.kotlin.resolve.findOriginalTopMostOverriddenDescriptors
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.expressions.OperatorConventions
import org.jetbrains.kotlin.util.OperatorNameConventions
class ReplaceCallWithComparisonInspection : IntentionBasedInspection<KtDotQualifiedExpression>(
ReplaceCallWithBinaryOperatorIntention::class,
{ qualifiedExpression ->
val calleeExpression = qualifiedExpression.callExpression?.calleeExpression as? KtSimpleNameExpression
val identifier = calleeExpression?.getReferencedNameAsName()
identifier == OperatorNameConventions.EQUALS || identifier == OperatorNameConventions.COMPARE_TO
}
)
class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention<KtDotQualifiedExpression>(
KtDotQualifiedExpression::class.java,
"Replace call with binary operator"
), HighPriorityAction {
class ReplaceCallWithBinaryOperatorInspection : AbstractApplicabilityBasedInspection<KtDotQualifiedExpression>() {
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): KtVisitorVoid =
object : KtVisitorVoid() {
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
super.visitDotQualifiedExpression(expression)
visitTargetElement(expression, holder, isOnTheFly)
}
}
private fun IElementType.inverted(): KtSingleValueToken? = when (this) {
KtTokens.LT -> KtTokens.GT
@@ -62,46 +58,67 @@ class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention<KtDot
else -> null
}
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression ?: return null
val operation = operation(calleeExpression) ?: return null
override fun isApplicable(element: KtDotQualifiedExpression): Boolean {
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression ?: return false
val operation = operation(calleeExpression) ?: return false
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return null
if (!resolvedCall.isReallySuccess()) return null
if (resolvedCall.call.typeArgumentList != null) return null
val argument = resolvedCall.call.valueArguments.singleOrNull() ?: return null
if ((resolvedCall.getArgumentMapping(argument) as ArgumentMatch).valueParameter.index != 0) return null
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return false
if (!resolvedCall.isReallySuccess()) return false
if (resolvedCall.call.typeArgumentList != null) return false
val argument = resolvedCall.call.valueArguments.singleOrNull() ?: return false
if ((resolvedCall.getArgumentMapping(argument) as ArgumentMatch).valueParameter.index != 0) return false
if (!element.isReceiverExpressionWithValue()) return null
text = "Replace with '${operation.value}' operator"
return calleeExpression.textRange
return element.isReceiverExpressionWithValue()
}
override fun applyTo(element: KtDotQualifiedExpression, editor: Editor?) {
val callExpression = element.callExpression ?: return
override fun inspectionTarget(element: KtDotQualifiedExpression) = element.callExpression?.calleeExpression ?: element
override fun inspectionHighlightType(element: KtDotQualifiedExpression): ProblemHighlightType {
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression
val identifier = calleeExpression?.getReferencedNameAsName()
return if (identifier == OperatorNameConventions.EQUALS || identifier == OperatorNameConventions.COMPARE_TO) {
ProblemHighlightType.GENERIC_ERROR_OR_WARNING
}
else {
ProblemHighlightType.INFORMATION
}
}
override fun inspectionText(element: KtDotQualifiedExpression) = "Call replaceable with binary operator"
override val defaultFixText: String
get() = "Replace with binary operator"
override fun fixText(element: KtDotQualifiedExpression): String {
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression ?: return defaultFixText
val operation = operation(calleeExpression) ?: return defaultFixText
return "Replace with '${operation.value}' operator"
}
override fun applyTo(element: PsiElement, project: Project, editor: Editor?) {
val qualifiedExpression = element.getParentOfType<KtDotQualifiedExpression>(strict = false) ?: return
val callExpression = qualifiedExpression.callExpression ?: return
val operation = operation(callExpression.calleeExpression as? KtSimpleNameExpression ?: return) ?: return
val argument = callExpression.valueArguments.single().getArgumentExpression() ?: return
val receiver = element.receiverExpression
val receiver = qualifiedExpression.receiverExpression
val factory = KtPsiFactory(element)
val factory = KtPsiFactory(qualifiedExpression)
when (operation) {
KtTokens.EXCLEQ -> {
val prefixExpression = element.getWrappingPrefixExpressionIfAny() ?: return
val prefixExpression = qualifiedExpression.getWrappingPrefixExpressionIfAny() ?: return
val newExpression = factory.createExpressionByPattern("$0 != $1", receiver, argument)
prefixExpression.replace(newExpression)
}
in OperatorConventions.COMPARISON_OPERATIONS -> {
val binaryParent = element.parent as? KtBinaryExpression ?: return
val binaryParent = qualifiedExpression.parent as? KtBinaryExpression ?: return
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
binaryParent.replace(newExpression)
}
else -> {
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
element.replace(newExpression)
qualifiedExpression.replace(newExpression)
}
}
}
private fun PsiElement.getWrappingPrefixExpressionIfAny() =
@@ -4,31 +4,47 @@
<line>2</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
<description>Replace with '==' operator</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
<problem>
<file>test.kt</file>
<line>3</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
<description>Replace with '!=' operator</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
<problem>
<file>test.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
<description>Replace with '&gt;' operator</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
<problem>
<file>test.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
<description>Replace with '&lt;=' operator</description>
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
<problem>
<file>test.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
<problem>
<file>test.kt</file>
<line>9</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
<description>Call replaceable with binary operator</description>
</problem>
</problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithComparisonInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceCallWithBinaryOperatorInspection
@@ -5,6 +5,6 @@ fun foo() {
1.compareTo(1) == 0 // NO
2.compareTo(1) > 0 // YES
0 >= 1.compareTo(2) // YES
2.plus(2) // NO
2.times(2) // NO
2.plus(2) // YES (information)
2.times(2) // YES (information)
}
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceCallWithBinaryOperatorInspection
@@ -1,8 +1,8 @@
// INTENTION_TEXT: Replace with '/' operator
// FIX: Replace with '/' operator
fun test() {
class Test {
operator fun div(a: Int): Test = Test()
}
val test = Test()
test.div<caret>(1)
test.<caret>div(1)
}
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '/' operator
// FIX: Replace with '/' operator
fun test() {
class Test {
operator fun div(a: Int): Test = Test()
@@ -0,0 +1,3 @@
// FIX: Replace with '==' operator
val x = 2.<caret>equals(2)
@@ -0,0 +1,3 @@
// FIX: Replace with '==' operator
val x = 2 == 2
@@ -2,5 +2,5 @@ fun test() {
class Test()
operator fun Test.div(a: Int): Test = Test()
val test = Test()
test.div<caret>(1)
test.<caret>div(1)
}
@@ -0,0 +1,3 @@
// FIX: Replace with '>' operator
val x = 3.compare<caret>To(2) > 0
@@ -0,0 +1,3 @@
// FIX: Replace with '>' operator
val x = 3 > 2
@@ -0,0 +1,3 @@
// FIX: Replace with '<=' operator
val x = 0 >= 4.compare<caret>To(5)
@@ -0,0 +1,3 @@
// FIX: Replace with '<=' operator
val x = 4 <= 5
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '-' operator
// FIX: Replace with '-' operator
fun test() {
class Test {
operator fun minus(a: Int): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '-' operator
// FIX: Replace with '-' operator
fun test() {
class Test {
operator fun minus(a: Int): Test = Test()
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
fun test() {
class Test{
@@ -1,10 +1,9 @@
// INTENTION_TEXT: Replace with '%' operator
// IS_APPLICABLE: false
// PROBLEM: none
fun test() {
class Test {
operator fun mod(a: Int): Test = Test()
}
val test = Test()
test % 1
test.<caret>mod(1)
}
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
fun test() {
class Test {
@@ -0,0 +1,3 @@
// FIX: Replace with '!=' operator
val x = !2.eq<caret>uals(3)
@@ -0,0 +1,3 @@
// FIX: Replace with '!=' operator
val x = 2 != 3
@@ -0,0 +1,3 @@
// FIX: Replace with '!=' operator
val x = !(2.<caret>equals(3))
@@ -0,0 +1,3 @@
// FIX: Replace with '!=' operator
val x = 2 != 3
@@ -0,0 +1,3 @@
// FIX: Replace with '==' operator
val x = !(2.equ<caret>als(3) && 4.equals(5))
@@ -0,0 +1,3 @@
// FIX: Replace with '==' operator
val x = !(2 == 3 && 4.equals(5))
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '+' operator
// FIX: Replace with '+' operator
fun test() {
class Test {
operator fun plus(a: Int): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '+' operator
// FIX: Replace with '+' operator
fun test() {
class Test {
operator fun plus(a: Int): Test = Test()
@@ -1,8 +1,8 @@
// INTENTION_TEXT: Replace with '..' operator
// FIX: Replace with '..' operator
fun test() {
class Test {
operator fun rangeTo(a: Int): Test = Test()
}
val test = Test()
test.rangeTo<caret>(1)
test.range<caret>To(1)
}
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '..' operator
// FIX: Replace with '..' operator
fun test() {
class Test {
operator fun rangeTo(a: Int): Test = Test()
@@ -1,9 +1,9 @@
// INTENTION_TEXT: Replace with '%' operator
// FIX: Replace with '%' operator
fun test() {
class Test {
operator fun rem(a: Int): Test = Test()
}
val test = Test()
test.rem<caret>(1)
test.<caret>rem(1)
}
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '%' operator
// FIX: Replace with '%' operator
fun test() {
class Test {
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: Operator call corresponds to a dot-qualified call 'nullable?.compareTo(1).compareTo(0)' which is not allowed on a nullable receiver 'nullable?.compareTo(1)'.
val nullable: Int? = null
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
open class Base {
open operator fun plus(s: String) = ""
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '*' operator
// FIX: Replace with '*' operator
fun test() {
class Test {
operator fun times(a: Int): Test = Test()
@@ -1,4 +1,4 @@
// INTENTION_TEXT: Replace with '*' operator
// FIX: Replace with '*' operator
fun test() {
class Test {
operator fun times(a: Int): Test = Test()
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
fun test() {
class Test {
operator fun <T> div(a: Test): T? = a as? T
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
fun test() {
class Test{
@@ -1,4 +1,4 @@
// IS_APPLICABLE: false
// PROBLEM: none
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
fun test() {
class Test{
@@ -1 +0,0 @@
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithBinaryOperatorIntention
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '==' operator
val x = 2.equals<caret>(2)
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '==' operator
val x = 2 == 2
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '>' operator
val x = 3.compareTo<caret>(2) > 0
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '>' operator
val x = 3 > 2
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '<=' operator
val x = 0 >= 4.compareTo<caret>(5)
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '<=' operator
val x = 4 <= 5
@@ -1,10 +0,0 @@
// INTENTION_TEXT: Replace call with binary operator
// IS_APPLICABLE: false
fun test() {
class Test {
operator fun mod(a: Int): Test = Test()
}
val test = Test()
test.mod<caret>(1)
}
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '!=' operator
val x = !2.equals<caret>(3)
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '!=' operator
val x = 2 != 3
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '!=' operator
val x = !(2.equals<caret>(3))
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '!=' operator
val x = 2 != 3
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '==' operator
val x = !(2.equals<caret>(3) && 4.equals(5))
@@ -1,3 +0,0 @@
// INTENTION_TEXT: Replace with '==' operator
val x = !(2 == 3 && 4.equals(5))
@@ -905,6 +905,171 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/conventionNameCalls"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ReplaceCallWithBinaryOperator extends AbstractLocalInspectionTest {
public void testAllFilesPresentInReplaceCallWithBinaryOperator() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("divSanityTest.kt")
public void testDivSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/divSanityTest.kt");
doTest(fileName);
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/equals.kt");
doTest(fileName);
}
@TestMetadata("equalsCompareTo.kt")
public void testEqualsCompareTo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/equalsCompareTo.kt");
doTest(fileName);
}
@TestMetadata("equalsExtensionFunction.kt")
public void testEqualsExtensionFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/equalsExtensionFunction.kt");
doTest(fileName);
}
@TestMetadata("extensionFunction.kt")
public void testExtensionFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/extensionFunction.kt");
doTest(fileName);
}
@TestMetadata("functionLiteralArgument.kt")
public void testFunctionLiteralArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/functionLiteralArgument.kt");
doTest(fileName);
}
@TestMetadata("greater.kt")
public void testGreater() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/greater.kt");
doTest(fileName);
}
@TestMetadata("lessEquals.kt")
public void testLessEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/lessEquals.kt");
doTest(fileName);
}
@TestMetadata("minusSanityTest.kt")
public void testMinusSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/minusSanityTest.kt");
doTest(fileName);
}
@TestMetadata("missingDefaultArgument.kt")
public void testMissingDefaultArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/missingDefaultArgument.kt");
doTest(fileName);
}
@TestMetadata("modSanityTest.kt")
public void testModSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/modSanityTest.kt");
doTest(fileName);
}
@TestMetadata("multipleArguments.kt")
public void testMultipleArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/multipleArguments.kt");
doTest(fileName);
}
@TestMetadata("notEquals.kt")
public void testNotEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/notEquals.kt");
doTest(fileName);
}
@TestMetadata("notEqualsBrackets.kt")
public void testNotEqualsBrackets() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/notEqualsBrackets.kt");
doTest(fileName);
}
@TestMetadata("notEqualsBracketsComplex.kt")
public void testNotEqualsBracketsComplex() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/notEqualsBracketsComplex.kt");
doTest(fileName);
}
@TestMetadata("plusSanityTest.kt")
public void testPlusSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/plusSanityTest.kt");
doTest(fileName);
}
@TestMetadata("qualifier.kt")
public void testQualifier() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/qualifier.kt");
doTest(fileName);
}
@TestMetadata("rangeToSanityTest.kt")
public void testRangeToSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/rangeToSanityTest.kt");
doTest(fileName);
}
@TestMetadata("remSanityTest.kt")
public void testRemSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/remSanityTest.kt");
doTest(fileName);
}
@TestMetadata("safeCompareTo.kt")
public void testSafeCompareTo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/safeCompareTo.kt");
doTest(fileName);
}
@TestMetadata("super.kt")
public void testSuper() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/super.kt");
doTest(fileName);
}
@TestMetadata("timesSanityTest.kt")
public void testTimesSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/timesSanityTest.kt");
doTest(fileName);
}
@TestMetadata("typeArguments.kt")
public void testTypeArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/typeArguments.kt");
doTest(fileName);
}
@TestMetadata("unacceptableVararg1.kt")
public void testUnacceptableVararg1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/unacceptableVararg1.kt");
doTest(fileName);
}
@TestMetadata("unacceptableVararg2.kt")
public void testUnacceptableVararg2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/unacceptableVararg2.kt");
doTest(fileName);
}
@TestMetadata("validNamedArgument.kt")
public void testValidNamedArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/validNamedArgument.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -3086,171 +3086,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/conventionNameCalls"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ReplaceCallWithBinaryOperator extends AbstractIntentionTest {
public void testAllFilesPresentInReplaceCallWithBinaryOperator() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("divSanityTest.kt")
public void testDivSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/divSanityTest.kt");
doTest(fileName);
}
@TestMetadata("equals.kt")
public void testEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/equals.kt");
doTest(fileName);
}
@TestMetadata("equalsCompareTo.kt")
public void testEqualsCompareTo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/equalsCompareTo.kt");
doTest(fileName);
}
@TestMetadata("equalsExtensionFunction.kt")
public void testEqualsExtensionFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/equalsExtensionFunction.kt");
doTest(fileName);
}
@TestMetadata("extensionFunction.kt")
public void testExtensionFunction() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/extensionFunction.kt");
doTest(fileName);
}
@TestMetadata("functionLiteralArgument.kt")
public void testFunctionLiteralArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/functionLiteralArgument.kt");
doTest(fileName);
}
@TestMetadata("greater.kt")
public void testGreater() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/greater.kt");
doTest(fileName);
}
@TestMetadata("lessEquals.kt")
public void testLessEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/lessEquals.kt");
doTest(fileName);
}
@TestMetadata("minusSanityTest.kt")
public void testMinusSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/minusSanityTest.kt");
doTest(fileName);
}
@TestMetadata("missingDefaultArgument.kt")
public void testMissingDefaultArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/missingDefaultArgument.kt");
doTest(fileName);
}
@TestMetadata("modSanityTest.kt")
public void testModSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/modSanityTest.kt");
doTest(fileName);
}
@TestMetadata("multipleArguments.kt")
public void testMultipleArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/multipleArguments.kt");
doTest(fileName);
}
@TestMetadata("notEquals.kt")
public void testNotEquals() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/notEquals.kt");
doTest(fileName);
}
@TestMetadata("notEqualsBrackets.kt")
public void testNotEqualsBrackets() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/notEqualsBrackets.kt");
doTest(fileName);
}
@TestMetadata("notEqualsBracketsComplex.kt")
public void testNotEqualsBracketsComplex() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/notEqualsBracketsComplex.kt");
doTest(fileName);
}
@TestMetadata("plusSanityTest.kt")
public void testPlusSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/plusSanityTest.kt");
doTest(fileName);
}
@TestMetadata("qualifier.kt")
public void testQualifier() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/qualifier.kt");
doTest(fileName);
}
@TestMetadata("rangeToSanityTest.kt")
public void testRangeToSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/rangeToSanityTest.kt");
doTest(fileName);
}
@TestMetadata("remSanityTest.kt")
public void testRemSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/remSanityTest.kt");
doTest(fileName);
}
@TestMetadata("safeCompareTo.kt")
public void testSafeCompareTo() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/safeCompareTo.kt");
doTest(fileName);
}
@TestMetadata("super.kt")
public void testSuper() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/super.kt");
doTest(fileName);
}
@TestMetadata("timesSanityTest.kt")
public void testTimesSanityTest() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/timesSanityTest.kt");
doTest(fileName);
}
@TestMetadata("typeArguments.kt")
public void testTypeArguments() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/typeArguments.kt");
doTest(fileName);
}
@TestMetadata("unacceptableVararg1.kt")
public void testUnacceptableVararg1() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/unacceptableVararg1.kt");
doTest(fileName);
}
@TestMetadata("unacceptableVararg2.kt")
public void testUnacceptableVararg2() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/unacceptableVararg2.kt");
doTest(fileName);
}
@TestMetadata("validNamedArgument.kt")
public void testValidNamedArgument() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithBinaryOperator/validNamedArgument.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)