Support internal compiler flags (-XX) in facets importing
This commit is contained in:
@@ -46,6 +46,7 @@ public class ArgumentUtils {
|
|||||||
Class<? extends CommonToolArguments> argumentsClass = arguments.getClass();
|
Class<? extends CommonToolArguments> argumentsClass = arguments.getClass();
|
||||||
convertArgumentsToStringList(arguments, argumentsClass.newInstance(), JvmClassMappingKt.getKotlinClass(argumentsClass), result);
|
convertArgumentsToStringList(arguments, argumentsClass.newInstance(), JvmClassMappingKt.getKotlinClass(argumentsClass), result);
|
||||||
result.addAll(arguments.getFreeArgs());
|
result.addAll(arguments.getFreeArgs());
|
||||||
|
result.addAll(arguments.getInternalArguments());
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+48
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
|||||||
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||||
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
|
import org.jetbrains.kotlin.idea.util.projectStructure.sdk
|
||||||
import org.jetbrains.kotlin.test.KotlinTestUtils
|
import org.jetbrains.kotlin.test.KotlinTestUtils
|
||||||
@@ -2102,6 +2103,53 @@ compileTestKotlin {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testInternalArgumentsFacetImporting() {
|
||||||
|
createProjectSubFile(
|
||||||
|
"build.gradle", """
|
||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.50")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:1.2.50"
|
||||||
|
}
|
||||||
|
|
||||||
|
compileKotlin {
|
||||||
|
kotlinOptions.freeCompilerArgs = ["-XXLanguage:+InlineClasses"]
|
||||||
|
kotlinOptions.languageVersion = "1.2"
|
||||||
|
}
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
importProject()
|
||||||
|
|
||||||
|
// Version is indeed 1.2
|
||||||
|
Assert.assertEquals(LanguageVersion.KOTLIN_1_2, facetSettings.languageLevel)
|
||||||
|
|
||||||
|
// We haven't lost internal argument during importing to facet
|
||||||
|
Assert.assertEquals("-XXLanguage:+InlineClasses", facetSettings.compilerSettings?.additionalArguments)
|
||||||
|
|
||||||
|
// Inline classes are enabled even though LV = 1.2
|
||||||
|
Assert.assertEquals(
|
||||||
|
LanguageFeature.State.ENABLED,
|
||||||
|
getModule("project_main").languageVersionSettings.getFeatureSupport(LanguageFeature.InlineClasses)
|
||||||
|
)
|
||||||
|
|
||||||
|
assertAllModulesConfigured()
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertAllModulesConfigured() {
|
private fun assertAllModulesConfigured() {
|
||||||
runReadAction {
|
runReadAction {
|
||||||
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
for (moduleGroup in ModuleSourceRootMap(myProject).groupByBaseModules(myProject.allModules())) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
|||||||
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
import org.jetbrains.kotlin.idea.framework.CommonLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
import org.jetbrains.kotlin.idea.framework.JSLibraryKind
|
||||||
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
import org.jetbrains.kotlin.idea.framework.KotlinSdkType
|
||||||
|
import org.jetbrains.kotlin.idea.project.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
import org.jetbrains.kotlin.idea.refactoring.toPsiFile
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
import org.jetbrains.kotlin.psi.KtFile
|
||||||
import org.junit.Assert
|
import org.junit.Assert
|
||||||
@@ -2716,6 +2717,63 @@ class KotlinMavenImporterTest : MavenImportingTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testInternalArgumentsFacetImporting() {
|
||||||
|
importProject(
|
||||||
|
"""
|
||||||
|
<groupId>test</groupId>
|
||||||
|
<artifactId>project</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-stdlib</artifactId>
|
||||||
|
<version>$kotlinVersion</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<sourceDirectory>src/main/kotlin</sourceDirectory>
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.jetbrains.kotlin</groupId>
|
||||||
|
<artifactId>kotlin-maven-plugin</artifactId>
|
||||||
|
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>compile</id>
|
||||||
|
<phase>compile</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>compile</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<languageVersion>1.2</languageVersion>
|
||||||
|
<args>
|
||||||
|
<arg>-XXLanguage:+InlineClasses</arg>
|
||||||
|
</args>
|
||||||
|
<jvmTarget>1.8</jvmTarget>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
assertImporterStatePresent()
|
||||||
|
|
||||||
|
// Check that we haven't lost internal argument during importing to facet
|
||||||
|
Assert.assertEquals("-XXLanguage:+InlineClasses", facetSettings.compilerSettings?.additionalArguments)
|
||||||
|
|
||||||
|
// Check that internal argument influenced LanguageVersionSettings correctly
|
||||||
|
Assert.assertEquals(
|
||||||
|
LanguageFeature.State.ENABLED,
|
||||||
|
getModule("project").languageVersionSettings.getFeatureSupport(LanguageFeature.InlineClasses)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun assertImporterStatePresent() {
|
private fun assertImporterStatePresent() {
|
||||||
assertNotNull("Kotlin importer component is not present", myTestFixture.module.getComponent(KotlinImporterComponent::class.java))
|
assertNotNull("Kotlin importer component is not present", myTestFixture.module.getComponent(KotlinImporterComponent::class.java))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user