Skip to content

Commit

Permalink
fixing broken formatting rules and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rkeulv committed Feb 6, 2024
1 parent 589f03b commit da2821f
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 23 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/testData/formatter/BracePlacement1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/testData/formatter/BracePlacement2.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/testData/formatter/Default.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Foo {
}

public function new() {
switch( v ) {
switch (v) {
case 0:
e1();
case foo(1):
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/testData/formatter/IndentSpaces.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Foo {
}

public function new() {
switch( v ) {
switch (v) {
case 0:
e1();
case foo(1):
Expand Down
2 changes: 1 addition & 1 deletion src/test/resources/testData/formatter/IndentTabs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Foo {
}

public function new() {
switch( v ) {
switch (v) {
case 0:
e1();
case foo(1):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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() {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/testData/formatter/SpaceLeftBraces.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down
5 changes: 2 additions & 3 deletions src/test/resources/testData/formatter/SpaceOthers.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
3 changes: 1 addition & 2 deletions src/test/resources/testData/formatter/SpaceWithin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand Down

0 comments on commit da2821f

Please sign in to comment.