Redundant SAM-constructor: highlight nested class name with outer class

So #KT-11156 Fixed
This commit is contained in:
Toshiaki Kameyama
2018-04-17 07:57:10 +03:00
committed by Mikhail Glukhikh
parent 204c68070a
commit 13356d32fd
6 changed files with 31 additions and 1 deletions
@@ -51,7 +51,7 @@ class RedundantSamConstructorInspection : AbstractKotlinInspection() {
if (single != null) {
val calleeExpression = single.calleeExpression ?: return
val problemDescriptor = holder.manager.createProblemDescriptor(
calleeExpression,
single.getQualifiedExpressionForSelectorOrThis(),
single.typeArgumentList ?: calleeExpression,
"Redundant SAM-constructor",
ProblemHighlightType.LIKE_UNUSED_SYMBOL,
@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.RedundantSamConstructorInspection
@@ -0,0 +1,8 @@
public class Foo {
public interface Bar {
void baz();
}
public static void foo(Bar bar) {
bar.baz();
}
}
@@ -0,0 +1,3 @@
fun test() {
Foo.foo(<caret>Foo.Bar { })
}
@@ -0,0 +1,3 @@
fun test() {
Foo.foo({ })
}
@@ -3117,6 +3117,21 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
}
}
@TestMetadata("idea/testData/inspectionsLocal/redundantSamConstructor")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class RedundantSamConstructor extends AbstractLocalInspectionTest {
public void testAllFilesPresentInRedundantSamConstructor() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/redundantSamConstructor"), Pattern.compile("^([\\w\\-_]+)\\.(kt|kts)$"), TargetBackend.ANY, true);
}
@TestMetadata("nestedInterface.kt")
public void testNestedInterface() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/redundantSamConstructor/nestedInterface.kt");
doTest(fileName);
}
}
@TestMetadata("idea/testData/inspectionsLocal/redundantSemicolon")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)