Refactoring: make "replace call with binary operator" an inspection
This commit is contained in:
@@ -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>
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
a + b
|
|
||||||
a - b
|
|
||||||
a * b
|
|
||||||
a / b
|
|
||||||
a % b
|
|
||||||
a .. b
|
|
||||||
-6
@@ -1,6 +0,0 @@
|
|||||||
a.plus(b)
|
|
||||||
a.minus(b)
|
|
||||||
a.times(b)
|
|
||||||
a.div(b)
|
|
||||||
a.mod(b)
|
|
||||||
a.rangeTo(b)
|
|
||||||
-6
@@ -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>
|
|
||||||
@@ -827,11 +827,6 @@
|
|||||||
<category>Kotlin</category>
|
<category>Kotlin</category>
|
||||||
</intentionAction>
|
</intentionAction>
|
||||||
|
|
||||||
<intentionAction>
|
|
||||||
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithBinaryOperatorIntention</className>
|
|
||||||
<category>Kotlin</category>
|
|
||||||
</intentionAction>
|
|
||||||
|
|
||||||
<intentionAction>
|
<intentionAction>
|
||||||
<className>org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention</className>
|
<className>org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention</className>
|
||||||
<category>Kotlin</category>
|
<category>Kotlin</category>
|
||||||
@@ -2005,8 +2000,8 @@
|
|||||||
language="kotlin"
|
language="kotlin"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithComparisonInspection"
|
<localInspection implementationClass="org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceCallWithBinaryOperatorInspection"
|
||||||
displayName="Can be replaced with comparison"
|
displayName="Can be replaced with binary operator"
|
||||||
groupPath="Kotlin"
|
groupPath="Kotlin"
|
||||||
groupName="Style issues"
|
groupName="Style issues"
|
||||||
enabledByDefault="true"
|
enabledByDefault="true"
|
||||||
|
|||||||
+58
-41
@@ -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");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
@@ -14,43 +14,39 @@
|
|||||||
* limitations under the License.
|
* 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.editor.Editor
|
||||||
import com.intellij.openapi.util.TextRange
|
import com.intellij.openapi.project.Project
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
import com.intellij.psi.tree.IElementType
|
import com.intellij.psi.tree.IElementType
|
||||||
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
|
import org.jetbrains.kotlin.idea.inspections.AbstractApplicabilityBasedInspection
|
||||||
import org.jetbrains.kotlin.idea.intentions.SelfTargetingRangeIntention
|
|
||||||
import org.jetbrains.kotlin.idea.intentions.callExpression
|
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.isReceiverExpressionWithValue
|
||||||
import org.jetbrains.kotlin.idea.intentions.toResolvedCall
|
import org.jetbrains.kotlin.idea.intentions.toResolvedCall
|
||||||
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
import org.jetbrains.kotlin.lexer.KtSingleValueToken
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getLastParentOfTypeInRow
|
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.ArgumentMatch
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
|
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.resolve.lazy.BodyResolveMode
|
||||||
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
import org.jetbrains.kotlin.types.expressions.OperatorConventions
|
||||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||||
|
|
||||||
class ReplaceCallWithComparisonInspection : IntentionBasedInspection<KtDotQualifiedExpression>(
|
class ReplaceCallWithBinaryOperatorInspection : AbstractApplicabilityBasedInspection<KtDotQualifiedExpression>() {
|
||||||
ReplaceCallWithBinaryOperatorIntention::class,
|
override fun buildVisitor(holder: ProblemsHolder, isOnTheFly: Boolean, session: LocalInspectionToolSession): KtVisitorVoid =
|
||||||
{ qualifiedExpression ->
|
object : KtVisitorVoid() {
|
||||||
val calleeExpression = qualifiedExpression.callExpression?.calleeExpression as? KtSimpleNameExpression
|
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
|
||||||
val identifier = calleeExpression?.getReferencedNameAsName()
|
super.visitDotQualifiedExpression(expression)
|
||||||
identifier == OperatorNameConventions.EQUALS || identifier == OperatorNameConventions.COMPARE_TO
|
visitTargetElement(expression, holder, isOnTheFly)
|
||||||
}
|
}
|
||||||
)
|
}
|
||||||
|
|
||||||
class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention<KtDotQualifiedExpression>(
|
|
||||||
KtDotQualifiedExpression::class.java,
|
|
||||||
"Replace call with binary operator"
|
|
||||||
), HighPriorityAction {
|
|
||||||
|
|
||||||
private fun IElementType.inverted(): KtSingleValueToken? = when (this) {
|
private fun IElementType.inverted(): KtSingleValueToken? = when (this) {
|
||||||
KtTokens.LT -> KtTokens.GT
|
KtTokens.LT -> KtTokens.GT
|
||||||
@@ -62,46 +58,67 @@ class ReplaceCallWithBinaryOperatorIntention : SelfTargetingRangeIntention<KtDot
|
|||||||
else -> null
|
else -> null
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
|
override fun isApplicable(element: KtDotQualifiedExpression): Boolean {
|
||||||
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression ?: return null
|
val calleeExpression = element.callExpression?.calleeExpression as? KtSimpleNameExpression ?: return false
|
||||||
val operation = operation(calleeExpression) ?: return null
|
val operation = operation(calleeExpression) ?: return false
|
||||||
|
|
||||||
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return null
|
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return false
|
||||||
if (!resolvedCall.isReallySuccess()) return null
|
if (!resolvedCall.isReallySuccess()) return false
|
||||||
if (resolvedCall.call.typeArgumentList != null) return null
|
if (resolvedCall.call.typeArgumentList != null) return false
|
||||||
val argument = resolvedCall.call.valueArguments.singleOrNull() ?: return null
|
val argument = resolvedCall.call.valueArguments.singleOrNull() ?: return false
|
||||||
if ((resolvedCall.getArgumentMapping(argument) as ArgumentMatch).valueParameter.index != 0) return null
|
if ((resolvedCall.getArgumentMapping(argument) as ArgumentMatch).valueParameter.index != 0) return false
|
||||||
|
|
||||||
if (!element.isReceiverExpressionWithValue()) return null
|
return element.isReceiverExpressionWithValue()
|
||||||
|
|
||||||
text = "Replace with '${operation.value}' operator"
|
|
||||||
return calleeExpression.textRange
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun applyTo(element: KtDotQualifiedExpression, editor: Editor?) {
|
override fun inspectionTarget(element: KtDotQualifiedExpression) = element.callExpression?.calleeExpression ?: element
|
||||||
val callExpression = element.callExpression ?: return
|
|
||||||
|
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 operation = operation(callExpression.calleeExpression as? KtSimpleNameExpression ?: return) ?: return
|
||||||
val argument = callExpression.valueArguments.single().getArgumentExpression() ?: 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) {
|
when (operation) {
|
||||||
KtTokens.EXCLEQ -> {
|
KtTokens.EXCLEQ -> {
|
||||||
val prefixExpression = element.getWrappingPrefixExpressionIfAny() ?: return
|
val prefixExpression = qualifiedExpression.getWrappingPrefixExpressionIfAny() ?: return
|
||||||
val newExpression = factory.createExpressionByPattern("$0 != $1", receiver, argument)
|
val newExpression = factory.createExpressionByPattern("$0 != $1", receiver, argument)
|
||||||
prefixExpression.replace(newExpression)
|
prefixExpression.replace(newExpression)
|
||||||
}
|
}
|
||||||
in OperatorConventions.COMPARISON_OPERATIONS -> {
|
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)
|
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
|
||||||
binaryParent.replace(newExpression)
|
binaryParent.replace(newExpression)
|
||||||
}
|
}
|
||||||
else -> {
|
else -> {
|
||||||
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
|
val newExpression = factory.createExpressionByPattern("$0 ${operation.value} $1", receiver, argument)
|
||||||
element.replace(newExpression)
|
qualifiedExpression.replace(newExpression)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun PsiElement.getWrappingPrefixExpressionIfAny() =
|
private fun PsiElement.getWrappingPrefixExpressionIfAny() =
|
||||||
+24
-8
@@ -4,31 +4,47 @@
|
|||||||
<line>2</line>
|
<line>2</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
|
||||||
<description>Replace with '==' operator</description>
|
<description>Call replaceable with binary operator</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>3</line>
|
<line>3</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
|
||||||
<description>Replace with '!=' operator</description>
|
<description>Call replaceable with binary operator</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>6</line>
|
<line>6</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
|
||||||
<description>Replace with '>' operator</description>
|
<description>Call replaceable with binary operator</description>
|
||||||
</problem>
|
</problem>
|
||||||
<problem>
|
<problem>
|
||||||
<file>test.kt</file>
|
<file>test.kt</file>
|
||||||
<line>7</line>
|
<line>7</line>
|
||||||
<module>light_idea_test_case</module>
|
<module>light_idea_test_case</module>
|
||||||
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
<entry_point TYPE="file" FQNAME="temp:///src/test.kt" />
|
||||||
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with comparison</problem_class>
|
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Can be replaced with binary operator</problem_class>
|
||||||
<description>Replace with '<=' operator</description>
|
<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>
|
</problem>
|
||||||
</problems>
|
</problems>
|
||||||
+1
-1
@@ -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
|
1.compareTo(1) == 0 // NO
|
||||||
2.compareTo(1) > 0 // YES
|
2.compareTo(1) > 0 // YES
|
||||||
0 >= 1.compareTo(2) // YES
|
0 >= 1.compareTo(2) // YES
|
||||||
2.plus(2) // NO
|
2.plus(2) // YES (information)
|
||||||
2.times(2) // NO
|
2.times(2) // YES (information)
|
||||||
}
|
}
|
||||||
Vendored
+1
@@ -0,0 +1 @@
|
|||||||
|
org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceCallWithBinaryOperatorInspection
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
// INTENTION_TEXT: Replace with '/' operator
|
// FIX: Replace with '/' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun div(a: Int): Test = Test()
|
operator fun div(a: Int): Test = Test()
|
||||||
}
|
}
|
||||||
val test = Test()
|
val test = Test()
|
||||||
test.div<caret>(1)
|
test.<caret>div(1)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '/' operator
|
// FIX: Replace with '/' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun div(a: Int): Test = Test()
|
operator fun div(a: Int): Test = Test()
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '==' operator
|
||||||
|
|
||||||
|
val x = 2.<caret>equals(2)
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '==' operator
|
||||||
|
|
||||||
|
val x = 2 == 2
|
||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
|
|
||||||
val x = 2.compareTo<caret>(2) == 0
|
val x = 2.compareTo<caret>(2) == 0
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
|
|
||||||
class Foo
|
class Foo
|
||||||
|
|
||||||
+1
-1
@@ -2,5 +2,5 @@ fun test() {
|
|||||||
class Test()
|
class Test()
|
||||||
operator fun Test.div(a: Int): Test = Test()
|
operator fun Test.div(a: Int): Test = Test()
|
||||||
val test = Test()
|
val test = Test()
|
||||||
test.div<caret>(1)
|
test.<caret>div(1)
|
||||||
}
|
}
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '>' operator
|
||||||
|
|
||||||
|
val x = 3.compare<caret>To(2) > 0
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '>' operator
|
||||||
|
|
||||||
|
val x = 3 > 2
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '<=' operator
|
||||||
|
|
||||||
|
val x = 0 >= 4.compare<caret>To(5)
|
||||||
idea/testData/inspectionsLocal/conventionNameCalls/replaceCallWithBinaryOperator/lessEquals.kt.after
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '<=' operator
|
||||||
|
|
||||||
|
val x = 4 <= 5
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '-' operator
|
// FIX: Replace with '-' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun minus(a: Int): Test = Test()
|
operator fun minus(a: Int): Test = Test()
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '-' operator
|
// FIX: Replace with '-' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun minus(a: Int): Test = Test()
|
operator fun minus(a: Int): Test = Test()
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test{
|
class Test{
|
||||||
+2
-3
@@ -1,10 +1,9 @@
|
|||||||
// INTENTION_TEXT: Replace with '%' operator
|
// PROBLEM: none
|
||||||
// IS_APPLICABLE: false
|
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun mod(a: Int): Test = Test()
|
operator fun mod(a: Int): Test = Test()
|
||||||
}
|
}
|
||||||
val test = Test()
|
val test = Test()
|
||||||
test % 1
|
test.<caret>mod(1)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '!=' operator
|
||||||
|
|
||||||
|
val x = !2.eq<caret>uals(3)
|
||||||
Vendored
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '!=' operator
|
||||||
|
|
||||||
|
val x = 2 != 3
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '!=' operator
|
||||||
|
|
||||||
|
val x = !(2.<caret>equals(3))
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '!=' operator
|
||||||
|
|
||||||
|
val x = 2 != 3
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '==' operator
|
||||||
|
|
||||||
|
val x = !(2.equ<caret>als(3) && 4.equals(5))
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
// FIX: Replace with '==' operator
|
||||||
|
|
||||||
|
val x = !(2 == 3 && 4.equals(5))
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '+' operator
|
// FIX: Replace with '+' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun plus(a: Int): Test = Test()
|
operator fun plus(a: Int): Test = Test()
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '+' operator
|
// FIX: Replace with '+' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun plus(a: Int): Test = Test()
|
operator fun plus(a: Int): Test = Test()
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
// INTENTION_TEXT: Replace with '..' operator
|
// FIX: Replace with '..' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun rangeTo(a: Int): Test = Test()
|
operator fun rangeTo(a: Int): Test = Test()
|
||||||
}
|
}
|
||||||
val test = Test()
|
val test = Test()
|
||||||
test.rangeTo<caret>(1)
|
test.range<caret>To(1)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '..' operator
|
// FIX: Replace with '..' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun rangeTo(a: Int): Test = Test()
|
operator fun rangeTo(a: Int): Test = Test()
|
||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
// INTENTION_TEXT: Replace with '%' operator
|
// FIX: Replace with '%' operator
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun rem(a: Int): Test = Test()
|
operator fun rem(a: Int): Test = Test()
|
||||||
}
|
}
|
||||||
val test = Test()
|
val test = Test()
|
||||||
test.rem<caret>(1)
|
test.<caret>rem(1)
|
||||||
}
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '%' operator
|
// FIX: Replace with '%' operator
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
+1
-1
@@ -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)'.
|
// 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
|
val nullable: Int? = null
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
|
|
||||||
open class Base {
|
open class Base {
|
||||||
open operator fun plus(s: String) = ""
|
open operator fun plus(s: String) = ""
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '*' operator
|
// FIX: Replace with '*' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun times(a: Int): Test = Test()
|
operator fun times(a: Int): Test = Test()
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// INTENTION_TEXT: Replace with '*' operator
|
// FIX: Replace with '*' operator
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun times(a: Int): Test = Test()
|
operator fun times(a: Int): Test = Test()
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test {
|
class Test {
|
||||||
operator fun <T> div(a: Test): T? = a as? T
|
operator fun <T> div(a: Test): T? = a as? T
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test{
|
class Test{
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
// IS_APPLICABLE: false
|
// PROBLEM: none
|
||||||
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
// ERROR: 'operator' modifier is inapplicable on this function: must have a single value parameter
|
||||||
fun test() {
|
fun test() {
|
||||||
class Test{
|
class Test{
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceCallWithBinaryOperatorIntention
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '==' operator
|
|
||||||
|
|
||||||
val x = 2.equals<caret>(2)
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '==' operator
|
|
||||||
|
|
||||||
val x = 2 == 2
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '>' operator
|
|
||||||
|
|
||||||
val x = 3.compareTo<caret>(2) > 0
|
|
||||||
Vendored
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '>' operator
|
|
||||||
|
|
||||||
val x = 3 > 2
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '<=' operator
|
|
||||||
|
|
||||||
val x = 0 >= 4.compareTo<caret>(5)
|
|
||||||
Vendored
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '<=' operator
|
|
||||||
|
|
||||||
val x = 4 <= 5
|
|
||||||
Vendored
-10
@@ -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)
|
|
||||||
}
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '!=' operator
|
|
||||||
|
|
||||||
val x = !2.equals<caret>(3)
|
|
||||||
Vendored
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '!=' operator
|
|
||||||
|
|
||||||
val x = 2 != 3
|
|
||||||
Vendored
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '!=' operator
|
|
||||||
|
|
||||||
val x = !(2.equals<caret>(3))
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '!=' operator
|
|
||||||
|
|
||||||
val x = 2 != 3
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
// INTENTION_TEXT: Replace with '==' operator
|
|
||||||
|
|
||||||
val x = !(2.equals<caret>(3) && 4.equals(5))
|
|
||||||
-3
@@ -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);
|
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")
|
@TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@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);
|
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")
|
@TestMetadata("idea/testData/intentions/conventionNameCalls/replaceCallWithUnaryOperator")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user