KT-9628 Intention&inspection to replace use of "set" operator function with []

#KT-9628 Fixed
This commit is contained in:
Valentin Kipyatkov
2015-10-20 16:01:04 +03:00
parent 852579e7f3
commit 66310806ca
51 changed files with 248 additions and 126 deletions
@@ -1,5 +0,0 @@
<html>
<body>
This inspection reports any explicit calls of 'get' which can be replaced by indexing operator []
</body>
</html>
@@ -0,0 +1,5 @@
<html>
<body>
This inspection reports any explicit calls of 'get' or 'set' functions which can be replaced by indexing operator []
</body>
</html>
@@ -1,5 +0,0 @@
<html>
<body>
This intention replaces <code>get</code> member calls with the array index operator (<code>[]</code>).
</body>
</html>
@@ -0,0 +1,5 @@
<html>
<body>
This intention replaces <code>get</code> or <code>set</code> function calls with the indexing operator (<code>[]</code>).
</body>
</html>
+3 -3
View File
@@ -653,7 +653,7 @@
</intentionAction>
<intentionAction>
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention</className>
<className>org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention</className>
<category>Kotlin</category>
</intentionAction>
@@ -1096,8 +1096,8 @@
level="INFO"
/>
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetInspection"
displayName="Explicit 'get'"
<localInspection implementationClass="org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetInspection"
displayName="Explicit 'get' or 'set' call"
groupName="Kotlin"
enabledByDefault="true"
level="INFO"
@@ -104,9 +104,9 @@ val KtQualifiedExpression.callExpression: KtCallExpression?
val KtQualifiedExpression.calleeName: String?
get() = (callExpression?.getCalleeExpression() as? KtNameReferenceExpression)?.getText()
fun KtQualifiedExpression.toResolvedCall(): ResolvedCall<out CallableDescriptor>? {
fun KtQualifiedExpression.toResolvedCall(bodyResolveMode: BodyResolveMode): ResolvedCall<out CallableDescriptor>? {
val callExpression = callExpression ?: return null
return callExpression.getResolvedCall(callExpression.analyze()) ?: return null
return callExpression.getResolvedCall(callExpression.analyze(bodyResolveMode)) ?: return null
}
fun KtExpression.isExitStatement(): Boolean {
@@ -26,13 +26,14 @@ import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.createExpressionByPattern
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.types.expressions.OperatorConventions
public class ReplaceCallWithBinaryOperatorIntention : JetSelfTargetingRangeIntention<KtDotQualifiedExpression>(javaClass(), "Replace call with binary operator"), HighPriorityAction {
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
val operation = operation(element.calleeName) ?: return null
val resolvedCall = element.toResolvedCall() ?: return null
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return null
if (!resolvedCall.isReallySuccess()) return null
if (resolvedCall.getCall().getTypeArgumentList() != null) return null
val argument = resolvedCall.getCall().getValueArguments().singleOrNull() ?: return null
@@ -25,13 +25,14 @@ import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.calls.model.ArgumentMatch
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
import org.jetbrains.kotlin.resolve.descriptorUtil.builtIns
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.util.OperatorNameConventions
public class ReplaceContainsIntention : JetSelfTargetingRangeIntention<KtDotQualifiedExpression>(javaClass(), "Replace 'contains' call with 'in' operator"), HighPriorityAction {
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
if (element.calleeName != OperatorNameConventions.CONTAINS.asString()) return null
val resolvedCall = element.toResolvedCall() ?: return null
val resolvedCall = element.toResolvedCall(BodyResolveMode.PARTIAL) ?: return null
if (!resolvedCall.isReallySuccess()) return null
val argument = resolvedCall.getCall().getValueArguments().singleOrNull() ?: return null
if ((resolvedCall.getArgumentMapping(argument) as ArgumentMatch).valueParameter.getIndex() != 0) return null
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.HighPriorityAction
import com.intellij.openapi.editor.Editor
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.descriptors.FunctionDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection
import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention
import org.jetbrains.kotlin.idea.intentions.callExpression
@@ -29,15 +30,19 @@ import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor
import org.jetbrains.kotlin.psi.KtDotQualifiedExpression
import org.jetbrains.kotlin.psi.KtPsiFactory
import org.jetbrains.kotlin.psi.buildExpression
import org.jetbrains.kotlin.resolve.bindingContextUtil.isUsedAsExpression
import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall
import org.jetbrains.kotlin.resolve.calls.model.isReallySuccess
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.jetbrains.kotlin.util.OperatorNameConventions
public class ReplaceGetInspection : IntentionBasedInspection<KtDotQualifiedExpression>(
ReplaceGetIntention(), ReplaceGetInspection.additionalChecker
public class ReplaceGetOrSetInspection : IntentionBasedInspection<KtDotQualifiedExpression>(
ReplaceGetOrSetIntention(), ReplaceGetOrSetInspection.additionalChecker
) {
companion object {
val additionalChecker = { expression: KtDotQualifiedExpression ->
(expression.toResolvedCall()!!.resultingDescriptor as FunctionDescriptor).isExplicitOperator()
(expression.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor as FunctionDescriptor).isExplicitOperator()
}
}
}
@@ -49,23 +54,35 @@ private fun FunctionDescriptor.isExplicitOperator(): Boolean {
overriddenDescriptors.any { it.isExplicitOperator() }
}
public class ReplaceGetIntention : JetSelfTargetingRangeIntention<KtDotQualifiedExpression>(javaClass(), "Replace 'get' call with index operator"), HighPriorityAction {
class ReplaceGetOrSetIntention : JetSelfTargetingRangeIntention<KtDotQualifiedExpression>(
KtDotQualifiedExpression::class.java,
"Replace 'get' or 'set' call with indexing operator"
), HighPriorityAction {
private val operatorNames = setOf(OperatorNameConventions.GET, OperatorNameConventions.SET)
override fun applicabilityRange(element: KtDotQualifiedExpression): TextRange? {
val resolvedCall = element.toResolvedCall() ?: return null
val callExpression = element.callExpression ?: return null
val bindingContext = callExpression.analyze(BodyResolveMode.PARTIAL)
val resolvedCall = callExpression.getResolvedCall(bindingContext) ?: return null
if (!resolvedCall.isReallySuccess()) return null
val target = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return null
if (target.name.asString() != "get" || !target.isOperator) return null
if (!target.isOperator || target.name !in operatorNames) return null
val call = element.callExpression ?: return null
if (call.getTypeArgumentList() != null) return null
if (callExpression.getTypeArgumentList() != null) return null
val arguments = call.getValueArguments()
val arguments = callExpression.getValueArguments()
if (arguments.isEmpty()) return null
if (arguments.any { it.isNamed() }) return null
if (!element.isReceiverExpressionWithValue()) return null
return call.getCalleeExpression()!!.getTextRange()
if (target.name == OperatorNameConventions.SET && element.isUsedAsExpression(bindingContext)) return null
text = "Replace '${target.name.asString()}' call with indexing operator"
return callExpression.getCalleeExpression()!!.getTextRange()
}
override fun applyTo(element: KtDotQualifiedExpression, editor: Editor) {
@@ -73,13 +90,19 @@ public class ReplaceGetIntention : JetSelfTargetingRangeIntention<KtDotQualified
}
fun applyTo(element: KtDotQualifiedExpression) {
val isSet = element.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor.name == OperatorNameConventions.SET
val allArguments = element.callExpression!!.valueArguments
if (isSet) {
assert(allArguments.size > 0)
}
val expression = KtPsiFactory(element).buildExpression {
appendExpression(element.getReceiverExpression())
appendFixedText("[")
val call = element.callExpression!!
for ((index, argument) in call.getValueArguments().withIndex()) {
val arguments = if (isSet) allArguments.dropLast(1) else allArguments
for ((index, argument) in arguments.withIndex()) {
if (index > 0) {
appendFixedText(",")
}
@@ -87,7 +110,13 @@ public class ReplaceGetIntention : JetSelfTargetingRangeIntention<KtDotQualified
}
appendFixedText("]")
if (isSet) {
appendFixedText("=")
appendExpression(allArguments.last().getArgumentExpression())
}
}
element.replace(expression)
}
}
@@ -26,8 +26,8 @@ import org.jetbrains.kotlin.idea.inspections.RedundantSamConstructorInspection
import org.jetbrains.kotlin.idea.intentions.*
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention
import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetInspection
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetInspection
import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention
import org.jetbrains.kotlin.idea.quickfix.RemoveModifierFix
import org.jetbrains.kotlin.idea.quickfix.RemoveRightPartOfBinaryExpressionFix
import org.jetbrains.kotlin.idea.references.mainReference
@@ -60,7 +60,7 @@ object J2KPostProcessingRegistrar {
registerIntentionBasedProcessing(IfThenToElvisIntention()) { applyTo(it) }
registerIntentionBasedProcessing(IfNullToElvisIntention()) { applyTo(it) }
registerIntentionBasedProcessing(SimplifyNegatedBinaryExpressionIntention()) { applyTo(it) }
registerIntentionBasedProcessing(ReplaceGetIntention(), additionalChecker = ReplaceGetInspection.additionalChecker) { applyTo(it) }
registerIntentionBasedProcessing(ReplaceGetOrSetIntention(), additionalChecker = ReplaceGetOrSetInspection.additionalChecker) { applyTo(it) }
registerIntentionBasedProcessing(AddOperatorModifierIntention()) { applyTo(it) }
registerDiagnosticBasedProcessing<KtBinaryExpressionWithTypeRHS>(Errors.USELESS_CAST) { element, diagnostic ->
@@ -1,64 +0,0 @@
<problems>
<problem>
<file>singleArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/singleArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>multiArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/multiArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>functionalArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/functionalArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>extensionFunction.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/extensionFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>argumentAndFunction.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/argumentAndFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>acceptableVararg.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/acceptableVararg.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
<problem>
<file>qualifier.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="temp:///src/qualifier.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES">Explicit 'get'</problem_class>
<description>Replace 'get' call with index operator</description>
</problem>
</problems>
@@ -1 +1 @@
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention
org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention
@@ -0,0 +1,82 @@
<problems>
<problem>
<file>singleArgument.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="singleArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>multiArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="multiArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>functionalArgument.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="functionalArgument.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>extensionFunction.kt</file>
<line>7</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="extensionFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>argumentAndFunction.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="argumentAndFunction.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>acceptableVararg.kt</file>
<line>6</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="acceptableVararg.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>qualifier.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="qualifier.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'get' call with indexing operator</description>
</problem>
<problem>
<file>set.kt</file>
<line>8</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="set.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'set' call with indexing operator</description>
</problem>
<problem>
<file>set2.kt</file>
<line>9</line>
<module>light_idea_test_case</module>
<entry_point TYPE="file" FQNAME="set2.kt" />
<problem_class severity="WARNING" attribute_key="WARNING_ATTRIBUTES"/>
<description>Replace 'set' call with indexing operator</description>
</problem>
</problems>
@@ -1 +1 @@
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetInspection
// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetInspection
@@ -0,0 +1,9 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
fun foo() {
C().<caret>set("x", 1)
}
@@ -0,0 +1,9 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
fun foo() {
C()["x"] = 1
}
@@ -0,0 +1,11 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
class D(val c: C) {
fun foo() {
this.c.<caret>set("x", 1)
}
}
@@ -0,0 +1,11 @@
// INTENTION_TEXT: Replace 'set' call with indexing operator
class C {
operator fun set(s: String, value: Int) {}
}
class D(val c: C) {
fun foo() {
this.c["x"] = 1
}
}
@@ -0,0 +1,11 @@
// IS_APPLICABLE: false
class C {
operator fun set(s: String, value: Int): Boolean = true
}
class D(val c: C) {
fun foo(): Boolean {
return this.c.<caret>set("x", 1)
}
}
@@ -1,3 +1,5 @@
// INTENTION_TEXT: Replace 'get' call with indexing operator
fun test() {
class Test{
operator fun get(i: Int) : Int = 0
@@ -1,3 +1,5 @@
// INTENTION_TEXT: Replace 'get' call with indexing operator
fun test() {
class Test{
operator fun get(i: Int) : Int = 0
@@ -49,9 +49,9 @@ public class JetInspectionTestGenerated extends AbstractJetInspectionTest {
doTest(fileName);
}
@TestMetadata("conventionNameCalls/replaceGet/inspectionData/inspections.test")
public void testConventionNameCalls_replaceGet_inspectionData_Inspections_test() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/inspectionData/inspections.test");
@TestMetadata("conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test")
public void testConventionNameCalls_replaceGetOrSet_inspectionData_Inspections_test() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test");
doTest(fileName);
}
@@ -2772,119 +2772,137 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
}
}
@TestMetadata("idea/testData/intentions/conventionNameCalls/replaceGet")
@TestMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class ReplaceGet extends AbstractIntentionTest {
public static class ReplaceGetOrSet extends AbstractIntentionTest {
@TestMetadata("acceptableVararg.kt")
public void testAcceptableVararg() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/acceptableVararg.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt");
doTest(fileName);
}
public void testAllFilesPresentInReplaceGet() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/conventionNameCalls/replaceGet"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
public void testAllFilesPresentInReplaceGetOrSet() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/conventionNameCalls/replaceGetOrSet"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), true);
}
@TestMetadata("argumentAndFunction.kt")
public void testArgumentAndFunction() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/argumentAndFunction.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt");
doTest(fileName);
}
@TestMetadata("duplicateArguments.kt")
public void testDuplicateArguments() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/duplicateArguments.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt");
doTest(fileName);
}
@TestMetadata("extensionFunction.kt")
public void testExtensionFunction() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/extensionFunction.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt");
doTest(fileName);
}
@TestMetadata("functionalArgument.kt")
public void testFunctionalArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/functionalArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt");
doTest(fileName);
}
@TestMetadata("invalidArgument.kt")
public void testInvalidArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/invalidArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/invalidArgument.kt");
doTest(fileName);
}
@TestMetadata("missingDefaultArgument.kt")
public void testMissingDefaultArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/missingDefaultArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt");
doTest(fileName);
}
@TestMetadata("multiArgument.kt")
public void testMultiArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/multiArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt");
doTest(fileName);
}
@TestMetadata("noArgument.kt")
public void testNoArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/noArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/noArgument.kt");
doTest(fileName);
}
@TestMetadata("notOperator.kt")
public void testNotOperator() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/notOperator.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/notOperator.kt");
doTest(fileName);
}
@TestMetadata("qualifier.kt")
public void testQualifier() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/qualifier.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt");
doTest(fileName);
}
@TestMetadata("sanityCheck.kt")
public void testSanityCheck() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/sanityCheck.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/sanityCheck.kt");
doTest(fileName);
}
@TestMetadata("set.kt")
public void testSet() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt");
doTest(fileName);
}
@TestMetadata("set2.kt")
public void testSet2() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt");
doTest(fileName);
}
@TestMetadata("setValueUsed.kt")
public void testSetValueUsed() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setValueUsed.kt");
doTest(fileName);
}
@TestMetadata("singleArgument.kt")
public void testSingleArgument() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/singleArgument.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt");
doTest(fileName);
}
@TestMetadata("staticMethod.kt")
public void testStaticMethod() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/staticMethod.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.kt");
doTest(fileName);
}
@TestMetadata("super.kt")
public void testSuper() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/super.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/super.kt");
doTest(fileName);
}
@TestMetadata("topLevelFun.kt")
public void testTopLevelFun() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/topLevelFun.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/topLevelFun.kt");
doTest(fileName);
}
@TestMetadata("unacceptableVararg.kt")
public void testUnacceptableVararg() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/unacceptableVararg.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt");
doTest(fileName);
}
@TestMetadata("unnamedAndNamed.kt")
public void testUnnamedAndNamed() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGet/unnamedAndNamed.kt");
String fileName = JetTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt");
doTest(fileName);
}
+2 -2
View File
@@ -3,13 +3,13 @@ import java.util.ArrayList
internal class C {
fun foo1(list: MutableList<String>) {
for (i in list.indices) {
list.set(i, "a")
list[i] = "a"
}
}
fun foo2(list: ArrayList<String>) {
for (i in list.indices) {
list.set(i, "a")
list[i] = "a"
}
}
}
+1 -1
View File
@@ -3,7 +3,7 @@ import java.util.ArrayList
internal class C {
fun foo(list: MutableList<String>) {
for (i in list.indices) {
list.set(i, "a")
list[i] = "a"
}
}
}