HaxeCheckstyle / haxe-formatter

Haxe code formatter based on tokentree
https://haxecheckstyle.github.io/haxe-formatter-docs/#codesamples.CommonSamples.allman_curlies
MIT License
72 stars 16 forks source link

Mapwrap #675

Closed JasperHorn closed 8 months ago

JasperHorn commented 1 year ago

Describe the Feature

Currently map literals ([key1 => value1, key2 => value2]) are formatted according to the wrapping.arrayWrap configuration. As far as I can tell, there is no way to format map literals different from array literals, which can definitely be a sensible thing to do (for example: leave array mapping as default, but use onePerLine for map literals).

Sample of desired output

{
    "wrapping": {
        "arrayWrapping": {
            "defaultWrap": "noWrap"
        },
        "mapWrapping": {
            "defaultWrap": "onePerLine"
       }
}
class Main {
    private var array:Array<String> = ["a", "b", "c"];

    private var map:Map<String, String> = [
        "a" => "apple",
        "b" => "bear",
        "c" => "callsign"
    ];
}