Misc: Fix deserialization of CommonCompilerArguments.freeArgs
#KT-20938 Fixed
This commit is contained in:
+7
-1
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.compiler.configuration
|
||||
|
||||
import com.intellij.openapi.components.PersistentStateComponent
|
||||
import com.intellij.openapi.components.StoragePathMacros.PROJECT_CONFIG_DIR
|
||||
import com.intellij.util.ReflectionUtil
|
||||
import com.intellij.util.xmlb.SkipDefaultValuesSerializationFilters
|
||||
import com.intellij.util.xmlb.XmlSerializer
|
||||
import org.jdom.Element
|
||||
@@ -64,7 +65,12 @@ abstract class BaseKotlinCompilerSettings<T : Freezable> protected constructor()
|
||||
override fun getState() = XmlSerializer.serialize(_settings, SKIP_DEFAULT_VALUES)
|
||||
|
||||
override fun loadState(state: Element) {
|
||||
_settings = XmlSerializer.deserialize(state, _settings.javaClass)
|
||||
_settings = ReflectionUtil.newInstance(_settings.javaClass).apply {
|
||||
if (this is CommonCompilerArguments) {
|
||||
freeArgs = ArrayList()
|
||||
}
|
||||
XmlSerializer.deserializeInto(this, state)
|
||||
}
|
||||
}
|
||||
|
||||
public override fun clone(): Any = super.clone()
|
||||
|
||||
@@ -58,8 +58,7 @@ private fun readV1Config(element: Element): KotlinFacetSettings {
|
||||
val jvmArgumentsElement = compilerInfoElement?.getOptionBody("k2jvmCompilerArguments")
|
||||
val jsArgumentsElement = compilerInfoElement?.getOptionBody("k2jsCompilerArguments")
|
||||
|
||||
val compilerArguments = targetPlatform.createCompilerArguments()
|
||||
compilerArguments.freeArgs = ArrayList()
|
||||
val compilerArguments = targetPlatform.createCompilerArguments { freeArgs = ArrayList() }
|
||||
|
||||
commonArgumentsElement?.let { XmlSerializer.deserializeInto(compilerArguments, it) }
|
||||
when (compilerArguments) {
|
||||
@@ -105,7 +104,7 @@ private fun readV2AndLaterConfig(element: Element): KotlinFacetSettings {
|
||||
XmlSerializer.deserializeInto(compilerSettings!!, it)
|
||||
}
|
||||
element.getChild("compilerArguments")?.let {
|
||||
compilerArguments = platformKind.createCompilerArguments()
|
||||
compilerArguments = platformKind.createCompilerArguments { freeArgs = ArrayList() }
|
||||
XmlSerializer.deserializeInto(compilerArguments!!, it)
|
||||
}
|
||||
testOutputPath = element.getChild("testOutputPath")?.let {
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="JAVA_MODULE" version="4">
|
||||
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||
<exclude-output />
|
||||
<content url="file://$MODULE_DIR$">
|
||||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" name="KotlinJavaRuntime (2)" level="project" />
|
||||
</component>
|
||||
</module>
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="CompilerConfiguration">
|
||||
<resourceExtensions />
|
||||
<wildcardResourcePatterns>
|
||||
<entry name="!?*.java" />
|
||||
<entry name="!?*.form" />
|
||||
<entry name="!?*.class" />
|
||||
<entry name="!?*.groovy" />
|
||||
<entry name="!?*.scala" />
|
||||
<entry name="!?*.flex" />
|
||||
<entry name="!?*.kt" />
|
||||
<entry name="!?*.clj" />
|
||||
<entry name="!?*.aj" />
|
||||
</wildcardResourcePatterns>
|
||||
<annotationProcessing>
|
||||
<profile default="true" name="Default" enabled="false">
|
||||
<processorPath useClasspath="true" />
|
||||
</profile>
|
||||
</annotationProcessing>
|
||||
</component>
|
||||
<component name="CopyrightManager" default="" />
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/module.iml" filepath="$PROJECT_DIR$/module.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||
<output url="file://$PROJECT_DIR$/out" />
|
||||
</component>
|
||||
<component name="libraryTable">
|
||||
<library name="KotlinJavaRuntime (2)">
|
||||
<CLASSES>
|
||||
<root url="jar://$PROJECT_DIR$/../mockRuntime11/kotlin-runtime.jar!/" />
|
||||
</CLASSES>
|
||||
<JAVADOC />
|
||||
<SOURCES>
|
||||
</SOURCES>
|
||||
</library>
|
||||
</component>
|
||||
<component name="KotlinCommonCompilerArguments">
|
||||
<option name="freeArgs">
|
||||
<list>
|
||||
<option value="true" />
|
||||
</list>
|
||||
</option>
|
||||
</component>
|
||||
</project>
|
||||
@@ -30,6 +30,7 @@ import com.intellij.psi.PsiRequiresStatement;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments;
|
||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments;
|
||||
import org.jetbrains.kotlin.config.*;
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder;
|
||||
import org.jetbrains.kotlin.idea.facet.FacetUtilsKt;
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet;
|
||||
import org.jetbrains.kotlin.idea.framework.JsLibraryStdDetectionUtil;
|
||||
@@ -40,6 +41,7 @@ import org.jetbrains.kotlin.resolve.jvm.modules.JavaModuleKt;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.StreamSupport;
|
||||
|
||||
@@ -264,6 +266,13 @@ public class ConfigureKotlinTest extends AbstractConfigureKotlinTest {
|
||||
checkAddStdlibModule();
|
||||
}
|
||||
|
||||
public void testProjectWithFreeArgs() {
|
||||
assertEquals(
|
||||
Collections.singletonList("true"),
|
||||
KotlinCommonCompilerArgumentsHolder.Companion.getInstance(myProject).getSettings().getFreeArgs()
|
||||
);
|
||||
}
|
||||
|
||||
private void checkAddStdlibModule() {
|
||||
doTestOneJavaModule(KotlinWithLibraryConfigurator.FileState.COPY);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user