Closed lucaswerkmeister closed 9 years ago
“Perhaps” here having the meaning of “I’ve been aware of this problem for a while, and didn’t want to care about it, but I’ve reached the point where I probably can’t ignore it any longer, and any “yes please” feedback will make me do this change.”
Do it :)
Sent from my iPhone
On 30 Oct 2014, at 9:49 pm, Lucas Werkmeister notifications@github.com wrote:
“Perhaps” here having the meaning of “I’ve been aware of this problem for a while, and didn’t want to care about it, but I’ve reached the point where I probably can’t ignore it any longer, and any “yes please” feedback will make me do this change.”
— Reply to this email directly or view it on GitHub.
Fine ;)
On 31.10.2014 00:23, Gavin King wrote:
Do it :)
Sent from my iPhone
On 30 Oct 2014, at 9:49 pm, Lucas Werkmeister notifications@github.com wrote:
“Perhaps” here having the meaning of “I’ve been aware of this problem for a while, and didn’t want to care about it, but I’ve reached the point where I probably can’t ignore it any longer, and any “yes please” feedback will make me do this change.”
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHub https://github.com/ceylon/ceylon.formatter/issues/99#issuecomment-61187520.
Hm, should this also apply to parentheses? I’m a bit uncertain about
(1..j).fold(1, (Integer a, Integer b) => a*b)+1
where perhaps
(1..j).fold(1, (Integer a, Integer b) => a*b) + 1
would be better?
Oh… and this is also not really pretty:
1+2 + 3
Another case: I don’t like the look of e.key==e.item
.
On the other hand, I could totally see a==b && x==y
.
So what’s the rule here? Only omit the spaces within a larger expression?
How about this?
Omit spaces if
BinaryOperatorExpression
(done by calling visitBinaryOperatorExpression_nested(that.leftTerm)
or something like that in visitBinaryOperatorExpression
), andLiteral
, BaseMemberExpression
, or QualifiedMemberExpression
, orBinaryOperatorExpression
and have their spaces omitted themselves.resulting in
1 + 2 + 3
x*y*z - a*b*c
a==b && c==d
Well, that maybe makes a lot of sense.
Okay, so with a few tweaks, the worst remaining wart is:
- value diff = token.stopIndex - token.startIndex - token.text.size + 1;
+ value diff = token.stopIndex-token.startIndex - token.text.size + 1;
So “the same kind of BinaryOperatorExpression
” needs to mean “the same precedence”, not “the same type” (type(x) == type(y)
).
Okay, done in the 99
branch. It would be great if someone else could go over a47093c4ad42e4580448b5f5acaa7da389e65e01 and 5e66b5cd20306d4a4df447234f9d045b93139de7 and tell me if the changes look acceptable.
From the let expressions sample:
That seems a bit… excessive. Perhaps we should add an option to omit the spaces if both operands are atoms.