-
Notifications
You must be signed in to change notification settings - Fork 755
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41397 from poorna2152/function_call_formatting
Fix multline function call formatting
- Loading branch information
Showing
16 changed files
with
247 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...parser/src/test/resources/expressions/object-constructor/object_constructor_source_10.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
public function main() { | ||
foo(object { | ||
int i = 1; | ||
}); | ||
int i = 1; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...matter/modules/formatter-core/src/test/resources/misc/linebreaks/assert/line_breaks_3.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
public function foo() { | ||
( | ||
) y = () | ||
; | ||
; | ||
var x = (); | ||
|
||
int | ||
|
2 changes: 1 addition & 1 deletion
2
...matter/modules/formatter-core/src/test/resources/misc/linebreaks/assert/line_breaks_4.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
public function foo() { | ||
foreach string animal in animals { | ||
match | ||
animal | ||
animal | ||
{ | ||
"Mouse" => | ||
{ | ||
|
13 changes: 13 additions & 0 deletions
13
...ter/modules/formatter-core/src/test/resources/statements/call/assert/call_statement_2.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ballerina/io; | ||
|
||
function calculateTotalInvoiceAmount(int customerId, string invoiceDate, | ||
decimal[] itemPrices, boolean isTaxable) returns decimal { | ||
decimal totalAmount = 0.0; | ||
return totalAmount; | ||
} | ||
|
||
public function main() { | ||
decimal invoiceAmount = calculateTotalInvoiceAmount(12345, "2023-09-13", | ||
[25.99, 19.95, 12.49, 7.99, 34.50], true); | ||
io:println(invoiceAmount); | ||
} |
21 changes: 21 additions & 0 deletions
21
...ter/modules/formatter-core/src/test/resources/statements/call/assert/call_statement_3.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function calculate() returns int { | ||
int result = subtract(add([21, 45, 6, 12, 67, 89], [1, 5, 6, 9]), | ||
add([11, 12, 13, 14, 15, 16, 17, 18, 19, 20], | ||
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10])); | ||
return result; | ||
} | ||
|
||
function add(int[] a, int[] b) returns int { | ||
int sum = 0; | ||
foreach int n in a { | ||
sum += n; | ||
} | ||
foreach int n in b { | ||
sum += n; | ||
} | ||
return sum; | ||
} | ||
|
||
function subtract(int x, int y) returns int { | ||
return x - y; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ter/modules/formatter-core/src/test/resources/statements/call/assert/call_statement_4.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type SourcePatient record { | ||
string message; | ||
string detail; | ||
string cause; | ||
}; | ||
|
||
function foo(string m, int c, int t, string d, string cause) { | ||
} | ||
|
||
function bar(SourcePatient sourcePatient, int errorCode, int errorType) { | ||
return foo(sourcePatient.message, errorCode, errorType, sourcePatient.detail, | ||
sourcePatient.cause); | ||
} |
32 changes: 32 additions & 0 deletions
32
...ter/modules/formatter-core/src/test/resources/statements/call/assert/call_statement_5.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
public function main() { | ||
foo(object { | ||
int i = 1; | ||
}, a, | ||
b); | ||
} | ||
|
||
public function bar() { | ||
bar(t1, object { | ||
int i = 1; | ||
}, t2, t3); | ||
} | ||
|
||
public function baz() { | ||
baz(t1, t2, object { | ||
int i = 1; | ||
int y = 2; | ||
}, | ||
b, | ||
c, | ||
d); | ||
} | ||
|
||
public function fox() { | ||
foz(t1, | ||
object { | ||
int i = 1; | ||
}, | ||
b, | ||
c, | ||
d); | ||
} |
21 changes: 21 additions & 0 deletions
21
...ter/modules/formatter-core/src/test/resources/statements/call/assert/call_statement_6.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function processEmployeeInfo(string firstName, string lastName, string department, string jobTitle, | ||
int employeeId, float salary) { | ||
} | ||
|
||
function foo() { | ||
string firstName = "John"; | ||
string lastName = "Doe"; | ||
string department = "Engineering"; | ||
string jobTitle = "Software Engineer"; | ||
int employeeId = 1001; | ||
float salary = 75000.0; | ||
|
||
processEmployeeInfo( | ||
firstName, | ||
lastName, | ||
department, | ||
jobTitle, | ||
employeeId, | ||
salary | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
...ter/modules/formatter-core/src/test/resources/statements/call/source/call_statement_2.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ballerina/io; | ||
|
||
function calculateTotalInvoiceAmount(int customerId, string invoiceDate, | ||
decimal[] itemPrices, boolean isTaxable) returns decimal { | ||
decimal totalAmount = 0.0; | ||
return totalAmount; | ||
} | ||
|
||
public function main() { | ||
decimal invoiceAmount = calculateTotalInvoiceAmount ( 12345, "2023-09-13", | ||
[25.99, 19.95, 12.49, 7.99, 34.50], true ) ; | ||
io:println ( invoiceAmount ) ; | ||
} |
21 changes: 21 additions & 0 deletions
21
...ter/modules/formatter-core/src/test/resources/statements/call/source/call_statement_3.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function calculate() returns int { | ||
int result = subtract(add([21, 45, 6, 12, 67, 89], [1,5,6,9]), | ||
add([11,12,13,14,15,16,17,18,19,20], | ||
[1,2,3,4,5,6,7,8,9,10])); | ||
return result; | ||
} | ||
|
||
function add(int[] a, int[] b) returns int { | ||
int sum = 0; | ||
foreach int n in a { | ||
sum += n; | ||
} | ||
foreach int n in b { | ||
sum += n; | ||
} | ||
return sum; | ||
} | ||
|
||
function subtract(int x, int y) returns int { | ||
return x - y; | ||
} |
13 changes: 13 additions & 0 deletions
13
...ter/modules/formatter-core/src/test/resources/statements/call/source/call_statement_4.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
type SourcePatient record { | ||
string message; | ||
string detail; | ||
string cause; | ||
}; | ||
|
||
function foo(string m, int c, int t, string d, string cause) { | ||
} | ||
|
||
function bar(SourcePatient sourcePatient, int errorCode, int errorType) { | ||
return foo(sourcePatient.message, errorCode, errorType, sourcePatient.detail, | ||
sourcePatient.cause); | ||
} |
32 changes: 32 additions & 0 deletions
32
...ter/modules/formatter-core/src/test/resources/statements/call/source/call_statement_5.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
public function main() { | ||
foo(object { | ||
int i = 1; | ||
}, a, | ||
b); | ||
} | ||
|
||
public function bar() { | ||
bar(t1, object { | ||
int i = 1; | ||
}, t2, t3); | ||
} | ||
|
||
public function baz() { | ||
baz(t1, t2, object { | ||
int i = 1; | ||
int y = 2; | ||
}, | ||
b, | ||
c, | ||
d); | ||
} | ||
|
||
public function fox() { | ||
foz(t1, | ||
object { | ||
int i = 1; | ||
}, | ||
b, | ||
c, | ||
d); | ||
} |
21 changes: 21 additions & 0 deletions
21
...ter/modules/formatter-core/src/test/resources/statements/call/source/call_statement_6.bal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function processEmployeeInfo(string firstName, string lastName, string department, string jobTitle, | ||
int employeeId, float salary) { | ||
} | ||
|
||
function foo() { | ||
string firstName = "John"; | ||
string lastName = "Doe"; | ||
string department = "Engineering"; | ||
string jobTitle = "Software Engineer"; | ||
int employeeId = 1001; | ||
float salary = 75000.0; | ||
|
||
processEmployeeInfo( | ||
firstName, | ||
lastName, | ||
department, | ||
jobTitle, | ||
employeeId, | ||
salary | ||
); | ||
} |