zclwrite: format shouldn't add spaces around attribute access dots

This commit is contained in:
Martin Atkins 2017-06-24 09:08:49 -07:00
parent d1fb42746b
commit cab61b36dc
2 changed files with 8 additions and 0 deletions

View File

@ -231,6 +231,10 @@ func spaceAfterToken(subject, before, after *Token) bool {
// Don't split a function name from open paren in a call // Don't split a function name from open paren in a call
return false return false
case subject.Type == zclsyntax.TokenDot || after.Type == zclsyntax.TokenDot:
// Don't use spaces around attribute access dots
return false
case after.Type == zclsyntax.TokenComma: case after.Type == zclsyntax.TokenComma:
// No space right before a comma in an argument list // No space right before a comma in an argument list
return false return false

View File

@ -23,6 +23,10 @@ func TestFormat(t *testing.T) {
`a=1`, `a=1`,
`a = 1`, `a = 1`,
}, },
{
`a=b.c`,
`a = b.c`,
},
{ {
`( a+2 )`, `( a+2 )`,
`(a + 2)`, `(a + 2)`,