diff --git a/idea/resources/inspectionDescriptions/RemoveExplicitTypeArgs.html b/idea/resources/inspectionDescriptions/RemoveExplicitTypeArguments.html similarity index 100% rename from idea/resources/inspectionDescriptions/RemoveExplicitTypeArgs.html rename to idea/resources/inspectionDescriptions/RemoveExplicitTypeArguments.html diff --git a/idea/resources/inspectionDescriptions/SimplifyBinaryNegation.html b/idea/resources/inspectionDescriptions/SimplifyNegatedBinaryExpression.html similarity index 100% rename from idea/resources/inspectionDescriptions/SimplifyBinaryNegation.html rename to idea/resources/inspectionDescriptions/SimplifyNegatedBinaryExpression.html diff --git a/idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/after.kt.template b/idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/after.kt.template similarity index 100% rename from idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/after.kt.template rename to idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/after.kt.template diff --git a/idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/before.kt.template b/idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/before.kt.template similarity index 100% rename from idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/before.kt.template rename to idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/before.kt.template diff --git a/idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/description.html b/idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/description.html similarity index 100% rename from idea/resources/intentionDescriptions/RemoveExplicitTypeArguments/description.html rename to idea/resources/intentionDescriptions/RemoveExplicitTypeArgumentsIntention/description.html diff --git a/idea/src/META-INF/plugin.xml b/idea/src/META-INF/plugin.xml index 5d0d41bf39c..507d53c1d1c 100644 --- a/idea/src/META-INF/plugin.xml +++ b/idea/src/META-INF/plugin.xml @@ -681,7 +681,7 @@ - org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArguments + org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention Kotlin @@ -875,21 +875,21 @@ Kotlin - - - - - - (IfNullToElvisIntention()) + public class IfNullToElvisIntention : JetSelfTargetingRangeIntention(javaClass(), "Replace 'if' with elvis operator"){ override fun applicabilityRange(element: JetIfExpression): TextRange? { val data = calcData(element) ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArguments.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt similarity index 87% rename from idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArguments.kt rename to idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt index ffd79eae9e9..0a5fc474926 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArguments.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/RemoveExplicitTypeArgumentsIntention.kt @@ -16,10 +16,12 @@ package org.jetbrains.kotlin.idea.intentions +import com.intellij.codeInspection.ProblemHighlightType import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.di.InjectorForMacros import org.jetbrains.kotlin.idea.caches.resolve.analyze import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.util.approximateFlexibleTypes import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.getTextWithLocation @@ -28,10 +30,14 @@ import org.jetbrains.kotlin.resolve.BindingTraceContext import org.jetbrains.kotlin.resolve.bindingContextUtil.getDataFlowInfo import org.jetbrains.kotlin.resolve.calls.callUtil.getResolvedCall import org.jetbrains.kotlin.resolve.calls.util.DelegatingCall -import org.jetbrains.kotlin.resolve.scopes.JetScope import org.jetbrains.kotlin.types.TypeUtils -public class RemoveExplicitTypeArguments : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Remove explicit type arguments") { +public class RemoveExplicitTypeArgumentsInspection : IntentionBasedInspection(RemoveExplicitTypeArgumentsIntention()) { + override val problemHighlightType: ProblemHighlightType + get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL +} + +public class RemoveExplicitTypeArgumentsIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Remove explicit type arguments") { override fun isApplicableTo(element: JetTypeArgumentList): Boolean { val callExpression = element.getParent() as? JetCallExpression ?: return false if (callExpression.getTypeArguments().isEmpty()) return false diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt index e674d662f2d..c71284742a3 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/ReplaceWithOperatorAssignmentIntention.kt @@ -16,16 +16,19 @@ package org.jetbrains.kotlin.idea.intentions -import org.jetbrains.kotlin.psi.JetBinaryExpression import com.intellij.openapi.editor.Editor +import org.jetbrains.kotlin.builtins.KotlinBuiltIns +import org.jetbrains.kotlin.descriptors.ClassDescriptor +import org.jetbrains.kotlin.idea.caches.resolve.analyze +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection +import org.jetbrains.kotlin.idea.util.psi.patternMatching.matches import org.jetbrains.kotlin.lexer.JetTokens +import org.jetbrains.kotlin.psi.JetBinaryExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.JetSimpleNameExpression import org.jetbrains.kotlin.resolve.BindingContext -import org.jetbrains.kotlin.descriptors.ClassDescriptor -import org.jetbrains.kotlin.builtins.KotlinBuiltIns -import org.jetbrains.kotlin.idea.util.psi.patternMatching.matches -import org.jetbrains.kotlin.idea.caches.resolve.analyze + +public class ReplaceWithOperatorAssignmentInspection : IntentionBasedInspection(ReplaceWithOperatorAssignmentIntention()) public class ReplaceWithOperatorAssignmentIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Replace with operator-assignment") { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt index 76df667c97a..33580083804 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/SimplifyNegatedBinaryExpressionIntention.kt @@ -19,10 +19,13 @@ package org.jetbrains.kotlin.idea.intentions import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange import com.intellij.psi.tree.IElementType +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.lexer.JetSingleValueToken import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* +public class SimplifyNegatedBinaryExpressionInspection : IntentionBasedInspection(SimplifyNegatedBinaryExpressionIntention()) + public class SimplifyNegatedBinaryExpressionIntention : JetSelfTargetingRangeIntention(javaClass(), "Simplify negated binary expression") { private fun IElementType.negate(): JetSingleValueToken? = when (this) { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt index 7e0db126b1d..f8c0f7e2752 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToElvisIntention.kt @@ -18,12 +18,15 @@ package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions import com.intellij.openapi.editor.Editor import org.jetbrains.kotlin.JetNodeTypes +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingOffsetIndependentIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.* import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.replaced +public class IfThenToElvisInspection : IntentionBasedInspection(IfThenToElvisIntention()) + public class IfThenToElvisIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Replace 'if' expression with elvis expression") { override fun isApplicableTo(element: JetIfExpression): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToSafeAccessIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToSafeAccessIntention.kt index 53b2a7a15a9..922bc4d6f3a 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToSafeAccessIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IfThenToSafeAccessIntention.kt @@ -17,12 +17,15 @@ package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions import com.intellij.openapi.editor.Editor +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingOffsetIndependentIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.* import org.jetbrains.kotlin.lexer.JetTokens import org.jetbrains.kotlin.psi.* import org.jetbrains.kotlin.psi.psiUtil.replaced +public class IfThenToSafeAccessInspection : IntentionBasedInspection(IfThenToSafeAccessIntention()) + public class IfThenToSafeAccessIntention : JetSelfTargetingOffsetIndependentIntention(javaClass(), "Replace 'if' expression with safe access expression") { override fun isApplicableTo(element: JetIfExpression): Boolean { diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt index ea7da9e4bf5..6744f821b93 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/branchedTransformations/intentions/IntroduceWhenSubjectIntention.kt @@ -18,11 +18,14 @@ package org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.getSubjectToIntroduce import org.jetbrains.kotlin.idea.intentions.branchedTransformations.introduceSubject import org.jetbrains.kotlin.psi.JetWhenExpression +public class IntroduceWhenSubjectInspection : IntentionBasedInspection(IntroduceWhenSubjectIntention()) + public class IntroduceWhenSubjectIntention : JetSelfTargetingRangeIntention(javaClass(), "Introduce argument to 'when'") { override fun applicabilityRange(element: JetWhenExpression): TextRange? { val subject = element.getSubjectToIntroduce() ?: return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetIntention.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetIntention.kt index 0c7379b8aa3..7b13f8e5ff2 100644 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetIntention.kt +++ b/idea/src/org/jetbrains/kotlin/idea/intentions/conventionNameCalls/ReplaceGetIntention.kt @@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.intentions.conventionNameCalls import com.intellij.openapi.editor.Editor import com.intellij.openapi.util.TextRange +import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection import org.jetbrains.kotlin.idea.intentions.JetSelfTargetingRangeIntention import org.jetbrains.kotlin.idea.intentions.callExpression import org.jetbrains.kotlin.idea.intentions.functionName @@ -25,6 +26,8 @@ import org.jetbrains.kotlin.psi.JetDotQualifiedExpression import org.jetbrains.kotlin.psi.JetPsiFactory import org.jetbrains.kotlin.psi.buildExpression +public class ExplicitGetInspection : IntentionBasedInspection(ReplaceGetIntention()) + public class ReplaceGetIntention : JetSelfTargetingRangeIntention(javaClass(), "Replace 'get' call with index operator") { override fun applicabilityRange(element: JetDotQualifiedExpression): TextRange? { if (element.functionName != "get") return null diff --git a/idea/src/org/jetbrains/kotlin/idea/intentions/inspections.kt b/idea/src/org/jetbrains/kotlin/idea/intentions/inspections.kt deleted file mode 100644 index 5e16b686033..00000000000 --- a/idea/src/org/jetbrains/kotlin/idea/intentions/inspections.kt +++ /dev/null @@ -1,45 +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 - -import com.intellij.codeInspection.ProblemHighlightType -import org.jetbrains.kotlin.idea.inspections.IntentionBasedInspection -import org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ReplaceGetIntention -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.intentions.IntroduceWhenSubjectIntention -import org.jetbrains.kotlin.psi.* - -public class ExplicitGetInspection : IntentionBasedInspection(ReplaceGetIntention()) - -public class IfThenToElvisInspection : IntentionBasedInspection(IfThenToElvisIntention()) - -public class IfThenToSafeAccessInspection : IntentionBasedInspection(IfThenToSafeAccessIntention()) - -public class IfNullToElvisInspection : IntentionBasedInspection(IfNullToElvisIntention()) - -public class RemoveExplicitTypeArgsInspection : IntentionBasedInspection(RemoveExplicitTypeArguments()) { - override val problemHighlightType: ProblemHighlightType - get() = ProblemHighlightType.LIKE_UNUSED_SYMBOL -} - -public class SimplifyBinaryNegationInspection : IntentionBasedInspection(SimplifyNegatedBinaryExpressionIntention()) - -public class ReplaceWithOperatorAssignmentInspection : IntentionBasedInspection(ReplaceWithOperatorAssignmentIntention()) - -public class IntroduceWhenSubjectInspection : IntentionBasedInspection(IntroduceWhenSubjectIntention()) - diff --git a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt index 4d6cd24d419..6859a07842d 100644 --- a/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt +++ b/idea/src/org/jetbrains/kotlin/idea/j2k/J2kPostProcessor.kt @@ -26,7 +26,7 @@ import org.jetbrains.kotlin.diagnostics.Diagnostic import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade import org.jetbrains.kotlin.idea.intentions.IfNullToElvisIntention -import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArguments +import org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention import org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisIntention import org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessIntention @@ -103,7 +103,7 @@ public class J2kPostProcessor(private val formatCode: Boolean) : PostProcessor { } override fun visitTypeArgumentList(typeArgumentList: JetTypeArgumentList) { - if (rangeFilter(typeArgumentList) == RangeFilterResult.PROCESS && RemoveExplicitTypeArguments().isApplicableTo(typeArgumentList)) { + if (rangeFilter(typeArgumentList) == RangeFilterResult.PROCESS && RemoveExplicitTypeArgumentsIntention().isApplicableTo(typeArgumentList)) { redundantTypeArgs.add(typeArgumentList) return } diff --git a/idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test b/idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test index 29b97c8b3ab..717942c3f28 100644 --- a/idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test +++ b/idea/testData/intentions/branched/ifThenToElvis/inspectionData/inspections.test @@ -1 +1 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.IfThenToElvisInspection +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToElvisInspection diff --git a/idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test b/idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test index 7e465eb8430..ab7a3fbec9a 100644 --- a/idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test +++ b/idea/testData/intentions/branched/ifThenToSafeAccess/inspectionData/inspections.test @@ -1 +1 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.IfThenToSafeAccessInspection +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.branchedTransformations.intentions.IfThenToSafeAccessInspection diff --git a/idea/testData/intentions/conventionNameCalls/replaceGet/inspectionData/inspections.test b/idea/testData/intentions/conventionNameCalls/replaceGet/inspectionData/inspections.test index 4b166399990..44897a1a382 100644 --- a/idea/testData/intentions/conventionNameCalls/replaceGet/inspectionData/inspections.test +++ b/idea/testData/intentions/conventionNameCalls/replaceGet/inspectionData/inspections.test @@ -1 +1 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.ExplicitGetInspection +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.conventionNameCalls.ExplicitGetInspection diff --git a/idea/testData/intentions/removeExplicitTypeArguments/.intention b/idea/testData/intentions/removeExplicitTypeArguments/.intention index 66d949609e3..4700a532461 100644 --- a/idea/testData/intentions/removeExplicitTypeArguments/.intention +++ b/idea/testData/intentions/removeExplicitTypeArguments/.intention @@ -1 +1 @@ -org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArguments +org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsIntention diff --git a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test index ffe5a260518..5c06704b32e 100644 --- a/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test +++ b/idea/testData/intentions/removeExplicitTypeArguments/inspectionData/inspections.test @@ -1 +1 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgsInspection +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.RemoveExplicitTypeArgumentsInspection diff --git a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test b/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test index 9b60db23f62..cde81a4753e 100644 --- a/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test +++ b/idea/testData/intentions/simplifyNegatedBinaryExpression/inspectionData/inspections.test @@ -1 +1 @@ -// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.SimplifyBinaryNegationInspection +// INSPECTION_CLASS: org.jetbrains.kotlin.idea.intentions.SimplifyNegatedBinaryExpressionInspection