mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[kotlin] narrow down the highlighting range for foreach parameter unused inspection
^KTIJ-33767 fixed GitOrigin-RevId: 2b5b70fa422dd2b052945744d8e67f0e6f7fc1e4
This commit is contained in:
committed by
intellij-monorepo-bot
parent
3c0c804b94
commit
0cd1da0307
+5
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.idea.base.resources.KotlinBundle
|
||||
import org.jetbrains.kotlin.idea.codeInsight.inspections.shared.ForEachParameterNotUsedInspection.UnusedForEachParameterInfo
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicable.inspections.KotlinApplicableInspectionBase
|
||||
import org.jetbrains.kotlin.idea.codeinsight.api.applicable.inspections.KotlinModCommandQuickFix
|
||||
import org.jetbrains.kotlin.idea.codeinsights.impl.base.applicators.ApplicabilityRanges
|
||||
import org.jetbrains.kotlin.idea.refactoring.moveFunctionLiteralOutsideParentheses
|
||||
import org.jetbrains.kotlin.idea.refactoring.util.setParameterListIfAny
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
@@ -49,6 +50,10 @@ internal class ForEachParameterNotUsedInspection :
|
||||
/* ...fixes = */ *createQuickFixes(element, context).toTypedArray()
|
||||
)
|
||||
|
||||
override fun getApplicableRanges(element: KtCallExpression): List<TextRange> {
|
||||
return ApplicabilityRanges.calleeExpression(element)
|
||||
}
|
||||
|
||||
private fun createQuickFixes(
|
||||
element: KtCallExpression,
|
||||
context: UnusedForEachParameterInfo,
|
||||
|
||||
+5
@@ -1298,6 +1298,11 @@ public abstract class SharedK1LocalInspectionTestGenerated extends AbstractShare
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/normal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("outsideOfApplicableRange.kt")
|
||||
public void testOutsideOfApplicableRange() throws Exception {
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/outsideOfApplicableRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("repeat.kt")
|
||||
public void testRepeat() throws Exception {
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/repeat.kt");
|
||||
|
||||
+5
@@ -1298,6 +1298,11 @@ public abstract class SharedK2LocalInspectionTestGenerated extends AbstractShare
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/normal.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("outsideOfApplicableRange.kt")
|
||||
public void testOutsideOfApplicableRange() throws Exception {
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/outsideOfApplicableRange.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("repeat.kt")
|
||||
public void testRepeat() throws Exception {
|
||||
runTest("../testData/inspectionsLocal/forEachParameterNotUsed/repeat.kt");
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// WITH_STDLIB
|
||||
// PROBLEM: none
|
||||
|
||||
fun test(list: List<String>) {
|
||||
list.forEach {
|
||||
//
|
||||
//<caret>
|
||||
//
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user