-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #131 from AntonButov/refactoring-dependencies
add DI
- Loading branch information
Showing
26 changed files
with
336 additions
and
285 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
code-factory-processor/src/main/kotlin/com/code/factory/DI.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package com.code.factory | ||
|
||
import com.code.factory.bridge.BridgeFactory | ||
import com.code.factory.bridge.BridgeFactoryImpl | ||
import com.code.factory.coderesolver.CodeResolver | ||
import com.code.factory.coderesolver.CodeResolverImpl | ||
import com.code.factory.ksp.KspProcessor | ||
import com.code.factory.ksp.PhaseResolver | ||
import com.code.factory.ksp.PhaseResolverImpl | ||
import com.google.devtools.ksp.processing.CodeGenerator | ||
import com.google.devtools.ksp.processing.KSPLogger | ||
import com.google.devtools.ksp.processing.SymbolProcessor | ||
import dagger.Binds | ||
import dagger.BindsInstance | ||
import dagger.Component | ||
import dagger.Module | ||
import javax.inject.Singleton | ||
|
||
@Singleton | ||
@Component(modules = [ProcessorBindModule::class]) | ||
interface ProcessorComponent { | ||
fun getKSPProcessor(): KspProcessor | ||
|
||
@Component.Builder | ||
interface Builder { | ||
@BindsInstance | ||
fun logger(logger: KSPLogger): Builder | ||
|
||
@BindsInstance | ||
fun codeGenerator(codeGenerator: CodeGenerator): Builder | ||
|
||
fun build(): ProcessorComponent | ||
} | ||
} | ||
|
||
@Module | ||
interface ProcessorBindModule { | ||
@Binds | ||
abstract fun provideAllDeclarationFinder(impl: AllDeclarationFinderImpl): AllDeclarationFinder | ||
|
||
@Binds | ||
abstract fun provideCodeResolver(impl: CodeResolverImpl): CodeResolver | ||
|
||
@Binds | ||
abstract fun provideTestCodeFilter(impl: TestCodeFilterImpl): TestCodeFilter | ||
|
||
@Binds | ||
abstract fun provideTestFilesResolver(impl: TestFilesResolverImpl): TestFilesResolver | ||
|
||
@Binds | ||
abstract fun provideCodeFilter(impl: CodeFilterImpl): CodeFilter | ||
|
||
@Binds | ||
abstract fun provideTestSourcePathResolver(impl: TestSourcePathResolverImpl): TestSourcePathResolver | ||
|
||
@Binds | ||
abstract fun provideBasePathProvider(impl: BasePathProviderImpl): BasePathProvider | ||
|
||
@Binds | ||
abstract fun provideCompileChecker(impl: CompileCheckerImpl): CompileChecker | ||
|
||
@Binds | ||
abstract fun provideBridgeFactory(impl: BridgeFactoryImpl): BridgeFactory | ||
|
||
@Binds | ||
abstract fun provideSymbolProcessor(impl: KspProcessor): SymbolProcessor | ||
|
||
@Binds | ||
abstract fun provideInterfaceFinder(impl: InterfaceFinderImpl): InterfaceFinder | ||
|
||
@Binds | ||
abstract fun providePhaseResolver(impl: PhaseResolverImpl): PhaseResolver | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 11 additions & 12 deletions
23
code-factory-processor/src/main/kotlin/com/code/factory/TestFilesResolver.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,21 @@ | ||
package com.code.factory | ||
|
||
import java.io.File | ||
import javax.inject.Inject | ||
|
||
interface TestFilesResolver { | ||
fun getTestFiles(basePath: String): Sequence<File> | ||
} | ||
|
||
fun testFileResolver(): TestFilesResolver { | ||
return TestFilesResolverImpl() | ||
} | ||
|
||
internal class TestFilesResolverImpl : TestFilesResolver { | ||
override fun getTestFiles(basePath: String): Sequence<File> { | ||
return findKtFiles(File(basePath)) | ||
} | ||
class TestFilesResolverImpl | ||
@Inject | ||
constructor() : TestFilesResolver { | ||
override fun getTestFiles(basePath: String): Sequence<File> { | ||
return findKtFiles(File(basePath)) | ||
} | ||
|
||
private fun findKtFiles(directory: File): Sequence<File> { | ||
return directory.walkTopDown() | ||
.filter { it.isFile && it.extension == "kt" } | ||
private fun findKtFiles(directory: File): Sequence<File> { | ||
return directory.walkTopDown() | ||
.filter { it.isFile && it.extension == "kt" } | ||
} | ||
} | ||
} |
Oops, something went wrong.