]> Cypherpunks repositories - gostls13.git/commit
go/ast: hide unexported fields in composite literals
authorAgniva De Sarker <agnivade@yahoo.co.in>
Wed, 4 Apr 2018 09:29:27 +0000 (14:59 +0530)
committerRobert Griesemer <gri@golang.org>
Tue, 1 May 2018 19:53:32 +0000 (19:53 +0000)
commitc2366b27abe7e18b1b5642e5a9a009f5c41723ae
tree194b1323f7f016496ed37ccb0a78400d01825dc9
parent548e1f89363fd3054a0bd8961c6c6b8b8ecbcfaf
go/ast: hide unexported fields in composite literals

In ast/ast.go, added an Incomplete field inside CompositeLit
to denote that fields are missing.

In ast/filter.go, added a new function to go through the expression list
checking for KeyValue expressions inside composite literals.
Filter out entries with an unexported key.

In printer/nodes.go, checking if the Incomplete field is set,
and accordingly print the filtered message with proper indentation.

Copying over similar functionality in doc/exports.go so as to
maintain parity with ast/filter.go and such that godoc
can show the output correctly.

Fixes #22803

Change-Id: I57a3b999521933e32411a18e02d0b94d2ea2e6f6
Reviewed-on: https://go-review.googlesource.com/106395
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/ast/ast.go
src/go/ast/filter.go
src/go/doc/exports.go
src/go/printer/nodes.go
src/go/printer/printer_test.go
src/go/printer/testdata/complit.input [new file with mode: 0644]
src/go/printer/testdata/complit.x [new file with mode: 0644]