Skip to content

Fix indentation around AND and OR #98

@xterao

Description

@xterao

When AND and OR appear consecutively, the keyword elements themselves have different indentation.

  • If AND is inside a subgroup, reduce its indentation by one level compared to OR.
  • If AND follows OR, regardless of whether it’s inside a subgroup,
     treat AND as a child element of OR and lower its indentation.
  • Align the indentation of any comment block above AND or OR with that of the keyword elements themselves.

ex)

SELECT COUNT(1)
  FROM /*# x */
 WHERE x = /* Id */1
   AND x <= /* x */'2019-01-01'
   AND x >= /* x */'2019-01-01'
       /*%if x && !x.isEmpty()  */ --
   OR x IN /* x */(1, 2)
  AND id = /* x */1 --
          /*%end */  --

expectations)

SELECT COUNT(1)
  FROM /*# x */
 WHERE x = /* Id */1
   AND x <= /* x */'2019-01-01'
   AND x >= /* x */'2019-01-01'
   /*%if x && !x.isEmpty()  */ --
   OR x IN /* x */(1, 2)
      AND id = /* x */1 
   /*%end */  --
           

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions