Cleanup KotlinCoreEnvironment and usages
Remove unused API, weaken declaration visibility, reformat
This commit is contained in:
@@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm.compiler
|
package org.jetbrains.kotlin.cli.jvm.compiler
|
||||||
|
|
||||||
import com.google.common.collect.Sets
|
|
||||||
import com.intellij.codeInsight.ContainerProvider
|
import com.intellij.codeInsight.ContainerProvider
|
||||||
import com.intellij.codeInsight.ExternalAnnotationsManager
|
import com.intellij.codeInsight.ExternalAnnotationsManager
|
||||||
import com.intellij.codeInsight.InferredAnnotationsManager
|
import com.intellij.codeInsight.InferredAnnotationsManager
|
||||||
@@ -29,7 +28,6 @@ import com.intellij.ide.highlighter.JavaFileType
|
|||||||
import com.intellij.ide.plugins.PluginManagerCore
|
import com.intellij.ide.plugins.PluginManagerCore
|
||||||
import com.intellij.lang.MetaLanguage
|
import com.intellij.lang.MetaLanguage
|
||||||
import com.intellij.lang.java.JavaParserDefinition
|
import com.intellij.lang.java.JavaParserDefinition
|
||||||
import com.intellij.mock.MockApplication
|
|
||||||
import com.intellij.openapi.Disposable
|
import com.intellij.openapi.Disposable
|
||||||
import com.intellij.openapi.application.ApplicationManager
|
import com.intellij.openapi.application.ApplicationManager
|
||||||
import com.intellij.openapi.application.TransactionGuard
|
import com.intellij.openapi.application.TransactionGuard
|
||||||
@@ -113,7 +111,6 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
configuration: CompilerConfiguration,
|
configuration: CompilerConfiguration,
|
||||||
configFiles: EnvironmentConfigFiles
|
configFiles: EnvironmentConfigFiles
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val projectEnvironment: JavaCoreProjectEnvironment = object : KotlinCoreProjectEnvironment(parentDisposable, applicationEnvironment) {
|
private val projectEnvironment: JavaCoreProjectEnvironment = object : KotlinCoreProjectEnvironment(parentDisposable, applicationEnvironment) {
|
||||||
override fun preregisterServices() {
|
override fun preregisterServices() {
|
||||||
registerProjectExtensionPoints(Extensions.getArea(project))
|
registerProjectExtensionPoints(Extensions.getArea(project))
|
||||||
@@ -141,6 +138,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
super.registerJavaPsiFacade()
|
super.registerJavaPsiFacade()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val sourceFiles = mutableListOf<KtFile>()
|
private val sourceFiles = mutableListOf<KtFile>()
|
||||||
private val rootsIndex: JvmDependenciesDynamicCompoundIndex
|
private val rootsIndex: JvmDependenciesDynamicCompoundIndex
|
||||||
private val packagePartProviders = mutableListOf<JvmPackagePartProvider>()
|
private val packagePartProviders = mutableListOf<JvmPackagePartProvider>()
|
||||||
@@ -152,9 +150,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
|
|
||||||
init {
|
init {
|
||||||
PersistentFSConstants.setMaxIntellisenseFileSize(FileUtilRt.LARGE_FOR_CONTENT_LOADING)
|
PersistentFSConstants.setMaxIntellisenseFileSize(FileUtilRt.LARGE_FOR_CONTENT_LOADING)
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
val project = projectEnvironment.project
|
val project = projectEnvironment.project
|
||||||
|
|
||||||
ExpressionCodegenExtension.registerExtensionPoint(project)
|
ExpressionCodegenExtension.registerExtensionPoint(project)
|
||||||
@@ -224,6 +220,10 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)
|
val finderFactory = CliVirtualFileFinderFactory(rootsIndex)
|
||||||
project.registerService(MetadataFinderFactory::class.java, finderFactory)
|
project.registerService(MetadataFinderFactory::class.java, finderFactory)
|
||||||
project.registerService(VirtualFileFinderFactory::class.java, finderFactory)
|
project.registerService(VirtualFileFinderFactory::class.java, finderFactory)
|
||||||
|
|
||||||
|
project.putUserData(APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY, fun(roots: List<File>) {
|
||||||
|
updateClasspath(roots.map { JavaSourceRoot(it, null) })
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun createPackagePartProvider(scope: GlobalSearchScope): JvmPackagePartProvider {
|
fun createPackagePartProvider(scope: GlobalSearchScope): JvmPackagePartProvider {
|
||||||
@@ -260,15 +260,10 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
private val applicationEnvironment: CoreApplicationEnvironment
|
private val applicationEnvironment: CoreApplicationEnvironment
|
||||||
get() = projectEnvironment.environment
|
get() = projectEnvironment.environment
|
||||||
|
|
||||||
val application: MockApplication
|
|
||||||
get() = applicationEnvironment.application
|
|
||||||
|
|
||||||
val project: Project
|
val project: Project
|
||||||
get() = projectEnvironment.project
|
get() = projectEnvironment.project
|
||||||
|
|
||||||
val sourceLinesOfCode: Int by lazy { countLinesOfCode(sourceFiles) }
|
internal fun countLinesOfCode(sourceFiles: List<KtFile>): Int =
|
||||||
|
|
||||||
fun countLinesOfCode(sourceFiles: List<KtFile>): Int =
|
|
||||||
sourceFiles.sumBy { sourceFile ->
|
sourceFiles.sumBy { sourceFile ->
|
||||||
val text = sourceFile.text
|
val text = sourceFile.text
|
||||||
StringUtil.getLineBreakCount(text) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1)
|
StringUtil.getLineBreakCount(text) + (if (StringUtil.endsWithLineBreak(text)) 0 else 1)
|
||||||
@@ -280,15 +275,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val appendJavaSourceRootsHandler = fun(roots: List<File>) {
|
internal fun updateClasspath(contentRoots: List<ContentRoot>): List<File>? {
|
||||||
updateClasspath(roots.map { JavaSourceRoot(it, null) })
|
|
||||||
}
|
|
||||||
|
|
||||||
init {
|
|
||||||
project.putUserData(APPEND_JAVA_SOURCE_ROOTS_HANDLER_KEY, appendJavaSourceRootsHandler)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateClasspath(contentRoots: List<ContentRoot>): List<File>? {
|
|
||||||
val newRoots = classpathRootsResolver.convertClasspathRoots(contentRoots)
|
val newRoots = classpathRootsResolver.convertClasspathRoots(contentRoots)
|
||||||
|
|
||||||
for (packagePartProvider in packagePartProviders) {
|
for (packagePartProvider in packagePartProviders) {
|
||||||
@@ -297,15 +284,13 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
|
|
||||||
return rootsIndex.addNewIndexForRoots(newRoots)?.let { newIndex ->
|
return rootsIndex.addNewIndexForRoots(newRoots)?.let { newIndex ->
|
||||||
updateClasspathFromRootsIndex(newIndex)
|
updateClasspathFromRootsIndex(newIndex)
|
||||||
newIndex.indexedRoots.mapNotNull { (file) -> File(file.path.substringBefore(URLUtil.JAR_SEPARATOR)) }.toList()
|
newIndex.indexedRoots.mapNotNull { (file) ->
|
||||||
|
VfsUtilCore.virtualToIoFile(VfsUtilCore.getVirtualFileForJar(file) ?: file)
|
||||||
|
}.toList()
|
||||||
}.orEmpty()
|
}.orEmpty()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Suppress("unused") // used externally
|
private fun contentRootToVirtualFile(root: JvmContentRoot): VirtualFile? {
|
||||||
@Deprecated("Use updateClasspath() instead.", ReplaceWith("updateClasspath(files)"))
|
|
||||||
fun tryUpdateClasspath(files: Iterable<File>): List<File>? = updateClasspath(files.map(::JvmClasspathRoot))
|
|
||||||
|
|
||||||
fun contentRootToVirtualFile(root: JvmContentRoot): VirtualFile? {
|
|
||||||
return when (root) {
|
return when (root) {
|
||||||
is JvmClasspathRoot -> if (root.file.isFile) findJarRoot(root) else findLocalFile(root)
|
is JvmClasspathRoot -> if (root.file.isFile) findJarRoot(root) else findLocalFile(root)
|
||||||
is JavaSourceRoot -> findLocalFile(root)
|
is JavaSourceRoot -> findLocalFile(root)
|
||||||
@@ -316,20 +301,18 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
internal fun findLocalFile(path: String) = applicationEnvironment.localFileSystem.findFileByPath(path)
|
internal fun findLocalFile(path: String) = applicationEnvironment.localFileSystem.findFileByPath(path)
|
||||||
|
|
||||||
private fun findLocalFile(root: JvmContentRoot): VirtualFile? {
|
private fun findLocalFile(root: JvmContentRoot): VirtualFile? {
|
||||||
val path = root.file
|
return findLocalFile(root.file.absolutePath).also {
|
||||||
val localFile = findLocalFile(path.absolutePath)
|
if (it == null) {
|
||||||
if (localFile == null) {
|
report(STRONG_WARNING, "Classpath entry points to a non-existent location: ${root.file}")
|
||||||
report(STRONG_WARNING, "Classpath entry points to a non-existent location: $path")
|
}
|
||||||
return null
|
|
||||||
}
|
}
|
||||||
return localFile
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun findJarRoot(root: JvmClasspathRoot): VirtualFile? =
|
private fun findJarRoot(root: JvmClasspathRoot): VirtualFile? =
|
||||||
applicationEnvironment.jarFileSystem.findFileByPath("${root.file}${URLUtil.JAR_SEPARATOR}")
|
applicationEnvironment.jarFileSystem.findFileByPath("${root.file}${URLUtil.JAR_SEPARATOR}")
|
||||||
|
|
||||||
private fun getSourceRootsCheckingForDuplicates(): Collection<String> {
|
private fun getSourceRootsCheckingForDuplicates(): Collection<String> {
|
||||||
val uniqueSourceRoots = Sets.newLinkedHashSet<String>()
|
val uniqueSourceRoots = linkedSetOf<String>()
|
||||||
|
|
||||||
configuration.kotlinSourceRoots.forEach { path ->
|
configuration.kotlinSourceRoots.forEach { path ->
|
||||||
if (!uniqueSourceRoots.add(path)) {
|
if (!uniqueSourceRoots.add(path)) {
|
||||||
@@ -403,7 +386,9 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
// used in the daemon for jar cache cleanup
|
// used in the daemon for jar cache cleanup
|
||||||
val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment
|
val applicationEnvironment: JavaCoreApplicationEnvironment? get() = ourApplicationEnvironment
|
||||||
|
|
||||||
private fun getOrCreateApplicationEnvironmentForProduction(configuration: CompilerConfiguration, configFilePaths: List<String>): JavaCoreApplicationEnvironment {
|
private fun getOrCreateApplicationEnvironmentForProduction(
|
||||||
|
configuration: CompilerConfiguration, configFilePaths: List<String>
|
||||||
|
): JavaCoreApplicationEnvironment {
|
||||||
synchronized (APPLICATION_LOCK) {
|
synchronized (APPLICATION_LOCK) {
|
||||||
if (ourApplicationEnvironment != null)
|
if (ourApplicationEnvironment != null)
|
||||||
return ourApplicationEnvironment!!
|
return ourApplicationEnvironment!!
|
||||||
@@ -420,7 +405,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun disposeApplicationEnvironment() {
|
private fun disposeApplicationEnvironment() {
|
||||||
synchronized (APPLICATION_LOCK) {
|
synchronized (APPLICATION_LOCK) {
|
||||||
val environment = ourApplicationEnvironment ?: return
|
val environment = ourApplicationEnvironment ?: return
|
||||||
ourApplicationEnvironment = null
|
ourApplicationEnvironment = null
|
||||||
@@ -429,7 +414,9 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createApplicationEnvironment(parentDisposable: Disposable, configuration: CompilerConfiguration, configFilePaths: List<String>): JavaCoreApplicationEnvironment {
|
private fun createApplicationEnvironment(
|
||||||
|
parentDisposable: Disposable, configuration: CompilerConfiguration, configFilePaths: List<String>
|
||||||
|
): JavaCoreApplicationEnvironment {
|
||||||
Extensions.cleanRootArea(parentDisposable)
|
Extensions.cleanRootArea(parentDisposable)
|
||||||
registerAppExtensionPoints()
|
registerAppExtensionPoints()
|
||||||
val applicationEnvironment = object : JavaCoreApplicationEnvironment(parentDisposable) {
|
val applicationEnvironment = object : JavaCoreApplicationEnvironment(parentDisposable) {
|
||||||
@@ -491,7 +478,9 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// made public for Upsource
|
// made public for Upsource
|
||||||
@JvmStatic fun registerApplicationServices(applicationEnvironment: JavaCoreApplicationEnvironment) {
|
@Suppress("MemberVisibilityCanPrivate")
|
||||||
|
@JvmStatic
|
||||||
|
fun registerApplicationServices(applicationEnvironment: JavaCoreApplicationEnvironment) {
|
||||||
with(applicationEnvironment) {
|
with(applicationEnvironment) {
|
||||||
registerFileType(KotlinFileType.INSTANCE, "kt")
|
registerFileType(KotlinFileType.INSTANCE, "kt")
|
||||||
registerFileType(KotlinFileType.INSTANCE, KotlinParserDefinition.STD_SCRIPT_SUFFIX)
|
registerFileType(KotlinFileType.INSTANCE, KotlinParserDefinition.STD_SCRIPT_SUFFIX)
|
||||||
@@ -508,7 +497,8 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// made public for Upsource
|
// made public for Upsource
|
||||||
@JvmStatic fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment) {
|
@JvmStatic
|
||||||
|
fun registerProjectServices(projectEnvironment: JavaCoreProjectEnvironment) {
|
||||||
with (projectEnvironment.project) {
|
with (projectEnvironment.project) {
|
||||||
val kotlinScriptDefinitionProvider = KotlinScriptDefinitionProvider()
|
val kotlinScriptDefinitionProvider = KotlinScriptDefinitionProvider()
|
||||||
registerService(KotlinScriptDefinitionProvider::class.java, kotlinScriptDefinitionProvider)
|
registerService(KotlinScriptDefinitionProvider::class.java, kotlinScriptDefinitionProvider)
|
||||||
@@ -518,7 +508,7 @@ class KotlinCoreEnvironment private constructor(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun registerProjectServicesForCLI(projectEnvironment: JavaCoreProjectEnvironment) {
|
private fun registerProjectServicesForCLI(@Suppress("UNUSED_PARAMETER") projectEnvironment: JavaCoreProjectEnvironment) {
|
||||||
/**
|
/**
|
||||||
* Note that Kapt may restart code analysis process, and CLI services should be aware of that.
|
* Note that Kapt may restart code analysis process, and CLI services should be aware of that.
|
||||||
* Use PsiManager.getModificationTracker() to ensure that all the data you cached is still valid.
|
* Use PsiManager.getModificationTracker() to ensure that all the data you cached is still valid.
|
||||||
|
|||||||
+6
-7
@@ -360,24 +360,24 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun analyze(environment: KotlinCoreEnvironment, targetDescription: String?): AnalysisResult? {
|
private fun analyze(environment: KotlinCoreEnvironment, targetDescription: String?): AnalysisResult? {
|
||||||
|
val sourceFiles = environment.getSourceFiles()
|
||||||
val collector = environment.messageCollector
|
val collector = environment.messageCollector
|
||||||
|
|
||||||
val analysisStart = PerformanceCounter.currentTime()
|
val analysisStart = PerformanceCounter.currentTime()
|
||||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector)
|
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector)
|
||||||
analyzerWithCompilerReport.analyzeAndReport(
|
analyzerWithCompilerReport.analyzeAndReport(sourceFiles, object : AnalyzerWithCompilerReport.Analyzer {
|
||||||
environment.getSourceFiles(), object : AnalyzerWithCompilerReport.Analyzer {
|
|
||||||
override fun analyze(): AnalysisResult {
|
override fun analyze(): AnalysisResult {
|
||||||
val project = environment.project
|
val project = environment.project
|
||||||
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNull { module ->
|
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNull { module ->
|
||||||
environment.findLocalFile(module.getOutputDirectory())
|
environment.findLocalFile(module.getOutputDirectory())
|
||||||
}.orEmpty()
|
}.orEmpty()
|
||||||
val sourcesOnly = TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, environment.getSourceFiles())
|
val sourcesOnly = TopDownAnalyzerFacadeForJVM.newModuleSearchScope(project, sourceFiles)
|
||||||
// To support partial and incremental compilation, we add the scope which contains binaries from output directories
|
// To support partial and incremental compilation, we add the scope which contains binaries from output directories
|
||||||
// of the compiled modules (.class) to the list of scopes of the source module
|
// of the compiled modules (.class) to the list of scopes of the source module
|
||||||
val scope = if (moduleOutputs.isEmpty()) sourcesOnly else sourcesOnly.uniteWith(DirectoriesScope(project, moduleOutputs))
|
val scope = if (moduleOutputs.isEmpty()) sourcesOnly else sourcesOnly.uniteWith(DirectoriesScope(project, moduleOutputs))
|
||||||
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
return TopDownAnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(
|
||||||
project,
|
project,
|
||||||
environment.getSourceFiles(),
|
sourceFiles,
|
||||||
CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(),
|
CliLightClassGenerationSupport.NoScopeRecordCliBindingTrace(),
|
||||||
environment.configuration,
|
environment.configuration,
|
||||||
environment::createPackagePartProvider,
|
environment::createPackagePartProvider,
|
||||||
@@ -392,12 +392,11 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
|
|
||||||
val analysisNanos = PerformanceCounter.currentTime() - analysisStart
|
val analysisNanos = PerformanceCounter.currentTime() - analysisStart
|
||||||
|
|
||||||
val sourceLinesOfCode = environment.sourceLinesOfCode
|
val sourceLinesOfCode = environment.countLinesOfCode(sourceFiles)
|
||||||
val numberOfFiles = environment.getSourceFiles().size
|
|
||||||
val time = TimeUnit.NANOSECONDS.toMillis(analysisNanos)
|
val time = TimeUnit.NANOSECONDS.toMillis(analysisNanos)
|
||||||
val speed = sourceLinesOfCode.toFloat() * 1000 / time
|
val speed = sourceLinesOfCode.toFloat() * 1000 / time
|
||||||
|
|
||||||
val message = "ANALYZE: $numberOfFiles files ($sourceLinesOfCode lines) ${targetDescription ?: ""}" +
|
val message = "ANALYZE: ${sourceFiles.size} files ($sourceLinesOfCode lines) ${targetDescription ?: ""}" +
|
||||||
"in $time ms - ${"%.3f".format(speed)} loc/s"
|
"in $time ms - ${"%.3f".format(speed)} loc/s"
|
||||||
|
|
||||||
K2JVMCompiler.reportPerf(environment.configuration, message)
|
K2JVMCompiler.reportPerf(environment.configuration, message)
|
||||||
|
|||||||
@@ -13,17 +13,18 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.cli.jvm
|
package org.jetbrains.kotlin.cli.jvm
|
||||||
|
|
||||||
import com.intellij.core.CoreJavaFileManager
|
import com.intellij.core.CoreJavaFileManager
|
||||||
import com.intellij.openapi.components.ServiceManager
|
import com.intellij.openapi.components.ServiceManager
|
||||||
|
import com.intellij.openapi.vfs.StandardFileSystems
|
||||||
import com.intellij.psi.search.GlobalSearchScope
|
import com.intellij.psi.search.GlobalSearchScope
|
||||||
import junit.framework.TestCase
|
import junit.framework.TestCase
|
||||||
import org.intellij.lang.annotations.Language
|
import org.intellij.lang.annotations.Language
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
import org.jetbrains.kotlin.cli.jvm.config.JavaSourceRoot
|
|
||||||
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
|
import org.jetbrains.kotlin.cli.jvm.index.JavaRoot
|
||||||
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndexImpl
|
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndexImpl
|
||||||
import org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex
|
import org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex
|
||||||
@@ -38,7 +39,7 @@ import org.jetbrains.kotlin.test.TestJdkKind
|
|||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
||||||
private var javaFilesDir: File? = null
|
private lateinit var javaFilesDir: File
|
||||||
|
|
||||||
fun testCommon() {
|
fun testCommon() {
|
||||||
val manager = configureManager(
|
val manager = configureManager(
|
||||||
@@ -184,7 +185,7 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
|||||||
javaFilesDir = KotlinTestUtils.tmpDir("java-file-manager-test")
|
javaFilesDir = KotlinTestUtils.tmpDir("java-file-manager-test")
|
||||||
|
|
||||||
val configuration = KotlinTestUtils.newConfiguration(
|
val configuration = KotlinTestUtils.newConfiguration(
|
||||||
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), listOf(javaFilesDir!!)
|
ConfigurationKind.JDK_ONLY, TestJdkKind.MOCK_JDK, emptyList(), listOf(javaFilesDir)
|
||||||
)
|
)
|
||||||
|
|
||||||
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
return KotlinCoreEnvironment.createForTests(testRootDisposable, configuration, EnvironmentConfigFiles.JVM_CONFIG_FILES)
|
||||||
@@ -200,7 +201,7 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
|||||||
val coreJavaFileFinder = VirtualFileFinder.SERVICE.getInstance(project)
|
val coreJavaFileFinder = VirtualFileFinder.SERVICE.getInstance(project)
|
||||||
val coreJavaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
|
val coreJavaFileManager = ServiceManager.getService(project, CoreJavaFileManager::class.java) as KotlinCliJavaFileManagerImpl
|
||||||
|
|
||||||
val root = environment.contentRootToVirtualFile(JavaSourceRoot(javaFilesDir!!, null))!!
|
val root = StandardFileSystems.local().findFileByPath(javaFilesDir.path)!!
|
||||||
coreJavaFileManager.initialize(
|
coreJavaFileManager.initialize(
|
||||||
JvmDependenciesIndexImpl(listOf(JavaRoot(root, JavaRoot.RootType.SOURCE))),
|
JvmDependenciesIndexImpl(listOf(JavaRoot(root, JavaRoot.RootType.SOURCE))),
|
||||||
SingleJavaFileRootsIndex(emptyList()),
|
SingleJavaFileRootsIndex(emptyList()),
|
||||||
@@ -223,7 +224,7 @@ class KotlinCliJavaFileManagerTest : KotlinTestWithEnvironment() {
|
|||||||
TestCase.assertNotNull("Could not find: $stringRequest", foundByString)
|
TestCase.assertNotNull("Could not find: $stringRequest", foundByString)
|
||||||
|
|
||||||
TestCase.assertEquals(foundByClassId, foundByString)
|
TestCase.assertEquals(foundByClassId, foundByString)
|
||||||
TestCase.assertEquals("Found ${foundByClassId!!.qualifiedName} instead of $packageFQName", packageFQName + "." + classFqName,
|
TestCase.assertEquals("Found ${foundByClassId.qualifiedName} instead of $packageFQName", packageFQName + "." + classFqName,
|
||||||
foundByClassId.qualifiedName)
|
foundByClassId.qualifiedName)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user