Support JS source map source embedding configuration in IDEA
This commit is contained in:
@@ -130,6 +130,7 @@ class KotlinMavenImporter : MavenImporter(KOTLIN_PLUGIN_GROUP_ID, KOTLIN_PLUGIN_
|
||||
is K2JSCompilerArguments -> {
|
||||
arguments.sourceMap = configuration?.getChild("sourceMap")?.text?.trim()?.toBoolean() ?: false
|
||||
arguments.sourceMapPrefix = configuration?.getChild("sourceMapPrefix")?.text?.trim() ?: ""
|
||||
arguments.sourceMapEmbedSources = configuration?.getChild("sourceMapEmbedSources")?.text?.trim() ?: "inlining"
|
||||
arguments.outputFile = configuration?.getChild("outputFile")?.text
|
||||
arguments.metaInfo = configuration?.getChild("metaInfo")?.text?.trim()?.toBoolean() ?: false
|
||||
arguments.moduleKind = configuration?.getChild("moduleKind")?.text
|
||||
|
||||
+25
-11
@@ -3,7 +3,7 @@
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="12" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="350" y="20" width="920" height="1119"/>
|
||||
<xy x="350" y="20" width="920" height="1171"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="empty">
|
||||
@@ -15,7 +15,7 @@
|
||||
<grid row="11" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="98e8a" binding="k2jsPanel" layout-manager="GridLayoutManager" row-count="7" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="98e8a" binding="k2jsPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="8" column="0" row-span="1" col-span="2" vsize-policy="3" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="true"/>
|
||||
@@ -30,7 +30,7 @@
|
||||
<children>
|
||||
<component id="3ac8f" class="javax.swing.JLabel" binding="labelForOutputPrefixFile">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.prefix"/>
|
||||
@@ -38,13 +38,13 @@
|
||||
</component>
|
||||
<component id="dd0c2" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPrefixFile">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="70326" class="javax.swing.JLabel" binding="labelForOutputPostfixFile">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text resource-bundle="org/jetbrains/kotlin/idea/KotlinBundle" key="kotlin.compiler.js.option.output.postfix"/>
|
||||
@@ -52,13 +52,13 @@
|
||||
</component>
|
||||
<component id="1bdb7" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputPostfixFile">
|
||||
<constraints>
|
||||
<grid row="3" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="4" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="b93a8" class="javax.swing.JLabel" binding="labelForOutputDirectory">
|
||||
<constraints>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Destination directory"/>
|
||||
@@ -66,7 +66,7 @@
|
||||
</component>
|
||||
<component id="7c11a" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="outputDirectory">
|
||||
<constraints>
|
||||
<grid row="5" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
|
||||
<preferred-size width="150" height="-1"/>
|
||||
</grid>
|
||||
</constraints>
|
||||
@@ -76,7 +76,7 @@
|
||||
</component>
|
||||
<component id="97317" class="com.intellij.util.ui.ThreeStateCheckBox" binding="copyRuntimeFilesCheckBox" custom-create="true">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<state value="NOT_SELECTED"/>
|
||||
@@ -85,7 +85,7 @@
|
||||
</component>
|
||||
<component id="915d" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<labelFor value="ca29c"/>
|
||||
@@ -94,7 +94,7 @@
|
||||
</component>
|
||||
<component id="ca29c" class="javax.swing.JComboBox" binding="moduleKindComboBox">
|
||||
<constraints>
|
||||
<grid row="6" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<model/>
|
||||
@@ -126,6 +126,20 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="e5314" class="javax.swing.JLabel">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Embed source code into source map:"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="48310" class="javax.swing.JComboBox" binding="sourceMapEmbedSources">
|
||||
<constraints>
|
||||
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="8" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="483d4" binding="scriptPanel" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
|
||||
+47
-2
@@ -64,7 +64,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Configurable.NoScroll{
|
||||
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<String, String>();
|
||||
private static final Map<String, String> moduleKindDescriptions = new LinkedHashMap<>();
|
||||
private static final Map<String, String> soruceMapSourceEmbeddingDescriptions = new LinkedHashMap<>();
|
||||
private static final List<LanguageFeature.State> languageFeatureStates = Arrays.asList(
|
||||
LanguageFeature.State.ENABLED, LanguageFeature.State.ENABLED_WITH_WARNING, LanguageFeature.State.ENABLED_WITH_ERROR
|
||||
);
|
||||
@@ -75,6 +76,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_AMD, "AMD");
|
||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_COMMONJS, "CommonJS");
|
||||
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, "UMD (detect AMD or CommonJS if available, fallback to plain)");
|
||||
|
||||
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, "Never");
|
||||
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, "Always");
|
||||
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING,
|
||||
"When inlining a function from other module with embedded sources");
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -114,6 +120,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
private JLabel warningLabel;
|
||||
private JTextField sourceMapPrefix;
|
||||
private JLabel labelForSourceMapPrefix;
|
||||
private JComboBox sourceMapEmbedSources;
|
||||
private boolean isEnabled = true;
|
||||
|
||||
public KotlinCompilerConfigurableTab(
|
||||
@@ -157,6 +164,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
false);
|
||||
|
||||
fillModuleKindList();
|
||||
fillSourceMapSourceEmbeddingList();
|
||||
fillJvmVersionList();
|
||||
fillLanguageAndAPIVersionList();
|
||||
fillCoroutineSupportList();
|
||||
@@ -258,6 +266,15 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getSourceMapSourceEmbeddingDescription(@Nullable String sourceMapSourceEmbeddingId) {
|
||||
if (sourceMapSourceEmbeddingId == null) return "";
|
||||
String result = soruceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId);
|
||||
assert result != null : "Source map source embedding mode " + sourceMapSourceEmbeddingId +
|
||||
" was not added to combobox, therefore it should not be here";
|
||||
return result;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getModuleKindOrDefault(@Nullable String moduleKindId) {
|
||||
if (moduleKindId == null) {
|
||||
@@ -266,6 +283,14 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return moduleKindId;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getSourceMapSourceEmbeddingOrDefault(@Nullable String sourceMapSourceEmbeddingId) {
|
||||
if (sourceMapSourceEmbeddingId == null) {
|
||||
sourceMapSourceEmbeddingId = K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING;
|
||||
}
|
||||
return sourceMapSourceEmbeddingId;
|
||||
}
|
||||
|
||||
private static String getJvmVersionOrDefault(@Nullable String jvmVersion) {
|
||||
return jvmVersion != null ? jvmVersion : JvmTarget.DEFAULT.getDescription();
|
||||
}
|
||||
@@ -370,6 +395,19 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fillSourceMapSourceEmbeddingList() {
|
||||
for (String moduleKind : soruceMapSourceEmbeddingDescriptions.keySet()) {
|
||||
sourceMapEmbedSources.addItem(moduleKind);
|
||||
}
|
||||
sourceMapEmbedSources.setRenderer(new ListCellRendererWrapper<String>() {
|
||||
@Override
|
||||
public void customize(JList list, String value, int index, boolean selected, boolean hasFocus) {
|
||||
setText(value != null ? getSourceMapSourceEmbeddingDescription(value) : "");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getId() {
|
||||
@@ -409,7 +447,8 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
ComparingUtils.isModified(outputPostfixFile, k2jsCompilerArguments.outputPostfix) ||
|
||||
!getSelectedModuleKind().equals(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind)) ||
|
||||
ComparingUtils.isModified(sourceMapPrefix, k2jsCompilerArguments.sourceMapPrefix) ||
|
||||
|
||||
!getSelectedSourceMapSourceEmbedding().equals(
|
||||
getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.sourceMapEmbedSources)) ||
|
||||
!getSelectedJvmVersion().equals(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget));
|
||||
}
|
||||
|
||||
@@ -418,6 +457,10 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
return getModuleKindOrDefault((String) moduleKindComboBox.getSelectedItem());
|
||||
}
|
||||
|
||||
private String getSelectedSourceMapSourceEmbedding() {
|
||||
return getSourceMapSourceEmbeddingOrDefault((String) sourceMapEmbedSources.getSelectedItem());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private String getSelectedJvmVersion() {
|
||||
return getJvmVersionOrDefault((String) jvmVersionComboBox.getSelectedItem());
|
||||
@@ -499,6 +542,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
k2jsCompilerArguments.moduleKind = getSelectedModuleKind();
|
||||
|
||||
k2jsCompilerArguments.sourceMapPrefix = sourceMapPrefix.getText();
|
||||
k2jsCompilerArguments.sourceMapEmbedSources = getSelectedSourceMapSourceEmbedding();
|
||||
|
||||
k2jvmCompilerArguments.jvmTarget = getSelectedJvmVersion();
|
||||
|
||||
@@ -542,6 +586,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable, Co
|
||||
moduleKindComboBox.setSelectedItem(getModuleKindOrDefault(k2jsCompilerArguments.moduleKind));
|
||||
sourceMapPrefix.setText(k2jsCompilerArguments.sourceMapPrefix);
|
||||
sourceMapPrefix.setEnabled(k2jsCompilerArguments.sourceMap);
|
||||
sourceMapEmbedSources.setSelectedItem(getSourceMapSourceEmbeddingOrDefault(k2jsCompilerArguments.sourceMapEmbedSources));
|
||||
|
||||
jvmVersionComboBox.setSelectedItem(getJvmVersionOrDefault(k2jvmCompilerArguments.jvmTarget));
|
||||
}
|
||||
|
||||
@@ -164,6 +164,7 @@ private val jvmPrimaryFields = commonPrimaryFields + jvmSpecificUIExposedFields
|
||||
|
||||
private val jsSpecificUIExposedFields = listOf(K2JSCompilerArguments::sourceMap.name,
|
||||
K2JSCompilerArguments::sourceMapPrefix.name,
|
||||
K2JSCompilerArguments::sourceMapEmbedSources.name,
|
||||
K2JSCompilerArguments::outputPrefix.name,
|
||||
K2JSCompilerArguments::outputPostfix.name,
|
||||
K2JSCompilerArguments::moduleKind.name)
|
||||
|
||||
Reference in New Issue
Block a user