Skip to content

Commit ec67705

Browse files
update custom format, snapshot version of 22.1.0
1 parent f5f09fc commit ec67705

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed

formatter/trivadis_custom_format.arbori

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
include "std.arbori"
1818

1919
/**
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
2121
* The idea is to keep the code formatted "as is" and apply chosen formatting rules only.
2222
*
2323
* The Arbori program is processed from top to bottom.
@@ -889,6 +889,7 @@ i9_remove_duplicate_spaces_in_scope:
889889
-- - A23: Enforce line break after single line comments.
890890
-- - R2: 3 space indention.
891891
-- - R7: SQL keywords are right aligned within a SQL command.
892+
-- - A24: Indent case expression.
892893
-- - A11: Align parameter names.
893894
-- - A10: Align parameter modes.
894895
-- - O8: Alignment: Type Declarations. Options: true; false. (alignTypeDecl).
@@ -1027,6 +1028,7 @@ a22_no_space_between_sign_and_digits:
10271028
& ![node-1) digits
10281029
& ![node-1) expr
10291030
-> {
1031+
var node = tuple.get("node");
10301032
struct.putNewline(node.to, "");
10311033
logger.fine(struct.getClass(), "a22_no_space_between_sign_and_digits: at " + node.to + ".");
10321034
}
@@ -3171,22 +3173,6 @@ r2_fix_indent_for_subquery_in_paren:
31713173
}
31723174
}
31733175

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-
31903176
-- --------------------------------------------------------------------------------------------------------------------
31913177
-- R7: SQL keywords are right aligned within a SQL command.
31923178
-- --------------------------------------------------------------------------------------------------------------------
@@ -3445,6 +3431,28 @@ r7_right_align_and_or:
34453431
rightAlign(tuple, "r7_right_align_and_or");
34463432
}
34473433

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+
34483456
-- --------------------------------------------------------------------------------------------------------------------
34493457
-- A11: Align parameter names.
34503458
-- --------------------------------------------------------------------------------------------------------------------

0 commit comments

Comments
 (0)