diff --git a/language-server/modules/langserver-core/src/test/resources/formatting/project/Format.toml b/language-server/modules/langserver-core/src/test/resources/formatting/project/Format.toml index d68d4dc5017a..f34eb5049103 100644 --- a/language-server/modules/langserver-core/src/test/resources/formatting/project/Format.toml +++ b/language-server/modules/langserver-core/src/test/resources/formatting/project/Format.toml @@ -6,7 +6,7 @@ maxLineLength = 80 simpleBlocksInOneLine = true simpleFunctionsInOneLine = true -[functionDeclaration] +[functionDefinition] alignMultilineParameters = true [ifStatement] diff --git a/misc/formatter/modules/formatter-cli/src/test/java/org/ballerinalang/formatter/cli/FormatCmdTest.java b/misc/formatter/modules/formatter-cli/src/test/java/org/ballerinalang/formatter/cli/FormatCmdTest.java index f8a35b8ae876..0ef6e827d68d 100644 --- a/misc/formatter/modules/formatter-cli/src/test/java/org/ballerinalang/formatter/cli/FormatCmdTest.java +++ b/misc/formatter/modules/formatter-cli/src/test/java/org/ballerinalang/formatter/cli/FormatCmdTest.java @@ -103,40 +103,39 @@ public void formatCLIOnBallerinaProjectWithConfigurations(String testCase, List< @DataProvider(name = "provideConfigurationProjects") private Object[][] provideConfigurationProjects() { + Path basePath = RES_DIR.resolve(Path.of("configurations", "options")); return new Object[][]{ {"brace", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "brace", "source", "project")) + basePath.resolve(Path.of("brace", "source", "project")) )}, {"functionCall", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "functionCall", "source", "chopDown")), - RES_DIR.resolve(Path.of("configurations", "options", "functionCall", "source", "noWrap")), - RES_DIR.resolve(Path.of("configurations", "options", "functionCall", "source", "wrap")) + basePath.resolve(Path.of("functionCall", "source", "chopDown")), + basePath.resolve(Path.of("functionCall", "source", "noWrap")), + basePath.resolve(Path.of("functionCall", "source", "wrap")) )}, - {"functionDeclaration", List.of( - RES_DIR.resolve( - Path.of("configurations", "options", "functionDeclaration", "source", "chopDown")), - RES_DIR.resolve( - Path.of("configurations", "options", "functionDeclaration", "source", "noWrap")), - RES_DIR.resolve(Path.of("configurations", "options", "functionDeclaration", "source", "wrap")) + {"functionDefinition", List.of( + basePath.resolve(Path.of("functionDefinition", "source", "chopDown")), + basePath.resolve(Path.of("functionDefinition", "source", "noWrap")), + basePath.resolve(Path.of("functionDefinition", "source", "wrap")) )}, {"ifStatement", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "ifStatement", "source", "ifelse")) + basePath.resolve(Path.of("ifStatement", "source", "ifelse")) )}, {"imports", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "imports", "source", "project")) + basePath.resolve(Path.of("imports", "source", "project")) )}, {"indent", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "indent", "source", "project")) + basePath.resolve(Path.of("indent", "source", "project")) )}, {"query", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "query", "source", "project")) + basePath.resolve(Path.of("query", "source", "project")) )} , {"spacing", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "spacing", "source", "project")) + basePath.resolve(Path.of("spacing", "source", "project")) )}, {"wrapping", List.of( - RES_DIR.resolve(Path.of("configurations", "options", "wrapping", "source", "project")) + basePath.resolve(Path.of("wrapping", "source", "project")) )} }; } diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/chopDown/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/chopDown/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/chopDown/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/chopDown/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/noWrap/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/noWrap/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/noWrap/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/noWrap/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/wrap/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/wrap/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/assert/wrap/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/assert/wrap/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/Ballerina.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/Ballerina.toml similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/Ballerina.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/Ballerina.toml diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/Format.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/Format.toml similarity index 80% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/Format.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/Format.toml index 75c3ddbfddb7..89109c454b0a 100644 --- a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/Format.toml +++ b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/Format.toml @@ -1,4 +1,4 @@ -[functionDeclaration] +[functionDefinition] parametersWrap = "ChopDown" alignMultilineParameters = true diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDown/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDown/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDownTemp/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDownTemp/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/chopDownTemp/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/chopDownTemp/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/Ballerina.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/Ballerina.toml similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/Ballerina.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/Ballerina.toml diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/Format.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/Format.toml similarity index 72% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/Format.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/Format.toml index f0fce7dc7d10..c7b0a4ca7559 100644 --- a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/Format.toml +++ b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/Format.toml @@ -1,4 +1,4 @@ -[functionDeclaration] +[functionDefinition] parametersWrap = "NoWrap" [wrapping] diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrap/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrap/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrapTemp/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrapTemp/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/noWrapTemp/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/noWrapTemp/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/Ballerina.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/Ballerina.toml similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/Ballerina.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/Ballerina.toml diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/Format.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/Format.toml similarity index 86% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/Format.toml rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/Format.toml index 94978d78125f..eda71c706a8d 100644 --- a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/Format.toml +++ b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/Format.toml @@ -1,4 +1,4 @@ -[functionDeclaration] +[functionDefinition] parametersWrap = "Wrap" alignMultilineParameters = true newLineAfterLeftParen = true diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrap/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrap/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrapTemp/main.bal b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrapTemp/main.bal similarity index 100% rename from misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDeclaration/source/wrapTemp/main.bal rename to misc/formatter/modules/formatter-cli/src/test/resources/configurations/options/functionDefinition/source/wrapTemp/main.bal diff --git a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/projectWithModule/source/project/Format.toml b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/projectWithModule/source/project/Format.toml index f53a8a07cb6b..7435aa1545ce 100644 --- a/misc/formatter/modules/formatter-cli/src/test/resources/configurations/projectWithModule/source/project/Format.toml +++ b/misc/formatter/modules/formatter-cli/src/test/resources/configurations/projectWithModule/source/project/Format.toml @@ -5,7 +5,7 @@ continuationIndentSize = 4 maxLineLength = 80 -[functionDeclaration] +[functionDefinition] alignMultilineParameters = true newLineAfterLeftParen = true diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java index 65cbae3545c9..70b94cd7d3f9 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/FormattingTreeModifier.java @@ -252,7 +252,7 @@ import org.ballerinalang.formatter.core.options.BraceStyle; import org.ballerinalang.formatter.core.options.FormattingOptions; import org.ballerinalang.formatter.core.options.FunctionCallFormattingOptions; -import org.ballerinalang.formatter.core.options.FunctionDeclFormattingOptions; +import org.ballerinalang.formatter.core.options.FunctionDefFormattingOptions; import org.ballerinalang.formatter.core.options.WrappingMethod; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -374,7 +374,7 @@ public ResourcePathParameterNode transform(ResourcePathParameterNode resourcePat @Override public FunctionSignatureNode transform(FunctionSignatureNode functionSignatureNode) { int parenTrailingNL = 0; - FunctionDeclFormattingOptions funcOptions = options.functionDeclFormattingOptions(); + FunctionDefFormattingOptions funcOptions = options.functionDefFormattingOptions(); if (hasNonWSMinutiae(functionSignatureNode.openParenToken().trailingMinutiae()) || funcOptions.newLineAfterLeftParen()) { parenTrailingNL++; @@ -4269,7 +4269,7 @@ private boolean shouldWrapLine(Node node, Node parent) { case REQUIRED_PARAM: case REST_PARAM: case RETURN_TYPE_DESCRIPTOR: - if (options.functionDeclFormattingOptions().parametersWrap() == WrappingMethod.NoWrap) { + if (options.functionDefFormattingOptions().parametersWrap() == WrappingMethod.NoWrap) { return false; } return true; diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormatSection.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormatSection.java index 0a812485641f..4a6bedd7b776 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormatSection.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormatSection.java @@ -25,7 +25,7 @@ public enum FormatSection { BRACES("braces"), FUNCTION_CALL("functionCall"), - FUNCTION_DECLARATION("functionDeclaration"), + FUNCTION_DEFINITION("functionDefinition"), IF_STATEMENT("ifStatement"), IMPORT("import"), INDENT("indent"), diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormattingOptions.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormattingOptions.java index 5626f20fc18f..ccf9191dd8e7 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormattingOptions.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FormattingOptions.java @@ -34,7 +34,7 @@ public class FormattingOptions { private final IndentFormattingOptions indentFormattingOptions; private final WrappingFormattingOptions wrappingFormattingOptions; private final BraceFormattingOptions braceFormattingOptions; - private final FunctionDeclFormattingOptions functionDeclFormattingOptions; + private final FunctionDefFormattingOptions functionDefFormattingOptions; private final FunctionCallFormattingOptions functionCallFormattingOptions; private final IfStatementFormattingOptions ifStatementFormattingOptions; private final SpacingFormattingOptions spacingFormattingOptions; @@ -45,7 +45,7 @@ public class FormattingOptions { private FormattingOptions(IndentFormattingOptions indentFormattingOptions, WrappingFormattingOptions wrappingFormattingOptions, BraceFormattingOptions braceFormattingOptions, - FunctionDeclFormattingOptions functionDeclFormattingOptions, + FunctionDefFormattingOptions functionDefFormattingOptions, FunctionCallFormattingOptions functionCallFormattingOptions, IfStatementFormattingOptions ifStatementFormattingOptions, SpacingFormattingOptions spacingFormattingOptions, @@ -55,7 +55,7 @@ private FormattingOptions(IndentFormattingOptions indentFormattingOptions, this.indentFormattingOptions = indentFormattingOptions; this.wrappingFormattingOptions = wrappingFormattingOptions; this.braceFormattingOptions = braceFormattingOptions; - this.functionDeclFormattingOptions = functionDeclFormattingOptions; + this.functionDefFormattingOptions = functionDefFormattingOptions; this.functionCallFormattingOptions = functionCallFormattingOptions; this.ifStatementFormattingOptions = ifStatementFormattingOptions; this.spacingFormattingOptions = spacingFormattingOptions; @@ -84,8 +84,8 @@ public BraceFormattingOptions braceFormattingOptions() { return braceFormattingOptions; } - public FunctionDeclFormattingOptions functionDeclFormattingOptions() { - return functionDeclFormattingOptions; + public FunctionDefFormattingOptions functionDefFormattingOptions() { + return functionDefFormattingOptions; } public FunctionCallFormattingOptions functionCallFormattingOptions() { @@ -122,8 +122,8 @@ public static class FormattingOptionsBuilder { private IndentFormattingOptions indentFormattingOptions = IndentFormattingOptions.builder().build(); private WrappingFormattingOptions wrappingFormattingOptions = WrappingFormattingOptions.builder().build(); private BraceFormattingOptions braceFormattingOptions = BraceFormattingOptions.builder().build(); - private FunctionDeclFormattingOptions functionDeclFormattingOptions = - FunctionDeclFormattingOptions.builder().build(); + private FunctionDefFormattingOptions functionDefFormattingOptions = + FunctionDefFormattingOptions.builder().build(); private FunctionCallFormattingOptions functionCallFormattingOptions = FunctionCallFormattingOptions.builder().build(); private IfStatementFormattingOptions ifStatementFormattingOptions = @@ -175,7 +175,7 @@ public FormattingOptionsBuilder setWrappingFormattingOptions( public FormattingOptions build() { return new FormattingOptions(indentFormattingOptions, wrappingFormattingOptions, braceFormattingOptions, - functionDeclFormattingOptions, functionCallFormattingOptions, ifStatementFormattingOptions, + functionDefFormattingOptions, functionCallFormattingOptions, ifStatementFormattingOptions, spacingFormattingOptions, forceFormattingOptions, importFormattingOptions, queryFormattingOptions); } @@ -197,8 +197,8 @@ public FormattingOptions build(Path root, Object formatSection) throws Formatter case INDENT -> indentFormattingOptions = IndentFormattingOptions.builder().build(configs); case WRAPPING -> wrappingFormattingOptions = WrappingFormattingOptions.builder().build(configs); case BRACES -> braceFormattingOptions = BraceFormattingOptions.builder().build(configs); - case FUNCTION_DECLARATION -> - functionDeclFormattingOptions = FunctionDeclFormattingOptions.builder().build(configs); + case FUNCTION_DEFINITION -> + functionDefFormattingOptions = FunctionDefFormattingOptions.builder().build(configs); case FUNCTION_CALL -> functionCallFormattingOptions = FunctionCallFormattingOptions.builder().build(configs); case IF_STATEMENT -> diff --git a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDeclFormattingOptions.java b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDefFormattingOptions.java similarity index 63% rename from misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDeclFormattingOptions.java rename to misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDefFormattingOptions.java index 29aaaca0fffe..f6d8a72c816a 100644 --- a/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDeclFormattingOptions.java +++ b/misc/formatter/modules/formatter-core/src/main/java/org/ballerinalang/formatter/core/options/FunctionDefFormattingOptions.java @@ -27,15 +27,15 @@ * * @since 2201.9.0 */ -public class FunctionDeclFormattingOptions { +public class FunctionDefFormattingOptions { private final WrappingMethod parametersWrap; private final boolean alignMultilineParameters; private final boolean newLineAfterLeftParen; private final boolean rightParenOnNewLine; - private FunctionDeclFormattingOptions(WrappingMethod parametersWrap, boolean alignMultilineParameters, - boolean newLineAfterLeftParen, boolean rightParenOnNewLine) { + private FunctionDefFormattingOptions(WrappingMethod parametersWrap, boolean alignMultilineParameters, + boolean newLineAfterLeftParen, boolean rightParenOnNewLine) { this.parametersWrap = parametersWrap; this.alignMultilineParameters = alignMultilineParameters; this.newLineAfterLeftParen = newLineAfterLeftParen; @@ -58,64 +58,64 @@ public boolean rightParenOnNewLine() { return rightParenOnNewLine; } - public static FunctionDeclFormattingOptionsBuilder builder() { - return new FunctionDeclFormattingOptions.FunctionDeclFormattingOptionsBuilder(); + public static FunctionDefFormattingOptionsBuilder builder() { + return new FunctionDefFormattingOptionsBuilder(); } - public static class FunctionDeclFormattingOptionsBuilder { + public static class FunctionDefFormattingOptionsBuilder { private static final String PARAMETERS_WRAP = "parametersWrap"; private static final String ALIGN_MULTILINE_PARAMETERS = "alignMultilineParameters"; private static final String NEWLINE_AFTER_LEFT_PAREN = "newLineAfterLeftParen"; private static final String RIGHT_PAREN_ON_NEWLINE = "rightParenOnNewLine"; private WrappingMethod parametersWrap = - WrappingMethod.valueOf(getDefaultString(FormatSection.FUNCTION_DECLARATION, PARAMETERS_WRAP)); + WrappingMethod.valueOf(getDefaultString(FormatSection.FUNCTION_DEFINITION, PARAMETERS_WRAP)); private boolean alignMultilineParameters = - getDefaultBoolean(FormatSection.FUNCTION_DECLARATION, ALIGN_MULTILINE_PARAMETERS); + getDefaultBoolean(FormatSection.FUNCTION_DEFINITION, ALIGN_MULTILINE_PARAMETERS); private boolean newLineAfterLeftParen = - getDefaultBoolean(FormatSection.FUNCTION_DECLARATION, NEWLINE_AFTER_LEFT_PAREN); + getDefaultBoolean(FormatSection.FUNCTION_DEFINITION, NEWLINE_AFTER_LEFT_PAREN); private boolean rightParenOnNewLine = - getDefaultBoolean(FormatSection.FUNCTION_DECLARATION, RIGHT_PAREN_ON_NEWLINE); + getDefaultBoolean(FormatSection.FUNCTION_DEFINITION, RIGHT_PAREN_ON_NEWLINE); - public FunctionDeclFormattingOptionsBuilder setParametersWrap(WrappingMethod parametersWrap) { + public FunctionDefFormattingOptionsBuilder setParametersWrap(WrappingMethod parametersWrap) { this.parametersWrap = parametersWrap; return this; } - public FunctionDeclFormattingOptionsBuilder setAlignMultilineParameters(boolean alignMultilineParameters) { + public FunctionDefFormattingOptionsBuilder setAlignMultilineParameters(boolean alignMultilineParameters) { this.alignMultilineParameters = alignMultilineParameters; return this; } - public FunctionDeclFormattingOptionsBuilder setNewLineAfterLeftParen(boolean newLineAfterLeftParen) { + public FunctionDefFormattingOptionsBuilder setNewLineAfterLeftParen(boolean newLineAfterLeftParen) { this.newLineAfterLeftParen = newLineAfterLeftParen; return this; } - public FunctionDeclFormattingOptionsBuilder setRightParenOnNewLine(boolean rightParenOnNewLine) { + public FunctionDefFormattingOptionsBuilder setRightParenOnNewLine(boolean rightParenOnNewLine) { this.rightParenOnNewLine = rightParenOnNewLine; return this; } - public FunctionDeclFormattingOptions build() { - return new FunctionDeclFormattingOptions(parametersWrap, alignMultilineParameters, + public FunctionDefFormattingOptions build() { + return new FunctionDefFormattingOptions(parametersWrap, alignMultilineParameters, newLineAfterLeftParen, rightParenOnNewLine); } - public FunctionDeclFormattingOptions build(Map configs) throws FormatterException { - for (Map.Entry functionDeclarationEntry : configs.entrySet()) { - String functionDeclarationKey = functionDeclarationEntry.getKey(); - switch (functionDeclarationKey) { + public FunctionDefFormattingOptions build(Map configs) throws FormatterException { + for (Map.Entry functionDefinitionEntry : configs.entrySet()) { + String functionDefinitionKey = functionDefinitionEntry.getKey(); + switch (functionDefinitionKey) { case PARAMETERS_WRAP -> - setParametersWrap(WrappingMethod.fromString((String) functionDeclarationEntry.getValue())); + setParametersWrap(WrappingMethod.fromString((String) functionDefinitionEntry.getValue())); case ALIGN_MULTILINE_PARAMETERS -> - setAlignMultilineParameters((Boolean) functionDeclarationEntry.getValue()); + setAlignMultilineParameters((Boolean) functionDefinitionEntry.getValue()); case NEWLINE_AFTER_LEFT_PAREN -> - setNewLineAfterLeftParen((Boolean) functionDeclarationEntry.getValue()); + setNewLineAfterLeftParen((Boolean) functionDefinitionEntry.getValue()); case RIGHT_PAREN_ON_NEWLINE -> - setRightParenOnNewLine((Boolean) functionDeclarationEntry.getValue()); + setRightParenOnNewLine((Boolean) functionDefinitionEntry.getValue()); default -> throw new FormatterException( - "invalid function declaration formatting option: " + functionDeclarationKey); + "invalid function definition formatting option: " + functionDefinitionKey); } } return build(); diff --git a/misc/formatter/modules/formatter-core/src/main/resources/format-toml-schema.json b/misc/formatter/modules/formatter-core/src/main/resources/format-toml-schema.json index 7542b6e61911..58ac484cc42a 100644 --- a/misc/formatter/modules/formatter-core/src/main/resources/format-toml-schema.json +++ b/misc/formatter/modules/formatter-core/src/main/resources/format-toml-schema.json @@ -47,7 +47,7 @@ } } }, - "functionDeclaration": { + "functionDefinition": { "type": "object", "additionalProperties": false, "properties": { diff --git a/misc/formatter/modules/formatter-core/src/main/resources/formatter.properties b/misc/formatter/modules/formatter-core/src/main/resources/formatter.properties index 7445b4293dac..5032c3635571 100644 --- a/misc/formatter/modules/formatter-core/src/main/resources/formatter.properties +++ b/misc/formatter/modules/formatter-core/src/main/resources/formatter.properties @@ -21,10 +21,10 @@ functionCall.alignMultilineArguments=false functionCall.newLineAfterLeftParen=false functionCall.rightParenOnNewLine=false -functionDeclaration.parametersWrap=Wrap -functionDeclaration.alignMultilineParameters=false -functionDeclaration.newLineAfterLeftParen=false -functionDeclaration.rightParenOnNewLine=false +functionDefinition.parametersWrap=Wrap +functionDefinition.alignMultilineParameters=false +functionDefinition.newLineAfterLeftParen=false +functionDefinition.rightParenOnNewLine=false ifStatement.elseOnNewLine=false diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatFileResolutionTest.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatFileResolutionTest.java index 03a625ba6c0c..ce3fe382a2d6 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatFileResolutionTest.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatFileResolutionTest.java @@ -36,7 +36,7 @@ public class FormatFileResolutionTest { private final Path resDir = Path.of("src", "test", "resources", "configurations", "resolution"); private final String validRemoteUrl = "https://gist.githubusercontent.com/ballerina-bot/ae54cc7303e9d474d730d732c1594c61/raw" + - "/db0909d0b66f97cd0035f19bcb7cde9a239f5d54/format.toml"; + "/8dc3204aec3f158105a811a6a67488bef45ff742/format.toml"; private final Path validRemote = resDir.resolve("validRemote"); private final Path withTarget = resDir.resolve("withTarget"); private final Path invalidLocal = resDir.resolve("invalidLocal"); diff --git a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatOptionNegativeTest.java b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatOptionNegativeTest.java index 933bdaef05ae..4736fccfa1ad 100644 --- a/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatOptionNegativeTest.java +++ b/misc/formatter/modules/formatter-core/src/test/java/org/ballerinalang/formatter/core/configurations/FormatOptionNegativeTest.java @@ -23,7 +23,7 @@ import org.ballerinalang.formatter.core.options.BraceStyle; import org.ballerinalang.formatter.core.options.FormatSection; import org.ballerinalang.formatter.core.options.FunctionCallFormattingOptions; -import org.ballerinalang.formatter.core.options.FunctionDeclFormattingOptions; +import org.ballerinalang.formatter.core.options.FunctionDefFormattingOptions; import org.ballerinalang.formatter.core.options.IfStatementFormattingOptions; import org.ballerinalang.formatter.core.options.ImportFormattingOptions; import org.ballerinalang.formatter.core.options.IndentFormattingOptions; @@ -68,8 +68,8 @@ public void testInvalidFunctionCallOptions() throws FormatterException { } @Test(expectedExceptions = FormatterException.class, - expectedExceptionsMessageRegExp = "invalid function declaration formatting option: parametersInLine") - public void testInvalidFunctionDeclarationOptions() throws FormatterException { + expectedExceptionsMessageRegExp = "invalid function definition formatting option: parametersInLine") + public void testInvalidFunctionDefinitionOptions() throws FormatterException { Map configs = new HashMap<>() {{ put("parametersWrap", "Wrap"); put("newLineAfterLeftParen", true); @@ -77,7 +77,7 @@ public void testInvalidFunctionDeclarationOptions() throws FormatterException { put("rightParenOnNewLine", true); put("parametersInLine", true); }}; - FunctionDeclFormattingOptions.builder().build(configs); + FunctionDefFormattingOptions.builder().build(configs); } @Test(expectedExceptions = FormatterException.class, diff --git a/misc/formatter/modules/formatter-core/src/test/resources/configurations/remote/source/Ballerina.toml b/misc/formatter/modules/formatter-core/src/test/resources/configurations/remote/source/Ballerina.toml index 4fa2b95cd975..176784afabdd 100644 --- a/misc/formatter/modules/formatter-core/src/test/resources/configurations/remote/source/Ballerina.toml +++ b/misc/formatter/modules/formatter-core/src/test/resources/configurations/remote/source/Ballerina.toml @@ -1,2 +1,2 @@ [format] -configPath = "https://gist.githubusercontent.com/ballerina-bot/ae54cc7303e9d474d730d732c1594c61/raw/cca92fd7156172057a4957edd47f1e1bd349b2ae/format.toml" +configPath = "https://gist.githubusercontent.com/ballerina-bot/ae54cc7303e9d474d730d732c1594c61/raw/8dc3204aec3f158105a811a6a67488bef45ff742/format.toml" diff --git a/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/invalid/Format.toml b/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/invalid/Format.toml index 78d3c109de72..786888481362 100644 --- a/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/invalid/Format.toml +++ b/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/invalid/Format.toml @@ -11,7 +11,7 @@ simpleFunctionsInOneLine = "true" classBraceStyle = "NEWLINE" functionBraceStyle = "NEWLINE" -[functionDeclaration] +[functionDefinition] parametersWrap = "CHOPDOWN" paramterExtend = true diff --git a/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/valid/Format.toml b/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/valid/Format.toml index b60765cbdc29..285f78a79845 100644 --- a/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/valid/Format.toml +++ b/misc/formatter/modules/formatter-core/src/test/resources/configurations/validator/valid/Format.toml @@ -11,7 +11,7 @@ simpleFunctionsInOneLine = true classBraceStyle = "NewLine" functionBraceStyle = "NewLine" -[functionDeclaration] +[functionDefinition] parametersWrap = "ChopDown" alignMultilineParameters = true newLineAfterLeftParen = false