Minor, inline unneeded JvmDependenciesIndexFactory

This commit is contained in:
Alexander Udalov
2017-06-16 18:02:50 +03:00
parent 0e2e3b3e65
commit fd0658e0f4
2 changed files with 6 additions and 15 deletions
@@ -203,13 +203,14 @@ class KotlinCoreEnvironment private constructor(
)
}
// REPL and kapt2 update classpath dynamically
val indexFactory = JvmUpdateableDependenciesIndexFactory()
val (roots, singleJavaFileRoots) =
initialRoots.partition { (file) -> file.isDirectory || file.extension != JavaFileType.DEFAULT_EXTENSION }
rootsIndex = indexFactory.makeIndexFor(roots)
updateClasspathFromRootsIndex(rootsIndex)
// REPL and kapt2 update classpath dynamically
rootsIndex = JvmDependenciesDynamicCompoundIndex().apply {
addIndex(JvmDependenciesIndexImpl(roots))
updateClasspathFromRootsIndex(this)
}
(ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl).initialize(
rootsIndex,
@@ -48,13 +48,3 @@ data class JavaRoot(val file: VirtualFile, val type: RootType, val prefixFqName:
val SourceAndBinary: Set<RootType> = EnumSet.of(RootType.BINARY, RootType.SOURCE)
}
}
interface JvmDependenciesIndexFactory<out T : JvmDependenciesIndex> {
fun makeIndexFor(roots: List<JavaRoot>): T
}
class JvmUpdateableDependenciesIndexFactory : JvmDependenciesIndexFactory<JvmDependenciesDynamicCompoundIndex> {
override fun makeIndexFor(roots: List<JavaRoot>) = JvmDependenciesDynamicCompoundIndex().apply {
addIndex(JvmDependenciesIndexImpl(roots))
}
}