From 50193ec1c508c7b5714160a9c0979366fbbcabb4 Mon Sep 17 00:00:00 2001 From: Alan Donovan Date: Thu, 3 Nov 2016 17:52:54 -0400 Subject: go/ast/astutil: support Go 1.8 type aliases Change-Id: I67d561755c1c06c0438f2b42e6a13efb024558c4 Reviewed-on: https://go-review.googlesource.com/32732 Reviewed-by: Robert Griesemer --- go/ast/astutil/enclosing18.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'go/ast') diff --git a/go/ast/astutil/enclosing18.go b/go/ast/astutil/enclosing18.go index af897cb0b..4a91c1d3b 100644 --- a/go/ast/astutil/enclosing18.go +++ b/go/ast/astutil/enclosing18.go @@ -200,6 +200,11 @@ func childrenOf(n ast.Node) []ast.Node { // Then add fake Nodes for bare tokens. switch n := n.(type) { + case *ast.AliasSpec: + // TODO(adonovan): AliasSpec.{Doc,Comment}? + // Guess position of "=>" assuming well-formattedness. + children = append(children, tok(n.Orig.Pos()-token.Pos(len("=> ")), len("=>"))) + case *ast.ArrayType: children = append(children, tok(n.Lbrack, len("[")), @@ -623,7 +628,8 @@ func NodeDescription(n ast.Node) string { return fmt.Sprintf("unary %s operation", n.Op) case *ast.ValueSpec: return "value specification" - + case *ast.AliasSpec: + return "alias specification" } panic(fmt.Sprintf("unexpected node type: %T", n)) } -- cgit v1.2.3