Configuration: Setup project settings even if library is not detected

#KT-22305 Fixed
This commit is contained in:
Alexey Sedunov
2018-04-12 16:58:46 +03:00
parent eb14625851
commit 1fb1431257
3 changed files with 41 additions and 8 deletions
@@ -73,6 +73,13 @@ abstract class CustomLibraryDescriptorWithDeferredConfig
}
fun finishLibConfiguration(module: Module, rootModel: ModifiableRootModel) {
configureKotlinSettings(module.project, rootModel.sdk)
KotlinCommonCompilerArgumentsHolder.getInstance(module.project).update {
languageVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
apiVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
}
val library = rootModel.orderEntries().findLibrary { library ->
val libraryPresentationManager = LibraryPresentationManager.getInstance()
val classFiles = library.getFiles(OrderRootType.CLASSES).toList()
@@ -99,13 +106,6 @@ abstract class CustomLibraryDescriptorWithDeferredConfig
}
}
configureKotlinSettings(module.project, rootModel.sdk)
KotlinCommonCompilerArgumentsHolder.getInstance(module.project).update {
languageVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
apiVersionView = VersionView.Specific(LanguageVersion.LATEST_STABLE)
}
collector.showNotification()
}
finally {
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.idea.configuration.BuildSystemType
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
import javax.swing.JComponent
internal class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
override fun getFrameworkType(): FrameworkTypeEx = JavaFrameworkType.instance
override fun createConfigurable(model: FrameworkSupportModel): FrameworkSupportInModuleConfigurable {
@@ -0,0 +1,33 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.idea.configuration
import com.intellij.framework.addSupport.FrameworkSupportInModuleProvider
import com.intellij.ide.util.frameworkSupport.FrameworkSupportProviderTestCase
import junit.framework.TestCase
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.VersionView
import org.jetbrains.kotlin.config.apiVersionView
import org.jetbrains.kotlin.config.languageVersionView
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
import org.jetbrains.kotlin.idea.framework.JSFrameworkSupportProvider
import org.jetbrains.kotlin.idea.framework.JavaFrameworkSupportProvider
class KotlinFrameworkSupportProviderTest : FrameworkSupportProviderTestCase() {
private fun doTest(provider: FrameworkSupportInModuleProvider) {
selectFramework(provider).createLibraryDescription()
addSupport()
with (KotlinCommonCompilerArgumentsHolder.getInstance(module.project).settings) {
TestCase.assertEquals(VersionView.Specific(LanguageVersion.LATEST_STABLE), languageVersionView)
TestCase.assertEquals(VersionView.Specific(LanguageVersion.LATEST_STABLE), apiVersionView)
}
}
fun testJvm() = doTest(JavaFrameworkSupportProvider())
fun testJs() = doTest(JSFrameworkSupportProvider())
}