diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt new file mode 100644 index 00000000000..33def856c4f --- /dev/null +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/coroutines.lib.kt @@ -0,0 +1,44 @@ +package kotlinx.coroutines + +interface Deferred { + suspend fun await(): T +} + +interface CoroutineContext + +object DefaultDispatcher : CoroutineContext + +enum class CoroutineStart { + DEFAULT, + LAZY, + ATOMIC, + UNDISPATCHED +} + +interface Job + +fun async( + context: CoroutineContext = DefaultDispatcher, + start: CoroutineStart = CoroutineStart.DEFAULT, + parent: Job? = null, + f: suspend () -> T +): Deferred { + TODO() +} + +fun runBlocking( + context: CoroutineContext = DefaultDispatcher, + f: suspend () -> T +) { + TODO() +} + +suspend fun withContext( + context: CoroutineContext, + start: CoroutineStart = CoroutineStart.DEFAULT, + f: suspend () -> T +) { + TODO() +} + + diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt index d892a6e11de..af46fe943e7 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { async(ctx) { 42 }.await() } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt.after b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt.after index 68ff62364c1..0e9a5896243 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt.after +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simple.kt.after @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { withContext(ctx) { 42 } } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt index 94329871a8f..5787f7b35e2 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test() { async { 42 }.await() } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt.after b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt.after index 4e1cac7e48f..367bd846556 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt.after +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/simplest.kt.after @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test() { withContext(DefaultDispatcher) { 42 } } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withParent.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withParent.kt index 07858dc80ff..69aea1dc19b 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withParent.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withParent.kt @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { async(parent = null) { 42 }.await() } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt index f1dcb86f5ec..2c4eeb479b4 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt @@ -2,47 +2,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { async(ctx, CoroutineStart.LAZY) { 42 }.await() } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after index 0296cae6f75..647cb453564 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartAndContext.kt.after @@ -2,47 +2,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { withContext(ctx, CoroutineStart.LAZY) { 42 } } \ No newline at end of file diff --git a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartNoContext.kt b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartNoContext.kt index 8ac1d641c9e..1f8510d5c6e 100644 --- a/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartNoContext.kt +++ b/idea/testData/inspectionsLocal/coroutines/redundantAsync/withStartNoContext.kt @@ -3,47 +3,6 @@ package kotlinx.coroutines -interface Deferred { - suspend fun await(): T -} - -interface CoroutineContext - -object DefaultDispatcher : CoroutineContext - -enum class CoroutineStart { - DEFAULT, - LAZY, - ATOMIC, - UNDISPATCHED -} - -interface Job - -fun async( - context: CoroutineContext = DefaultDispatcher, - start: CoroutineStart = CoroutineStart.DEFAULT, - parent: Job? = null, - f: suspend () -> T -): Deferred { - TODO() -} - -fun runBlocking( - context: CoroutineContext = DefaultDispatcher, - f: suspend () -> T -) { - TODO() -} - -suspend fun withContext( - context: CoroutineContext, - start: CoroutineStart = CoroutineStart.DEFAULT, - f: suspend () -> T -) { - TODO() -} - suspend fun test(ctx: CoroutineContext) { async(start = CoroutineStart.LAZY) { 42 }.await() } \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt index 60d129349b8..c532ee0d5a6 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/inspections/AbstractLocalInspectionTest.kt @@ -114,6 +114,14 @@ abstract class AbstractLocalInspectionTest : KotlinLightCodeInsightFixtureTestCa } break } + val parentFile = mainFile.parentFile + if (parentFile != null) { + for (file in parentFile.walkTopDown().maxDepth(1)) { + if (file.name.endsWith(".lib.kt")) { + extraFileNames += file.name + } + } + } myFixture.configureByFiles(*(listOf(mainFile.name) + extraFileNames).toTypedArray()).first()