Kotlin Facet: Convert paths to OS-independent form
#KT-17223 Fixed
Original commit: 6bf23d5e02
This commit is contained in:
@@ -16,12 +16,12 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.config
|
package org.jetbrains.kotlin.config
|
||||||
|
|
||||||
|
import com.intellij.util.PathUtil
|
||||||
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter
|
import com.intellij.util.xmlb.SkipDefaultsSerializationFilter
|
||||||
import com.intellij.util.xmlb.XmlSerializer
|
import com.intellij.util.xmlb.XmlSerializer
|
||||||
import org.jdom.DataConversionException
|
import org.jdom.DataConversionException
|
||||||
import org.jdom.Element
|
import org.jdom.Element
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JSCompilerArguments
|
import org.jetbrains.kotlin.cli.common.arguments.*
|
||||||
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|
||||||
|
|
||||||
fun Element.getOption(name: String) = getChildren("option").firstOrNull { it.getAttribute("name").value == name }
|
fun Element.getOption(name: String) = getChildren("option").firstOrNull { it.getAttribute("name").value == name }
|
||||||
|
|
||||||
@@ -116,6 +116,36 @@ fun deserializeFacetSettings(element: Element): KotlinFacetSettings {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun CommonCompilerArguments.convertPathsToSystemIndependent() {
|
||||||
|
pluginClasspaths?.forEachIndexed { index, s -> pluginClasspaths[index] = PathUtil.toSystemIndependentName(s) }
|
||||||
|
|
||||||
|
when (this) {
|
||||||
|
is K2JVMCompilerArguments -> {
|
||||||
|
destination = PathUtil.toSystemIndependentName(destination)
|
||||||
|
classpath = PathUtil.toSystemIndependentName(classpath)
|
||||||
|
jdkHome = PathUtil.toSystemIndependentName(jdkHome)
|
||||||
|
kotlinHome = PathUtil.toSystemIndependentName(kotlinHome)
|
||||||
|
friendPaths?.forEachIndexed { index, s -> friendPaths[index] = PathUtil.toSystemIndependentName(s) }
|
||||||
|
declarationsOutputPath = PathUtil.toSystemIndependentName(declarationsOutputPath)
|
||||||
|
}
|
||||||
|
|
||||||
|
is K2JSCompilerArguments -> {
|
||||||
|
outputFile = PathUtil.toSystemIndependentName(outputFile)
|
||||||
|
libraries = PathUtil.toSystemIndependentName(libraries)
|
||||||
|
}
|
||||||
|
|
||||||
|
is K2MetadataCompilerArguments -> {
|
||||||
|
destination = PathUtil.toSystemIndependentName(destination)
|
||||||
|
classpath = PathUtil.toSystemIndependentName(classpath)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun CompilerSettings.convertPathsToSystemIndependent() {
|
||||||
|
scriptTemplatesClasspath = PathUtil.toSystemIndependentName(scriptTemplatesClasspath)
|
||||||
|
outputDirectoryForJsLibraryFiles = PathUtil.toSystemIndependentName(outputDirectoryForJsLibraryFiles)
|
||||||
|
}
|
||||||
|
|
||||||
fun KotlinFacetSettings.serializeFacetSettings(element: Element) {
|
fun KotlinFacetSettings.serializeFacetSettings(element: Element) {
|
||||||
val filter = SkipDefaultsSerializationFilter()
|
val filter = SkipDefaultsSerializationFilter()
|
||||||
|
|
||||||
@@ -126,13 +156,15 @@ fun KotlinFacetSettings.serializeFacetSettings(element: Element) {
|
|||||||
if (!useProjectSettings) {
|
if (!useProjectSettings) {
|
||||||
element.setAttribute("useProjectSettings", useProjectSettings.toString())
|
element.setAttribute("useProjectSettings", useProjectSettings.toString())
|
||||||
}
|
}
|
||||||
compilerSettings?.let {
|
compilerSettings?.let { copyBean(it) }?.let {
|
||||||
|
it.convertPathsToSystemIndependent()
|
||||||
Element("compilerSettings").apply {
|
Element("compilerSettings").apply {
|
||||||
XmlSerializer.serializeInto(it, this, filter)
|
XmlSerializer.serializeInto(it, this, filter)
|
||||||
element.addContent(this)
|
element.addContent(this)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
compilerArguments?.let {
|
compilerArguments?.let { copyBean(it) }?.let {
|
||||||
|
it.convertPathsToSystemIndependent()
|
||||||
Element("compilerArguments").apply {
|
Element("compilerArguments").apply {
|
||||||
XmlSerializer.serializeInto(it, this, filter)
|
XmlSerializer.serializeInto(it, this, filter)
|
||||||
element.addContent(this)
|
element.addContent(this)
|
||||||
|
|||||||
Reference in New Issue
Block a user