[Python] Refactor the old DictAlignment enum which prevented dynamic syntax bundle loading

Unfortunately, we need to keep the old int values logic to preserve compatibility with old user settings

GitOrigin-RevId: 59fba8bd53e3d89d31897ed675b54827bbf9b15f
This commit is contained in:
Daniil Kalinin
2025-02-13 10:45:38 +00:00
committed by intellij-monorepo-bot
parent a4f9be714a
commit f8a57f7367
2 changed files with 17 additions and 24 deletions
@@ -4,6 +4,7 @@ package com.jetbrains.python.formatter;
import com.intellij.psi.codeStyle.CodeStyleSettings;
import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
import com.intellij.util.ui.PresentableEnum;
import com.jetbrains.python.PySyntaxCoreBundle;
import org.intellij.lang.annotations.MagicConstant;
import org.jetbrains.annotations.NotNull;
@@ -13,24 +14,29 @@ import static com.intellij.psi.codeStyle.CommonCodeStyleSettings.WRAP_AS_NEEDED;
public class PyCodeStyleSettings extends CustomCodeStyleSettings {
public enum DictAlignment {
NONE(PySyntaxCoreBundle.message("formatter.panel.dict.alignment.do.not.align")),
ON_VALUE(PySyntaxCoreBundle.message("formatter.panel.dict.alignment.align.on.value")),
ON_COLON(PySyntaxCoreBundle.message("formatter.panel.dict.alignment.align.on.colon"));
public enum DictAlignment implements PresentableEnum {
NONE("formatter.panel.dict.alignment.do.not.align"),
ON_VALUE("formatter.panel.dict.alignment.align.on.value"),
ON_COLON("formatter.panel.dict.alignment.align.on.colon");
String description;
private final String key;
DictAlignment(String description) {
this.description = description;
DictAlignment(String key) {
this.key = key;
}
public int asInt() {
return ordinal();
}
@Override
public String getPresentableText() {
return PySyntaxCoreBundle.message(key);
}
@Override
public String toString() {
return description;
return getPresentableText();
}
}