Unused symbol: do not search for internal member light methods
Use direct references search instead So #KT-19811 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
4428798c61
commit
5c4e034171
@@ -274,7 +274,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration is KtCallableDeclaration) {
|
if (declaration is KtCallableDeclaration && !declaration.hasModifier(KtTokens.INTERNAL_KEYWORD)) {
|
||||||
val lightMethods = declaration.toLightMethods()
|
val lightMethods = declaration.toLightMethods()
|
||||||
if (lightMethods.isNotEmpty()) {
|
if (lightMethods.isNotEmpty()) {
|
||||||
return lightMethods.any { method ->
|
return lightMethods.any { method ->
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
// PROBLEM: none
|
||||||
|
|
||||||
|
class Foo {
|
||||||
|
fun test() {
|
||||||
|
abacaba("")
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun <caret>abacaba(s: String): String = s
|
||||||
|
}
|
||||||
@@ -1842,6 +1842,21 @@ public class LocalInspectionTestGenerated extends AbstractLocalInspectionTest {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("idea/testData/inspectionsLocal/unusedSymbol")
|
||||||
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
public static class UnusedSymbol extends AbstractLocalInspectionTest {
|
||||||
|
public void testAllFilesPresentInUnusedSymbol() throws Exception {
|
||||||
|
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/inspectionsLocal/unusedSymbol"), Pattern.compile("^([\\w\\-_]+)\\.kt$"), TargetBackend.ANY, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("internal.kt")
|
||||||
|
public void testInternal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/inspectionsLocal/unusedSymbol/internal.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/inspectionsLocal/useExpressionBody")
|
@TestMetadata("idea/testData/inspectionsLocal/useExpressionBody")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@RunWith(JUnit3RunnerWithInners.class)
|
@RunWith(JUnit3RunnerWithInners.class)
|
||||||
|
|||||||
Reference in New Issue
Block a user