diff options
| author | griesemer <gri@golang.org> | 2017-10-23 10:48:46 -0700 |
|---|---|---|
| committer | Robert Griesemer <gri@golang.org> | 2017-10-23 18:10:06 +0000 |
| commit | 0316d6618c7a986727c9e99fb7aab7c7a4e92d71 (patch) | |
| tree | ab4fa2bb6c96c3cc8a1967ea344dafe1a92faa6a /src | |
| parent | 083338cb976763e7a77e787827b24228fbaa7bf3 (diff) | |
| download | go-0316d6618c7a986727c9e99fb7aab7c7a4e92d71.tar.xz | |
go/types: improved documentation for WriteExpr and ExprString
Fixes #22377.
Change-Id: I0a0e1bde558df964f0961dc4cfc305e72d590e1a
Reviewed-on: https://go-review.googlesource.com/72690
Reviewed-by: Alan Donovan <adonovan@google.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/go/types/exprstring.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/go/types/exprstring.go b/src/go/types/exprstring.go index 370bdf3532..28d605f5ee 100644 --- a/src/go/types/exprstring.go +++ b/src/go/types/exprstring.go @@ -11,14 +11,18 @@ import ( "go/ast" ) -// ExprString returns the (possibly simplified) string representation for x. +// ExprString returns the (possibly shortened) string representation for x. +// Shortened representations are suitable for user interfaces but may not +// necessarily follow Go syntax. func ExprString(x ast.Expr) string { var buf bytes.Buffer WriteExpr(&buf, x) return buf.String() } -// WriteExpr writes the (possibly simplified) string representation for x to buf. +// WriteExpr writes the (possibly shortened) string representation for x to buf. +// Shortened representations are suitable for user interfaces but may not +// necessarily follow Go syntax. func WriteExpr(buf *bytes.Buffer, x ast.Expr) { // The AST preserves source-level parentheses so there is // no need to introduce them here to correct for different @@ -44,12 +48,12 @@ func WriteExpr(buf *bytes.Buffer, x ast.Expr) { case *ast.FuncLit: buf.WriteByte('(') WriteExpr(buf, x.Type) - buf.WriteString(" literal)") // simplified + buf.WriteString(" literal)") // shortened case *ast.CompositeLit: buf.WriteByte('(') WriteExpr(buf, x.Type) - buf.WriteString(" literal)") // simplified + buf.WriteString(" literal)") // shortened case *ast.ParenExpr: buf.WriteByte('(') |
