diff --git a/zclwrite/parser.go b/zclwrite/parser.go index cd32254..add9ffd 100644 --- a/zclwrite/parser.go +++ b/zclwrite/parser.go @@ -194,8 +194,6 @@ func parseBodyItem(nativeItem zclsyntax.Node, from inputTokens) (inputTokens, No switch tItem := nativeItem.(type) { case *zclsyntax.Attribute: item = parseAttribute(tItem, within, leadComments, lineComments, newline) - // TODO: Grab the newline and any line comment from "after" and - // write them into the attribute object. case *zclsyntax.Block: // TODO: implement this panic("block parsing not yet implemented") @@ -243,7 +241,8 @@ func parseAttribute(nativeAttr *zclsyntax.Attribute, from, leadComments, lineCom } if newline.Len() > 0 { - allTokens = append(allTokens, newline.Seq()) + attr.EOLTokens = newline.Seq() + allTokens = append(allTokens, attr.EOLTokens) } // Collect any stragglers, though there shouldn't be any diff --git a/zclwrite/parser_test.go b/zclwrite/parser_test.go index 3b44495..13179df 100644 --- a/zclwrite/parser_test.go +++ b/zclwrite/parser_test.go @@ -89,6 +89,13 @@ func TestParse(t *testing.T) { }, }}, }, + EOLTokens: &TokenSeq{Tokens{ + { + Type: zclsyntax.TokenNewline, + Bytes: []byte{'\n'}, + SpacesBefore: 0, + }, + }}, }, }, AllTokens: &TokenSeq{ @@ -215,6 +222,13 @@ func TestParse(t *testing.T) { }, }}, }, + EOLTokens: &TokenSeq{Tokens{ + { + Type: zclsyntax.TokenNewline, + Bytes: []byte{'\n'}, + SpacesBefore: 0, + }, + }}, }, }, AllTokens: &TokenSeq{ @@ -451,6 +465,13 @@ func TestParse(t *testing.T) { }, }}, }, + EOLTokens: &TokenSeq{Tokens{ + { + Type: zclsyntax.TokenNewline, + Bytes: []byte{'\n'}, + SpacesBefore: 0, + }, + }}, }, }, AllTokens: &TokenSeq{