Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CodeFormatter: One-line formatting and whitespace #7

Open
ldoblies opened this issue Jan 21, 2013 · 0 comments
Open

CodeFormatter: One-line formatting and whitespace #7

ldoblies opened this issue Jan 21, 2013 · 0 comments

Comments

@ldoblies
Copy link
Contributor

One-line formatting gets messed up by unexpected whitespace placement in the syntax tree.

As of now, one-line formatting for certain nodes (e.g. a ReturnClause) is only applied if the
input is also on one line.
E.g.

if ($a) then $b else $c

is left as is, while

if ($a) then $b else
$c 

is formatted to

if ($a) then
  $b
else
  $c

because the input is not on one line.

WS in the AST after certain nodes messes this up, e.g.

for $i in (let, for)
return return

is formatted to

for $i in (let, for)
return
    return

because of a '\n' being part of the ReturnClause (it is unclear to me why this WS node is or should be a child of the ReturnClause). Could be fixed by removing WS that have no semantic impact from the end of nodes (and moving it to the parent node).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant