diff --git a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt index 275d3214a40..c6445c3aff3 100755 --- a/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/kotlin/generators/tests/GenerateTests.kt @@ -318,6 +318,7 @@ fun main(args: Array) { testClass { model("intentions", pattern = "^(inspections\\.test)$", singleClass = true) model("inspections", pattern = "^(inspections\\.test)$", singleClass = true) + model("inspectionsLocal", pattern = "^(inspections\\.test)$", singleClass = true) } testClass { diff --git a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/after.kt.template b/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/after.kt.template deleted file mode 100644 index 6d919b77d89..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/after.kt.template +++ /dev/null @@ -1 +0,0 @@ -inst[a, b] diff --git a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/before.kt.template b/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/before.kt.template deleted file mode 100644 index efa185dc69c..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/before.kt.template +++ /dev/null @@ -1 +0,0 @@ -inst.get(a, b) \ No newline at end of file diff --git a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/description.html b/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/description.html deleted file mode 100644 index 08810115993..00000000000 --- a/idea/resources/intentionDescriptions/ReplaceGetOrSetIntention/description.html +++ /dev/null @@ -1,5 +0,0 @@ - - -This intention replaces get or set function calls with the indexing operator ([]). - - \ No newline at end of file diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 537aa326d1d..f09fc29ddd9 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -812,11 +812,6 @@ Kotlin - - org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention - Kotlin - - org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceContainsIntention Kotlin @@ -1607,7 +1602,7 @@ language="kotlin" /> - () { + private fun FunctionDescriptor.isExplicitOperator(): Boolean { + return if (overriddenDescriptors.isEmpty()) + containingDeclaration !is JavaClassDescriptor && isOperator + else + overriddenDescriptors.any { it.isExplicitOperator() } + } + + 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 val operatorNames = setOf(OperatorNameConventions.GET, OperatorNameConventions.SET) + + override fun isApplicable(element: KtDotQualifiedExpression): Boolean { + val callExpression = element.callExpression ?: return false + val bindingContext = callExpression.analyze(BodyResolveMode.PARTIAL) + val resolvedCall = callExpression.getResolvedCall(bindingContext) ?: return false + if (!resolvedCall.isReallySuccess()) return false + + val target = resolvedCall.resultingDescriptor as? FunctionDescriptor ?: return false + if (!target.isValidOperator() || target.name !in operatorNames) return false + + if (callExpression.typeArgumentList != null) return false + + val arguments = callExpression.valueArguments + if (arguments.isEmpty()) return false + if (arguments.any { it.isNamed() }) return false + + if (!element.isReceiverExpressionWithValue()) return false + + return target.name != OperatorNameConventions.SET || !element.isUsedAsExpression(bindingContext) + } + + override fun inspectionText(element: KtDotQualifiedExpression) = "Call replaceable with indexing operator" + + override fun inspectionHighlightType(element: KtDotQualifiedExpression): ProblemHighlightType { + return if ((element.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor as FunctionDescriptor).isExplicitOperator()) { + ProblemHighlightType.GENERIC_ERROR_OR_WARNING + } + else { + ProblemHighlightType.INFORMATION + } + } + + override val defaultFixText: String + get() = "Replace get or set call with indexing operator" + + override fun fixText(element: KtDotQualifiedExpression): String { + val callExpression = element.callExpression ?: return defaultFixText + val bindingContext = callExpression.analyze(BodyResolveMode.PARTIAL) + val resolvedCall = callExpression.getResolvedCall(bindingContext) ?: return defaultFixText + return "Replace '${resolvedCall.resultingDescriptor.name.asString()}' call with indexing operator" + } + + override fun inspectionTarget(element: KtDotQualifiedExpression) = element.callExpression?.calleeExpression ?: element + + override fun applyTo(element: PsiElement, project: Project, editor: Editor?) { + val expression = element as? KtDotQualifiedExpression ?: element.parent.parent as? KtDotQualifiedExpression ?: return + val isSet = expression.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor.name == OperatorNameConventions.SET + val allArguments = expression.callExpression!!.valueArguments + assert(allArguments.isNotEmpty()) + + val newExpression = KtPsiFactory(expression).buildExpression { + appendExpression(expression.receiverExpression) + + appendFixedText("[") + + val arguments = if (isSet) allArguments.dropLast(1) else allArguments + appendExpressions(arguments.map { it.getArgumentExpression() }) + + appendFixedText("]") + + if (isSet) { + appendFixedText("=") + appendExpression(allArguments.last().getArgumentExpression()) + } + } + + val newElement = expression.replace(newExpression) + + if (editor != null) { + moveCaret(editor, isSet, newElement) + } + } + + private fun moveCaret(editor: Editor, isSet: Boolean, newElement: PsiElement) { + val arrayAccessExpression = if (isSet) { + newElement.getChildOfType()!! + } + else { + newElement as KtArrayAccessExpression + } + + editor.caretModel.moveToOffset(arrayAccessExpression.leftBracket!!.startOffset) + } +} diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt deleted file mode 100644 index 7c474580b3d..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetOrSetIntention.kt +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2010-2015 JetBrains s.r.o. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package org.jetbrains.kotlin.idea.intentions.conventionNameCalls - -import com.intellij.codeInsight.intention.HighPriorityAction -import com.intellij.openapi.editor.Editor -import com.intellij.openapi.util.TextRange -import com.intellij.psi.PsiElement -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.SelfTargetingRangeIntention -import org.jetbrains.kotlin.idea.intentions.callExpression -import org.jetbrains.kotlin.idea.intentions.isReceiverExpressionWithValue -import org.jetbrains.kotlin.idea.intentions.toResolvedCall -import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor -import org.jetbrains.kotlin.psi.KtArrayAccessExpression -import org.jetbrains.kotlin.psi.KtDotQualifiedExpression -import org.jetbrains.kotlin.psi.KtPsiFactory -import org.jetbrains.kotlin.psi.buildExpression -import org.jetbrains.kotlin.psi.psiUtil.getChildOfType -import org.jetbrains.kotlin.psi.psiUtil.startOffset -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 -import org.jetbrains.kotlin.util.isValidOperator - -class ReplaceGetOrSetInspection : IntentionBasedInspection( - ReplaceGetOrSetIntention::class, ReplaceGetOrSetInspection.additionalChecker - -) { - companion object { - val additionalChecker = { expression: KtDotQualifiedExpression -> - (expression.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor as FunctionDescriptor).isExplicitOperator() - } - } -} - -private fun FunctionDescriptor.isExplicitOperator(): Boolean { - return if (overriddenDescriptors.isEmpty()) - containingDeclaration !is JavaClassDescriptor && isOperator - else - overriddenDescriptors.any { it.isExplicitOperator() } -} - -class ReplaceGetOrSetIntention : SelfTargetingRangeIntention( - 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 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.isValidOperator() || target.name !in operatorNames) return null - - if (callExpression.typeArgumentList != null) return null - - val arguments = callExpression.valueArguments - if (arguments.isEmpty()) return null - if (arguments.any { it.isNamed() }) return null - - if (!element.isReceiverExpressionWithValue()) return null - - if (target.name == OperatorNameConventions.SET && element.isUsedAsExpression(bindingContext)) return null - - text = "Replace '${target.name.asString()}' call with indexing operator" - - return callExpression.calleeExpression!!.textRange - } - - override fun applyTo(element: KtDotQualifiedExpression, editor: Editor?) { - val isSet = element.toResolvedCall(BodyResolveMode.PARTIAL)!!.resultingDescriptor.name == OperatorNameConventions.SET - val allArguments = element.callExpression!!.valueArguments - assert(allArguments.isNotEmpty()) - - val expression = KtPsiFactory(element).buildExpression { - appendExpression(element.receiverExpression) - - appendFixedText("[") - - val arguments = if (isSet) allArguments.dropLast(1) else allArguments - appendExpressions(arguments.map { it.getArgumentExpression() }) - - appendFixedText("]") - - if (isSet) { - appendFixedText("=") - appendExpression(allArguments.last().getArgumentExpression()) - } - } - - val newElement = element.replace(expression) - - if (editor != null) { - moveCaret(editor, isSet, newElement) - } - } - - private fun moveCaret(editor: Editor, isSet: Boolean, newElement: PsiElement) { - val arrayAccessExpression = if (isSet) { - newElement.getChildOfType()!! - } - else { - newElement as KtArrayAccessExpression - } - - editor.caretModel.moveToOffset(arrayAccessExpression.leftBracket!!.startOffset) - } -} diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt index 32008a15ba5..66f566178ca 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessings.kt @@ -27,14 +27,13 @@ import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.core.replaced import org.jetbrains.kotlin.idea.core.setVisibility import org.jetbrains.kotlin.idea.inspections.* +import org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceGetOrSetInspection import org.jetbrains.kotlin.idea.intentions.* import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnAsymmetricallyIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.FoldIfToReturnIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.isTrivialStatementBody -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.RemoveUselessCastFix import org.jetbrains.kotlin.idea.refactoring.inline.KotlinInlineValHandler @@ -91,7 +90,7 @@ object J2KPostProcessingRegistrar { registerIntentionBasedProcessing(IfThenToSafeAccessIntention()) registerIntentionBasedProcessing(IfThenToElvisIntention()) registerIntentionBasedProcessing(SimplifyNegatedBinaryExpressionIntention()) - registerIntentionBasedProcessing(ReplaceGetOrSetIntention(), additionalChecker = ReplaceGetOrSetInspection.additionalChecker) + registerInspectionBasedProcessing(ReplaceGetOrSetInspection()) registerIntentionBasedProcessing(AddOperatorModifierIntention()) registerIntentionBasedProcessing(ObjectLiteralToLambdaIntention()) registerIntentionBasedProcessing(AnonymousFunctionToLambdaIntention()) diff --git a/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/.inspection b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/.inspection new file mode 100644 index 00000000000..24a18f1a199 --- /dev/null +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/.inspection @@ -0,0 +1 @@ +org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceGetOrSetInspection diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt similarity index 91% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt index ec1ecfc8108..726c3351941 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: An argument is already passed for this parameter // ERROR: No value passed for parameter 'b' fun test() { diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/extensionFunction.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/extensionFunction.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/extensionFunction.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/extensionFunction.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/functionalArgument.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/functionalArgument.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/functionalArgument.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/functionalArgument.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml similarity index 66% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml index 056dad6b970..77d4af09b97 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/expected.xml @@ -4,8 +4,8 @@ 8 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -13,8 +13,8 @@ 6 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -22,8 +22,8 @@ 6 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -31,8 +31,8 @@ 7 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -40,8 +40,8 @@ 6 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -49,8 +49,8 @@ 6 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -58,8 +58,8 @@ 8 light_idea_test_case - - Replace 'get' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -67,8 +67,8 @@ 8 light_idea_test_case - - Replace 'set' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator @@ -76,7 +76,7 @@ 9 light_idea_test_case - - Replace 'set' call with indexing operator + Explicit 'get' or 'set' call + Call replaceable with indexing operator diff --git a/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test new file mode 100644 index 00000000000..7c537ab4fd4 --- /dev/null +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test @@ -0,0 +1 @@ +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.inspections.conventionNameCalls.ReplaceGetOrSetInspection diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/invalidArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/invalidArgument.kt similarity index 88% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/invalidArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/invalidArgument.kt index 7833c291f06..879d7a53f9e 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/invalidArgument.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/invalidArgument.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: Cannot find a parameter with this name: c fun test() { class Test{ diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt similarity index 85% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt index ec9ecba95c6..1766f8e4dc7 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none fun test() { class Test{ operator fun get(a: Int=1, b: Int=2) : Int = 0 diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/multiArgument.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/multiArgument.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/multiArgument.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/multiArgument.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/noArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/noArgument.kt similarity index 90% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/noArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/noArgument.kt index 4dca5e57b29..94da75ea143 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/noArgument.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/noArgument.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: 'operator' modifier is inapplicable on this function: must have at least 1 value parameter fun test() { class Test{ diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/notOperator.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/notOperator.kt similarity index 78% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/notOperator.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/notOperator.kt index b1ceac07976..a551b023d9c 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/notOperator.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/notOperator.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none package p class C diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/qualifier.kt similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/qualifier.kt diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/qualifier.kt.after similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/qualifier.kt.after diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/sanityCheck.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/sanityCheck.kt similarity index 87% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/sanityCheck.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/sanityCheck.kt index b68378e3a2d..b637f5f53cb 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/sanityCheck.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/sanityCheck.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: Unresolved reference: got fun test() { class Test{ diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt similarity index 62% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt index a7183c945fd..bde3716e1e9 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'set' call with indexing operator +// FIX: Replace 'set' call with indexing operator class C { operator fun set(s: String, value: Int) {} diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt.after similarity index 61% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt.after index ba0f0ed68c0..f72a63af23b 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt.after +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt.after @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'set' call with indexing operator +// FIX: Replace 'set' call with indexing operator class C { operator fun set(s: String, value: Int) {} diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt similarity index 72% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt index 17b2712ccc0..cde7669113b 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'set' call with indexing operator +// FIX: Replace 'set' call with indexing operator class C { operator fun set(s: String, p: Int, value: Int): Boolean = true diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt.after similarity index 72% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt.after index 0d6b1eb2d1d..32fe81fef8f 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt.after +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt.after @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'set' call with indexing operator +// FIX: Replace 'set' call with indexing operator class C { operator fun set(s: String, p: Int, value: Int): Boolean = true diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setValueUsed.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setValueUsed.kt similarity index 87% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setValueUsed.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setValueUsed.kt index 44a3ef2d5fd..0b3b838cfb1 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setValueUsed.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setValueUsed.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none class C { operator fun set(s: String, value: Int): Boolean = true diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt similarity index 89% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt index 428d8a8cb60..4dbf45adbce 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: 'operator' modifier is inapplicable on this function: must have at least 2 value parameters class C { diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithVararg.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithVararg.kt similarity index 92% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithVararg.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithVararg.kt index 78ef6e01c1e..8d09dc5660f 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithVararg.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithVararg.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: 'operator' modifier is inapplicable on this function: last parameter should not have a default value or be a vararg class C { diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt similarity index 67% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt index 0120bd84bc7..e9d32e2fd3c 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'get' call with indexing operator +// FIX: Replace 'get' call with indexing operator fun test() { class Test{ diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after similarity index 66% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after index 95d8ca55a42..4e40fa45a5d 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt.after @@ -1,4 +1,4 @@ -// INTENTION_TEXT: Replace 'get' call with indexing operator +// FIX: Replace 'get' call with indexing operator fun test() { class Test{ diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.1.java b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.1.java similarity index 100% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.1.java rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.1.java diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.kt similarity index 68% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.kt index ffa6c14729e..558a42f458c 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none fun foo() { JavaClass.get(JavaClass()) } diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/super.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/super.kt similarity index 87% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/super.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/super.kt index 13fc86a6195..08073c343dd 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/super.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/super.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none open class Base { open operator fun get(s: String) = "" diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/topLevelFun.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/topLevelFun.kt similarity index 88% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/topLevelFun.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/topLevelFun.kt index 7f89a884ed4..b5e909a242a 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/topLevelFun.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/topLevelFun.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none // ERROR: 'operator' modifier is inapplicable on this function: must be a member or an extension function package p diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt similarity index 87% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt index fc7be00e7e3..7f666b684ef 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none fun test() { class Test{ operator fun get(a: Int, vararg b: Int, c: Int = 0) : Int = 0 diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt similarity index 87% rename from idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt rename to idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt index da4be6cf0c9..18eaacbdb31 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt +++ b/idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt @@ -1,4 +1,4 @@ -// IS_APPLICABLE: false +// PROBLEM: none fun test() { class Test{ operator fun get(a: Int = 0, b: Int = 1, c: Int = 2, d: Int = 3) : Int = 0 diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/.intention b/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/.intention deleted file mode 100644 index 1cc0a8bd180..00000000000 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/.intention +++ /dev/null @@ -1 +0,0 @@ -org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetIntention diff --git a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test b/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test deleted file mode 100644 index 3049fb8bebe..00000000000 --- a/idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test +++ /dev/null @@ -1 +0,0 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetOrSetInspection diff --git a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java index 16e4d39eacb..16c0fccf51c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/codeInsight/InspectionTestGenerated.java @@ -50,12 +50,6 @@ public class InspectionTestGenerated extends AbstractInspectionTest { doTest(fileName); } - @TestMetadata("conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test") - public void testConventionNameCalls_replaceGetOrSet_inspectionData_Inspections_test() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test"); - doTest(fileName); - } - @TestMetadata("convertToStringTemplate/inspectionData/inspections.test") public void testConvertToStringTemplate_inspectionData_Inspections_test() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/convertToStringTemplate/inspectionData/inspections.test"); @@ -485,4 +479,19 @@ public class InspectionTestGenerated extends AbstractInspectionTest { doTest(fileName); } } + + @TestMetadata("idea/testData/inspectionsLocal") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class InspectionsLocal extends AbstractInspectionTest { + public void testAllFilesPresentInInspectionsLocal() throws Exception { + KotlinTestUtils.assertAllTestsPresentInSingleGeneratedClass(this.getClass(), new File("idea/testData/inspectionsLocal"), Pattern.compile("^(inspections\\.test)$"), TargetBackend.ANY); + } + + @TestMetadata("conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test") + public void testConventionNameCalls_replaceGetOrSet_inspectionData_Inspections_test() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/inspectionData/inspections.test"); + doTest(fileName); + } + } } diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index eb4d8753dbf..a4685103018 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -91,7 +91,21 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa DirectiveBasedActionUtils.checkForUnexpectedErrors(file as KtFile) } - val psiFile = myFixture.configureByFiles(mainFile.name).first() + var i = 1 + val extraFileNames = mutableListOf() + extraFileLoop@ while (true) { + for (extension in EXTENSIONS) { + val extraFile = File(mainFile.parent, FileUtil.getNameWithoutExtension(mainFile) + "." + i + extension) + if (extraFile.exists()) { + extraFileNames += extraFile.name + i++ + continue@extraFileLoop + } + } + break + } + + val psiFile = myFixture.configureByFiles(*(listOf(mainFile.name) + extraFileNames).toTypedArray()).first() doTestFor(mainFile.name, psiFile.virtualFile!!, inspection, fileText) @@ -168,5 +182,7 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa ) } } - + companion object { + private val EXTENSIONS = arrayOf(".kt", ".kts", ".java", ".groovy") + } } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java index 1301bce8b75..4bde56db74c 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/LocalInspectionTestGenerated.java @@ -522,6 +522,162 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest { } } + @TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ConventionNameCalls extends AbstractLocalInspectionTest { + public void testAllFilesPresentInConventionNameCalls() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/conventionNameCalls"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ReplaceGetOrSet extends AbstractLocalInspectionTest { + @TestMetadata("acceptableVararg.kt") + public void testAcceptableVararg() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt"); + doTest(fileName); + } + + public void testAllFilesPresentInReplaceGetOrSet() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); + } + + @TestMetadata("argumentAndFunction.kt") + public void testArgumentAndFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt"); + doTest(fileName); + } + + @TestMetadata("duplicateArguments.kt") + public void testDuplicateArguments() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt"); + doTest(fileName); + } + + @TestMetadata("extensionFunction.kt") + public void testExtensionFunction() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/extensionFunction.kt"); + doTest(fileName); + } + + @TestMetadata("functionalArgument.kt") + public void testFunctionalArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/functionalArgument.kt"); + doTest(fileName); + } + + @TestMetadata("invalidArgument.kt") + public void testInvalidArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/invalidArgument.kt"); + doTest(fileName); + } + + @TestMetadata("missingDefaultArgument.kt") + public void testMissingDefaultArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt"); + doTest(fileName); + } + + @TestMetadata("multiArgument.kt") + public void testMultiArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/multiArgument.kt"); + doTest(fileName); + } + + @TestMetadata("noArgument.kt") + public void testNoArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/noArgument.kt"); + doTest(fileName); + } + + @TestMetadata("notOperator.kt") + public void testNotOperator() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/notOperator.kt"); + doTest(fileName); + } + + @TestMetadata("qualifier.kt") + public void testQualifier() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/qualifier.kt"); + doTest(fileName); + } + + @TestMetadata("sanityCheck.kt") + public void testSanityCheck() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/sanityCheck.kt"); + doTest(fileName); + } + + @TestMetadata("set.kt") + public void testSet() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set.kt"); + doTest(fileName); + } + + @TestMetadata("set2.kt") + public void testSet2() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/set2.kt"); + doTest(fileName); + } + + @TestMetadata("setValueUsed.kt") + public void testSetValueUsed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setValueUsed.kt"); + doTest(fileName); + } + + @TestMetadata("setWithNoParameters.kt") + public void testSetWithNoParameters() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt"); + doTest(fileName); + } + + @TestMetadata("setWithVararg.kt") + public void testSetWithVararg() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/setWithVararg.kt"); + doTest(fileName); + } + + @TestMetadata("singleArgument.kt") + public void testSingleArgument() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/singleArgument.kt"); + doTest(fileName); + } + + @TestMetadata("staticMethod.kt") + public void testStaticMethod() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/staticMethod.kt"); + doTest(fileName); + } + + @TestMetadata("super.kt") + public void testSuper() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/super.kt"); + doTest(fileName); + } + + @TestMetadata("topLevelFun.kt") + public void testTopLevelFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/topLevelFun.kt"); + doTest(fileName); + } + + @TestMetadata("unacceptableVararg.kt") + public void testUnacceptableVararg() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt"); + doTest(fileName); + } + + @TestMetadata("unnamedAndNamed.kt") + public void testUnnamedAndNamed() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt"); + doTest(fileName); + } + } + } + @TestMetadata("idea/testData/inspectionsLocal/copyWithoutNamedArguments") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class) diff --git a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java index 3f6384a47de..a51b7a05743 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/intentions/IntentionTestGenerated.java @@ -3839,153 +3839,6 @@ public class IntentionTestGenerated extends AbstractIntentionTest { } } - @TestMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet") - @TestDataPath("$PROJECT_ROOT") - @RunWith(JUnit3RunnerWithInners.class) - public static class ReplaceGetOrSet extends AbstractIntentionTest { - @TestMetadata("acceptableVararg.kt") - public void testAcceptableVararg() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/acceptableVararg.kt"); - doTest(fileName); - } - - public void testAllFilesPresentInReplaceGetOrSet() throws Exception { - KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/intentions/conventionNameCalls/replaceGetOrSet"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true); - } - - @TestMetadata("argumentAndFunction.kt") - public void testArgumentAndFunction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/argumentAndFunction.kt"); - doTest(fileName); - } - - @TestMetadata("duplicateArguments.kt") - public void testDuplicateArguments() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/duplicateArguments.kt"); - doTest(fileName); - } - - @TestMetadata("extensionFunction.kt") - public void testExtensionFunction() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/extensionFunction.kt"); - doTest(fileName); - } - - @TestMetadata("functionalArgument.kt") - public void testFunctionalArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/functionalArgument.kt"); - doTest(fileName); - } - - @TestMetadata("invalidArgument.kt") - public void testInvalidArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/invalidArgument.kt"); - doTest(fileName); - } - - @TestMetadata("missingDefaultArgument.kt") - public void testMissingDefaultArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/missingDefaultArgument.kt"); - doTest(fileName); - } - - @TestMetadata("multiArgument.kt") - public void testMultiArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/multiArgument.kt"); - doTest(fileName); - } - - @TestMetadata("noArgument.kt") - public void testNoArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/noArgument.kt"); - doTest(fileName); - } - - @TestMetadata("notOperator.kt") - public void testNotOperator() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/notOperator.kt"); - doTest(fileName); - } - - @TestMetadata("qualifier.kt") - public void testQualifier() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/qualifier.kt"); - doTest(fileName); - } - - @TestMetadata("sanityCheck.kt") - public void testSanityCheck() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/sanityCheck.kt"); - doTest(fileName); - } - - @TestMetadata("set.kt") - public void testSet() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set.kt"); - doTest(fileName); - } - - @TestMetadata("set2.kt") - public void testSet2() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/set2.kt"); - doTest(fileName); - } - - @TestMetadata("setValueUsed.kt") - public void testSetValueUsed() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setValueUsed.kt"); - doTest(fileName); - } - - @TestMetadata("setWithNoParameters.kt") - public void testSetWithNoParameters() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithNoParameters.kt"); - doTest(fileName); - } - - @TestMetadata("setWithVararg.kt") - public void testSetWithVararg() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/setWithVararg.kt"); - doTest(fileName); - } - - @TestMetadata("singleArgument.kt") - public void testSingleArgument() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/singleArgument.kt"); - doTest(fileName); - } - - @TestMetadata("staticMethod.kt") - public void testStaticMethod() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/staticMethod.kt"); - doTest(fileName); - } - - @TestMetadata("super.kt") - public void testSuper() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/super.kt"); - doTest(fileName); - } - - @TestMetadata("topLevelFun.kt") - public void testTopLevelFun() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/topLevelFun.kt"); - doTest(fileName); - } - - @TestMetadata("unacceptableVararg.kt") - public void testUnacceptableVararg() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unacceptableVararg.kt"); - doTest(fileName); - } - - @TestMetadata("unnamedAndNamed.kt") - public void testUnnamedAndNamed() throws Exception { - String fileName = KotlinTestUtils.navigationMetadata("idea/testData/intentions/conventionNameCalls/replaceGetOrSet/unnamedAndNamed.kt"); - doTest(fileName); - } - } - @TestMetadata("idea/testData/intentions/conventionNameCalls/replaceInvoke") @TestDataPath("$PROJECT_ROOT") @RunWith(JUnit3RunnerWithInners.class)