eclipse-archived / ceylon.formatter

A formatter for the Ceylon programming language, written in Ceylon.
Apache License 2.0
14 stars 11 forks source link

Spacing of range operators #35

Closed lucaswerkmeister closed 10 years ago

lucaswerkmeister commented 10 years ago
// hand-written, doesn’t work because I can’t influence spacing inside l/r expressions
complex+expression-foo..complex+expression-bar
// current formatted result – confusing because precedence different than spacing
complex + expression - foo..complex + expression - bar
// better?
complex + expression - foo .. complex + expression - bar

Same for : and ....

lucaswerkmeister commented 10 years ago

How about this: No spaces around the operators if l+r expression are

otherwise, spaces.

gavinking commented 10 years ago

Or

lucaswerkmeister commented 10 years ago

Oh, right. So, Expression with mainToken exists.

lucaswerkmeister commented 10 years ago

No, Expression with (mainToken?.text else "") == "(". a - b is an expression with a mainToken as well.

lucaswerkmeister commented 10 years ago

Okay, the type hierarchy had me confused for a bit… most XYZExpression classes don’t extend Expression. The condition is now term is Atom|Primary || (expr.mainToken?.text else "") == "(". I’ll test a few ranges, and if it looks good, I’ll commit it.

lucaswerkmeister commented 10 years ago

No, that doesn’t make sense, an Expression is an Atom.

lucaswerkmeister commented 10 years ago

I guess this also applies to EntryOp (1->2).