Skip to content

Commit

Permalink
Testing changes
Browse files Browse the repository at this point in the history
  • Loading branch information
JoelWilcox committed Aug 31, 2023
1 parent 93026e9 commit c193cfb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import com.squareup.anvil.compiler.internal.reference.classAndInnerClassReferenc
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.psi.KtFile
import java.io.File

private var counter = 0
import kotlin.random.Random

fun simpleCodeGenerator(
mapper: CodeGenerator.(clazz: ClassReference.Psi) -> String?
Expand Down Expand Up @@ -78,7 +77,7 @@ fun parseSimpleFileContents(content: String): SimpleFileContents {
?.trim()
?.substringBefore(" ")
}
?: "NewFile${counter++}"
?: "NewFile${Random.nextInt()}"

return SimpleFileContents(
packageName = packageName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,12 +368,9 @@ class ContributesMultibindingGeneratorTest(
package com.squareup.test
import com.squareup.anvil.annotations.ContributesMultibinding
import dagger.MapKey
import javax.inject.Singleton
@ContributesMultibinding(Any::class)
@BindingKey("abc")
@Singleton
@ContributesMultibinding(scope = Any::class)
@BindingKey(value = "abc")
interface ContributingInterface : ParentInterface
""".trimIndent()

Expand All @@ -388,7 +385,7 @@ class ContributesMultibindingGeneratorTest(
}
is AnvilCompilationMode.Ksp -> {
val processor = simpleSymbolProcessor { resolver ->
resolver.getSymbolsWithAnnotation(MergeComponent::class.qualifiedName!!)
resolver.getSymbolsWithAnnotation(mergeComponentFqName.toString(), inDepth = true)
.map { stubContentToGenerate }
.toList()
}
Expand All @@ -408,7 +405,7 @@ class ContributesMultibindingGeneratorTest(
interface ParentInterface
@MergeComponent(Any::class)
@MergeComponent(scope = Any::class)
interface ComponentInterface
""",
mode = localMode
Expand All @@ -426,16 +423,14 @@ class ContributesMultibindingGeneratorTest(
import com.squareup.anvil.annotations.ContributesMultibinding
import dagger.MapKey
import javax.inject.Singleton
interface ParentInterface
@MapKey
annotation class BindingKey1(val value: String)
@ContributesMultibinding(Any::class)
@BindingKey1("abc")
@Singleton
@ContributesMultibinding(scope = Any::class)
@BindingKey1(value = "abc")
interface ContributingInterface : ParentInterface
""".trimIndent()

Expand All @@ -452,7 +447,7 @@ class ContributesMultibindingGeneratorTest(
}
is AnvilCompilationMode.Ksp -> {
val processor = simpleSymbolProcessor { resolver ->
resolver.getSymbolsWithAnnotation(MergeComponent::class.qualifiedName!!)
resolver.getSymbolsWithAnnotation(mergeComponentFqName.toString(), inDepth = true)
.map { stubContentToGenerate }
.toList()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ private class SimpleSymbolProcessor(
val (packageName, fileName) = parseSimpleFileContents(content)

val dependencies = Dependencies(aggregating = false, sources = emptyArray())
val file = env.codeGenerator.createNewFile(dependencies, packageName, "$fileName.kt")
val file = env.codeGenerator.createNewFile(dependencies, packageName, fileName)
// Don't use writeTo(file) because that tries to handle directories under the hood
OutputStreamWriter(file, StandardCharsets.UTF_8)
.buffered()
Expand Down

0 comments on commit c193cfb

Please sign in to comment.