]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: improved documentation for WriteExpr and ExprString
authorgriesemer <gri@golang.org>
Mon, 23 Oct 2017 17:48:46 +0000 (10:48 -0700)
committerRobert Griesemer <gri@golang.org>
Mon, 23 Oct 2017 18:10:06 +0000 (18:10 +0000)
Fixes #22377.

Change-Id: I0a0e1bde558df964f0961dc4cfc305e72d590e1a
Reviewed-on: https://go-review.googlesource.com/72690
Reviewed-by: Alan Donovan <adonovan@google.com>
src/go/types/exprstring.go

index 370bdf35324ca7265430470fd40de3a321daef8b..28d605f5ee8410a08fff044bfa5be2f571a2922b 100644 (file)
@@ -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('(')