Unused symbol: do not search for internal member light methods

Use direct references search instead
So #KT-19811 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-09-08 16:43:26 +03:00
committed by Mikhail Glukhikh
parent 4428798c61
commit 5c4e034171
4 changed files with 26 additions and 1 deletions

View File

@@ -274,7 +274,7 @@ class UnusedSymbolInspection : AbstractKotlinInspection() {
return false
}
if (declaration is KtCallableDeclaration) {
if (declaration is KtCallableDeclaration && !declaration.hasModifier(KtTokens.INTERNAL_KEYWORD)) {
val lightMethods = declaration.toLightMethods()
if (lightMethods.isNotEmpty()) {
return lightMethods.any { method ->

View File

@@ -0,0 +1 @@
org.jetbrains.kotlin.idea.inspections.UnusedSymbolInspection

View File

@@ -0,0 +1,9 @@
// PROBLEM: none
class Foo {
fun test() {
abacaba("")
}
internal fun <caret>abacaba(s: String): String = s
}

View File

@@ -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")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)