|
17 | 17 | include "std.arbori" |
18 | 18 |
|
19 | 19 | /** |
20 | | - * Lightweight Formatter for SQL Developer and SQLcl, version 21.4.3 |
| 20 | + * Lightweight Formatter for SQL Developer and SQLcl, version 22.1.0-SNAPSHOT |
21 | 21 | * The idea is to keep the code formatted "as is" and apply chosen formatting rules only. |
22 | 22 | * |
23 | 23 | * The Arbori program is processed from top to bottom. |
@@ -889,6 +889,7 @@ i9_remove_duplicate_spaces_in_scope: |
889 | 889 | -- - A23: Enforce line break after single line comments. |
890 | 890 | -- - R2: 3 space indention. |
891 | 891 | -- - R7: SQL keywords are right aligned within a SQL command. |
| 892 | +-- - A24: Indent case expression. |
892 | 893 | -- - A11: Align parameter names. |
893 | 894 | -- - A10: Align parameter modes. |
894 | 895 | -- - O8: Alignment: Type Declarations. Options: true; false. (alignTypeDecl). |
@@ -1027,6 +1028,7 @@ a22_no_space_between_sign_and_digits: |
1027 | 1028 | & ![node-1) digits |
1028 | 1029 | & ![node-1) expr |
1029 | 1030 | -> { |
| 1031 | + var node = tuple.get("node"); |
1030 | 1032 | struct.putNewline(node.to, ""); |
1031 | 1033 | logger.fine(struct.getClass(), "a22_no_space_between_sign_and_digits: at " + node.to + "."); |
1032 | 1034 | } |
@@ -3171,22 +3173,6 @@ r2_fix_indent_for_subquery_in_paren: |
3171 | 3173 | } |
3172 | 3174 | } |
3173 | 3175 |
|
3174 | | -r2_fix_indent_for_case_expr: |
3175 | | - ([parent) case_expr | [parent) case_expression) |
3176 | | - & [endcase) 'END' |
3177 | | - & endcase^ = parent |
3178 | | --> { |
3179 | | - var parent = tuple.get("parent"); |
3180 | | - if (getIndent(parent.from).indexOf("\n") == -1) { |
3181 | | - var endcase = tuple.get("endcase"); |
3182 | | - var marginDiff = getColumn(parent.from) - getColumn(endcase.from); |
3183 | | - if (marginDiff > 0) { |
3184 | | - addIndent(parent, marginDiff); |
3185 | | - logger.fine(struct.getClass(), "r2_fix_indent_for_case_expr: at " + parent.from + "."); |
3186 | | - } |
3187 | | - } |
3188 | | -} |
3189 | | - |
3190 | 3176 | -- -------------------------------------------------------------------------------------------------------------------- |
3191 | 3177 | -- R7: SQL keywords are right aligned within a SQL command. |
3192 | 3178 | -- -------------------------------------------------------------------------------------------------------------------- |
@@ -3445,6 +3431,28 @@ r7_right_align_and_or: |
3445 | 3431 | rightAlign(tuple, "r7_right_align_and_or"); |
3446 | 3432 | } |
3447 | 3433 |
|
| 3434 | +-- -------------------------------------------------------------------------------------------------------------------- |
| 3435 | +-- A24: Indent case expression. |
| 3436 | +-- -------------------------------------------------------------------------------------------------------------------- |
| 3437 | + |
| 3438 | +-- must run after right-alignment. See also #203. |
| 3439 | + |
| 3440 | +a24_indent_case_expression: |
| 3441 | + ([parent) case_expr | [parent) case_expression) |
| 3442 | + & [endcase) 'END' |
| 3443 | + & endcase^ = parent |
| 3444 | +-> { |
| 3445 | + var parent = tuple.get("parent"); |
| 3446 | + if (getIndent(parent.from).indexOf("\n") == -1) { |
| 3447 | + var endcase = tuple.get("endcase"); |
| 3448 | + var marginDiff = getColumn(parent.from) - getColumn(endcase.from); |
| 3449 | + if (marginDiff > 0) { |
| 3450 | + addIndent(parent, marginDiff); |
| 3451 | + logger.fine(struct.getClass(), "a24_indent_case_expression: at " + parent.from + "."); |
| 3452 | + } |
| 3453 | + } |
| 3454 | +} |
| 3455 | + |
3448 | 3456 | -- -------------------------------------------------------------------------------------------------------------------- |
3449 | 3457 | -- A11: Align parameter names. |
3450 | 3458 | -- -------------------------------------------------------------------------------------------------------------------- |
|
0 commit comments