-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Copy link
Labels
Description
Adjusting Line Breaks and Indentation for Elements Surrounded by Directive Comments
Problem Overview
Currently, when SQL standard conditions or literal directives are surrounded by conditional directives, they are not line-broken and end up appearing inline next to the directive comments, which reduces readability. For example:
SELECT *
FROM employee emp
LEFT JOIN users usr
ON user.id = emp.id
WHERE emp.number = /*entity.number*/'111'
/*%if entity.id > 100 */
AND
/*%for project : entity.projects*/ number = /* entity.number */'000'
/*%if project_has_next */ /*# "OR"*/
/*%end */
/*%end */
/*%end */In this example:
- The
ANDclause and the looped condition (number = ...) get cramped next to directive comments like/*%for*/and/*%if*/ - This makes the SQL visually confusing and hard to maintain
Expected Behavior / Specification
1. Always insert line breaks before and after conditional and loop directives
Regardless of what follows, the formatter must:
- Add a line break before every directive like
/*%if*/,/*%for*/,/*%end*/ - Add a line break after every directive unless the next element is another directive of the same block (in which case indentation is still maintained)
2. Indent content inside directive blocks properly
For example, if a WHERE clause contains a directive block, all inner conditions must be indented consistently:
WHERE emp.number = /*entity.number*/'111'
/*%if entity.id > 100 */
AND
/*%for project : entity.projects*/
number = /* entity.number */'000'
/*%if project_has_next */
/*# "OR"*/
/*%end */
/*%end */
/*%end */