Fix NPE in Kotlin facets tab

This commit is contained in:
Vladimir Dolzhenko
2021-02-05 21:27:53 +01:00
parent 250040bab7
commit 391f53154a
@@ -54,10 +54,7 @@ import java.util.List;
public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
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
);
private static final Map<String, String> sourceMapSourceEmbeddingDescriptions = new LinkedHashMap<>();
private static final int MAX_WARNING_SIZE = 75;
private static final Disposable validatorsDisposable = Disposer.newDisposable();
@@ -68,9 +65,11 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_COMMONJS, KotlinBundle.message("configuration.description.commonjs"));
moduleKindDescriptions.put(K2JsArgumentConstants.MODULE_UMD, KotlinBundle.message("configuration.description.umd.detect.amd.or.commonjs.if.available.fallback.to.plain"));
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, KotlinBundle.message("configuration.description.never"));
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, KotlinBundle.message("configuration.description.always"));
soruceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, KotlinBundle.message("configuration.description.when.inlining.a.function.from.other.module.with.embedded.sources"));
sourceMapSourceEmbeddingDescriptions
.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_NEVER, KotlinBundle.message("configuration.description.never"));
sourceMapSourceEmbeddingDescriptions
.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_ALWAYS, KotlinBundle.message("configuration.description.always"));
sourceMapSourceEmbeddingDescriptions.put(K2JsArgumentConstants.SOURCE_MAP_SOURCE_CONTENT_INLINING, KotlinBundle.message("configuration.description.when.inlining.a.function.from.other.module.with.embedded.sources"));
}
@Nullable
@@ -97,8 +96,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
private JComboBox moduleKindComboBox;
private JTextField scriptTemplatesField;
private JTextField scriptTemplatesClasspathField;
private JLabel scriptTemplatesLabel;
private JLabel scriptTemplatesClasspathLabel;
private JPanel k2jvmPanel;
private JPanel k2jsPanel;
private JComboBox jvmVersionComboBox;
@@ -109,9 +106,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
private JLabel labelForOutputPostfixFile;
private JLabel warningLabel;
private JTextField sourceMapPrefix;
private JLabel labelForSourceMapPrefix;
private JComboBox sourceMapEmbedSources;
private JPanel coroutinesPanel;
private boolean isEnabled = true;
public KotlinCompilerConfigurableTab(
@@ -266,7 +261,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
@NotNull
private static String getSourceMapSourceEmbeddingDescription(@Nullable String sourceMapSourceEmbeddingId) {
if (sourceMapSourceEmbeddingId == null) return "";
String result = soruceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId);
String result = sourceMapSourceEmbeddingDescriptions.get(sourceMapSourceEmbeddingId);
assert result != null : "Source map source embedding mode " + sourceMapSourceEmbeddingId +
" was not added to combobox, therefore it should not be here";
return result;
@@ -329,7 +324,6 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
public void onLanguageLevelChanged(@Nullable VersionView languageLevel) {
if (languageLevel == null) return;
restrictAPIVersions(languageLevel);
coroutinesPanel.setVisible(languageLevel.getVersion().compareTo(LanguageVersion.KOTLIN_1_3) < 0);
}
@SuppressWarnings("unchecked")
@@ -400,7 +394,7 @@ public class KotlinCompilerConfigurableTab implements SearchableConfigurable {
@SuppressWarnings("unchecked")
private void fillSourceMapSourceEmbeddingList() {
for (String moduleKind : soruceMapSourceEmbeddingDescriptions.keySet()) {
for (String moduleKind : sourceMapSourceEmbeddingDescriptions.keySet()) {
sourceMapEmbedSources.addItem(moduleKind);
}
sourceMapEmbedSources.setRenderer(new ListCellRendererWrapper<String>() {