From da2821f128c327a1a1ba04e525cbecea38a9096c Mon Sep 17 00:00:00 2001 From: m0rkeulv Date: Tue, 6 Feb 2024 22:37:27 +0100 Subject: [PATCH] fixing broken formatting rules and tests --- CHANGELOG.md | 4 ++++ .../plugins/haxe/ide/formatter/HaxeSpacingProcessor.java | 6 ++++-- .../resources/testData/formatter/BracePlacement1.txt | 3 +-- .../resources/testData/formatter/BracePlacement2.txt | 3 +-- src/test/resources/testData/formatter/Default.txt | 2 +- src/test/resources/testData/formatter/IndentSpaces.txt | 2 +- src/test/resources/testData/formatter/IndentTabs.txt | 2 +- .../testData/formatter/SpaceAroundOperators.txt | 9 ++++----- .../testData/formatter/SpaceBeforeParentheses.txt | 3 +-- .../resources/testData/formatter/SpaceLeftBraces.txt | 3 +-- src/test/resources/testData/formatter/SpaceOthers.txt | 5 ++--- src/test/resources/testData/formatter/SpaceWithin.txt | 3 +-- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c11af9a94..cbec34c10 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ # Changelog +## 1.4.36 +* Fixed: Restored broken formatting rules +* Fixed: Prevent anonymous types from being formatted as code-blocks + ## 1.4.35 * Fixed: Assign hint was not working when resolving function return type. diff --git a/src/main/java/com/intellij/plugins/haxe/ide/formatter/HaxeSpacingProcessor.java b/src/main/java/com/intellij/plugins/haxe/ide/formatter/HaxeSpacingProcessor.java index cecb9b812..ab99d4422 100644 --- a/src/main/java/com/intellij/plugins/haxe/ide/formatter/HaxeSpacingProcessor.java +++ b/src/main/java/com/intellij/plugins/haxe/ide/formatter/HaxeSpacingProcessor.java @@ -332,8 +332,10 @@ else if (typeType1 == OCOLON) { // Spacing around assignment operators (=, -=, etc.) // - if (ASSIGN_OPERATORS.contains(typeType1) || ASSIGN_OPERATORS.contains(typeType2) || - type2 == VAR_INIT) { + if (ASSIGN_OPERATORS.contains(type1) + || ASSIGN_OPERATORS.contains(typeType1) + || ASSIGN_OPERATORS.contains(typeType2) + || type2 == VAR_INIT) { return addSingleSpaceIf(mySettings.SPACE_AROUND_ASSIGNMENT_OPERATORS); } diff --git a/src/test/resources/testData/formatter/BracePlacement1.txt b/src/test/resources/testData/formatter/BracePlacement1.txt index 150a61d5d..7cce1c32d 100644 --- a/src/test/resources/testData/formatter/BracePlacement1.txt +++ b/src/test/resources/testData/formatter/BracePlacement1.txt @@ -4,8 +4,7 @@ class Foo function fOne(argA:Int, argB, argC, argD, argE, argF, argG, argH) { var numbers:Array< String> = ['one', 'two', 'three', 'four', 'five', 'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try { this.fTwo(argA, argB, argC, this.fThree("", argE, argF, argG, argH)); diff --git a/src/test/resources/testData/formatter/BracePlacement2.txt b/src/test/resources/testData/formatter/BracePlacement2.txt index 914c9f9eb..75c04ee4a 100644 --- a/src/test/resources/testData/formatter/BracePlacement2.txt +++ b/src/test/resources/testData/formatter/BracePlacement2.txt @@ -3,8 +3,7 @@ class Foo { function fOne(argA:Int, argB, argC, argD, argE, argF, argG, argH) { var numbers:Array< String> = ['one', 'two', 'three', 'four', 'five', 'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try { this.fTwo(argA, argB, argC, this.fThree("", argE, argF, argG, argH)); } catch (ignored:String) { diff --git a/src/test/resources/testData/formatter/Default.txt b/src/test/resources/testData/formatter/Default.txt index fda2cf2d3..ae3acc938 100644 --- a/src/test/resources/testData/formatter/Default.txt +++ b/src/test/resources/testData/formatter/Default.txt @@ -42,7 +42,7 @@ class Foo { } public function new() { - switch( v ) { + switch (v) { case 0: e1(); case foo(1): diff --git a/src/test/resources/testData/formatter/IndentSpaces.txt b/src/test/resources/testData/formatter/IndentSpaces.txt index 05474aa4b..31d33ca28 100644 --- a/src/test/resources/testData/formatter/IndentSpaces.txt +++ b/src/test/resources/testData/formatter/IndentSpaces.txt @@ -42,7 +42,7 @@ class Foo { } public function new() { - switch( v ) { + switch (v) { case 0: e1(); case foo(1): diff --git a/src/test/resources/testData/formatter/IndentTabs.txt b/src/test/resources/testData/formatter/IndentTabs.txt index 8d84615a3..74cbf3d63 100644 --- a/src/test/resources/testData/formatter/IndentTabs.txt +++ b/src/test/resources/testData/formatter/IndentTabs.txt @@ -42,7 +42,7 @@ class Foo { } public function new() { - switch( v ) { + switch (v) { case 0: e1(); case foo(1): diff --git a/src/test/resources/testData/formatter/SpaceAroundOperators.txt b/src/test/resources/testData/formatter/SpaceAroundOperators.txt index 6396cdaf7..b7d6f90f2 100644 --- a/src/test/resources/testData/formatter/SpaceAroundOperators.txt +++ b/src/test/resources/testData/formatter/SpaceAroundOperators.txt @@ -2,8 +2,7 @@ class Foo { // function fBar (x,y); function fOne(argA:Int, argB, argC, argD, argE, argF, argG, argH) { var numbers:Array< String>=['one', 'two', 'three', 'four', 'five', 'six']; - var x=("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x=(""+argA)+argB+argC+argD+argE+argF+argG+argH; try { this.fTwo(argA, argB, argC, this.fThree("", argE, argF, argG, argH)); } catch (ignored:String) { @@ -22,15 +21,15 @@ class Foo { function fTwo(strA, strB, strC, strD) { if (true) return strC; - if (strA=='one' || strB=='two') { - return strA + strB; + if (strA=='one'||strB=='two') { + return strA+strB; } else if (true) return strD; throw strD; } function fThree(strA, strB, strC, strD, strE) { - return strA + strB + strC + strD + strE; + return strA+strB+strC+strD+strE; } public function new() {} diff --git a/src/test/resources/testData/formatter/SpaceBeforeParentheses.txt b/src/test/resources/testData/formatter/SpaceBeforeParentheses.txt index e3bc9cb65..7985d7215 100644 --- a/src/test/resources/testData/formatter/SpaceBeforeParentheses.txt +++ b/src/test/resources/testData/formatter/SpaceBeforeParentheses.txt @@ -2,8 +2,7 @@ class Foo { // function fBar (x,y); function fOne (argA:Int, argB, argC, argD, argE, argF, argG, argH) { var numbers:Array< String> = ['one', 'two', 'three', 'four', 'five', 'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try { this.fTwo (argA, argB, argC, this.fThree ("", argE, argF, argG, argH)); } catch(ignored:String) { diff --git a/src/test/resources/testData/formatter/SpaceLeftBraces.txt b/src/test/resources/testData/formatter/SpaceLeftBraces.txt index 591a6eea8..47d57beb8 100644 --- a/src/test/resources/testData/formatter/SpaceLeftBraces.txt +++ b/src/test/resources/testData/formatter/SpaceLeftBraces.txt @@ -2,8 +2,7 @@ class Foo { // function fBar (x,y); function fOne(argA:Int, argB, argC, argD, argE, argF, argG, argH){ var numbers:Array< String> = ['one', 'two', 'three', 'four', 'five', 'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try{ this.fTwo(argA, argB, argC, this.fThree("", argE, argF, argG, argH)); } catch (ignored:String){ diff --git a/src/test/resources/testData/formatter/SpaceOthers.txt b/src/test/resources/testData/formatter/SpaceOthers.txt index 75b9aa24d..e69589653 100644 --- a/src/test/resources/testData/formatter/SpaceOthers.txt +++ b/src/test/resources/testData/formatter/SpaceOthers.txt @@ -2,14 +2,13 @@ class Foo { // function fBar (x,y); function fOne(argA:Int , argB , argC , argD , argE , argF , argG , argH) { var numbers:Array< String> = ['one' ,'two' ,'three' ,'four' ,'five' ,'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try { this.fTwo(argA , argB , argC , this.fThree("" , argE , argF , argG , argH)); }catch (ignored:String) { } - var z = argA == 'Some string' ? 'yes' : 'no'; + var z = argA == 'Some string'?'yes':'no'; var colors = ['red' ,'green' ,'blue' ,'black' ,'white' ,'gray']; for (colorIndex in 0...colors.length) { var colorString = numbers[colorIndex]; diff --git a/src/test/resources/testData/formatter/SpaceWithin.txt b/src/test/resources/testData/formatter/SpaceWithin.txt index 974053fbc..ad62c3634 100644 --- a/src/test/resources/testData/formatter/SpaceWithin.txt +++ b/src/test/resources/testData/formatter/SpaceWithin.txt @@ -2,8 +2,7 @@ class Foo { // function fBar (x,y); function fOne( argA:Int, argB, argC, argD, argE, argF, argG, argH ) { var numbers:Array< String> = ['one', 'two', 'three', 'four', 'five', 'six']; - var x = ("" + argA) + argB + - argC + argD + argE + argF + argG + argH; + var x = ("" + argA) + argB + argC + argD + argE + argF + argG + argH; try { this.fTwo( argA, argB, argC, this.fThree( "", argE, argF, argG, argH ) ); } catch ( ignored:String ) {