Skip to content

Commit

Permalink
Remove wrapping braces in if conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ishad-M-I-M committed Oct 16, 2023
1 parent 49226a8 commit fd3790a
Show file tree
Hide file tree
Showing 28 changed files with 62 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private SyntaxTreeConstants() {
public static final Token SYNTAX_TREE_KEYWORD_IF = AbstractNodeFactory.createIdentifierToken("if ");
public static final Token SYNTAX_TREE_KEYWORD_ELSE = AbstractNodeFactory.createIdentifierToken("else ");
public static final Token SYNTAX_TREE_KEYWORD_IS = AbstractNodeFactory.createIdentifierToken("is ");
public static final Token SYNTAX_TREE_KEYWORD_NOT_IS = AbstractNodeFactory.createIdentifierToken("!is");
public static final Token SYNTAX_TREE_KEYWORD_NOT_IS = AbstractNodeFactory.createIdentifierToken("!is ");
public static final Token SYNTAX_TREE_KEYWORD_LISTENER = AbstractNodeFactory.createIdentifierToken("listener ");
public static final Token SYNTAX_TREE_KEYWORD_SERVICE = AbstractNodeFactory.createIdentifierToken("service ");
public static final Token SYNTAX_TREE_KEYWORD_ON = AbstractNodeFactory.createIdentifierToken("on ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

import static io.ballerina.protoc.GrpcConstants.ANN_DESCRIPTOR;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getBinaryExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getBracedExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getFieldAccessExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getMethodCallExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getOptionalFieldAccessExpressionNode;
Expand Down Expand Up @@ -263,9 +262,7 @@ private static Function getValidationFunction(Message message) {
}
if (counts.size() > 0) {
IfElse countCheck = new IfElse(
getBracedExpressionNode(
getCountCheckBinaryExpression(counts)
)
getCountCheckBinaryExpression(counts)
);
countCheck.addIfStatement(
getReturnStatementNode(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static io.ballerina.protoc.builder.BallerinaFileBuilder.protofileModuleMap;
import static io.ballerina.protoc.builder.balgen.BalGenConstants.COLON;
import static io.ballerina.protoc.builder.balgen.BalGenConstants.PACKAGE_SEPARATOR;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getBracedExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getExplicitNewExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getFieldAccessExpressionNode;
import static io.ballerina.protoc.builder.syntaxtree.components.Expression.getMethodCallExpressionNode;
Expand Down Expand Up @@ -228,11 +227,9 @@ private static Function getNextFunction(Method method, String filename) {
function.addVariableStatement(streamValue.getVariableDeclarationNode());

IfElse streamValueNilCheck = new IfElse(
getBracedExpressionNode(
getTypeTestExpressionNode(
getSimpleNameReferenceNode("streamValue"),
getNilTypeDescriptorNode()
)
getTypeTestExpressionNode(
getSimpleNameReferenceNode("streamValue"),
getNilTypeDescriptorNode()
)
);
streamValueNilCheck.addIfStatement(
Expand All @@ -241,11 +238,9 @@ private static Function getNextFunction(Method method, String filename) {
)
);
IfElse streamValueErrorCheck = new IfElse(
getBracedExpressionNode(
getTypeTestExpressionNode(
getSimpleNameReferenceNode("streamValue"),
SyntaxTreeConstants.SYNTAX_TREE_GRPC_ERROR
)
getTypeTestExpressionNode(
getSimpleNameReferenceNode("streamValue"),
SyntaxTreeConstants.SYNTAX_TREE_GRPC_ERROR
)
);
streamValueErrorCheck.addIfStatement(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public class ResMessageStream {

public isolated function next() returns record {|ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ResMessage value;|} nextRecord = {value: <ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public class ResMessageStream {

public isolated function next() returns record {|ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ResMessage value;|} nextRecord = {value: <ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ isolated function isValidRequest1(Request1 r) returns boolean {
if r?.'version !is () {
nameCount += 1;
}
if (otherCount > 1 || nameCount > 1) {
if otherCount > 1 || nameCount > 1 {
return false;
}
return true;
Expand Down Expand Up @@ -241,7 +241,7 @@ isolated function isValidAddress1(Address1 r) returns boolean {
if r?.street_number !is () {
codeCount += 1;
}
if (codeCount > 1) {
if codeCount > 1 {
return false;
}
return true;
Expand Down Expand Up @@ -318,7 +318,7 @@ isolated function isValidZzz(ZZZ r) returns boolean {
if r?.one_k !is () {
valueCount += 1;
}
if (valueCount > 1) {
if valueCount > 1 {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public class ParentMessageStream {

public isolated function next() returns record {|ParentMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ParentMessage value;|} nextRecord = {value: <ParentMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,9 +153,9 @@ public class AlbumStream {

public isolated function next() returns record {|Album value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Album value;|} nextRecord = {value: <Album>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -361,9 +361,9 @@ public class EmptyStream {

public isolated function next() returns record {|Empty value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Empty value;|} nextRecord = {value: <Empty>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ isolated function isValidFieldrules(FieldRules r) returns boolean {
if r?.'enum !is () {
typeCount += 1;
}
if (typeCount > 1) {
if typeCount > 1 {
return false;
}
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public class ParentMessageStream {

public isolated function next() returns record {|ParentMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ParentMessage value;|} nextRecord = {value: <ParentMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ public class ResMessageStream {

public isolated function next() returns record {|message:ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message:ResMessage value;|} nextRecord = {value: <message:ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ public class ResMessageStream {

public isolated function next() returns record {|message:ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message:ResMessage value;|} nextRecord = {value: <message:ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public class ResMessage2Stream {

public isolated function next() returns record {|message2:ResMessage2 value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message2:ResMessage2 value;|} nextRecord = {value: <message2:ResMessage2>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public class ResMessage2Stream {

public isolated function next() returns record {|message2:ResMessage2 value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message2:ResMessage2 value;|} nextRecord = {value: <message2:ResMessage2>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ public class ResMessageStream {

public isolated function next() returns record {|ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ResMessage value;|} nextRecord = {value: <ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public class ResMessageStream {

public isolated function next() returns record {|message2:ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message2:ResMessage value;|} nextRecord = {value: <message2:ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,9 +143,9 @@ public class ResMessageStream {

public isolated function next() returns record {|message2:ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|message2:ResMessage value;|} nextRecord = {value: <message2:ResMessage>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public class MessageStream {

public isolated function next() returns record {|Message value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Message value;|} nextRecord = {value: <Message>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ public class MessageStream {

public isolated function next() returns record {|Message value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Message value;|} nextRecord = {value: <Message>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public class HelloResponseStream {

public isolated function next() returns record {|HelloResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|HelloResponse value;|} nextRecord = {value: <HelloResponse>streamValue.value};
Expand All @@ -107,9 +107,9 @@ public class ByeResponseStream {

public isolated function next() returns record {|ByeResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ByeResponse value;|} nextRecord = {value: <ByeResponse>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public class HelloResponseStream {

public isolated function next() returns record {|HelloResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|HelloResponse value;|} nextRecord = {value: <HelloResponse>streamValue.value};
Expand All @@ -107,9 +107,9 @@ public class ByeResponseStream {

public isolated function next() returns record {|ByeResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ByeResponse value;|} nextRecord = {value: <ByeResponse>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class HelloResponseStream {

public isolated function next() returns record {|HelloResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|HelloResponse value;|} nextRecord = {value: <HelloResponse>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ public class HelloResponseStream {

public isolated function next() returns record {|HelloResponse value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|HelloResponse value;|} nextRecord = {value: <HelloResponse>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ public class GreetingStream {

public isolated function next() returns record {|Greeting value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Greeting value;|} nextRecord = {value: <Greeting>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ public class GreetingStream {

public isolated function next() returns record {|Greeting value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|Greeting value;|} nextRecord = {value: <Greeting>streamValue.value};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public class ResMessageStream {

public isolated function next() returns record {|ResMessage value;|}|grpc:Error? {
var streamValue = self.anydataStream.next();
if (streamValue is ()) {
if streamValue is () {
return streamValue;
} else if (streamValue is grpc:Error) {
} else if streamValue is grpc:Error {
return streamValue;
} else {
record {|ResMessage value;|} nextRecord = {value: <ResMessage>streamValue.value};
Expand Down
Loading

0 comments on commit fd3790a

Please sign in to comment.