summaryrefslogtreecommitdiff
path: root/vendor/golang.org/x/tools/go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/tools/go')
-rw-r--r--vendor/golang.org/x/tools/go/ast/astutil/enclosing.go21
-rw-r--r--vendor/golang.org/x/tools/go/ast/astutil/rewrite.go4
-rw-r--r--vendor/golang.org/x/tools/go/types/objectpath/objectpath.go2
3 files changed, 20 insertions, 7 deletions
diff --git a/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go b/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go
index 6e34df461..89f5097be 100644
--- a/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go
+++ b/vendor/golang.org/x/tools/go/ast/astutil/enclosing.go
@@ -207,6 +207,9 @@ func childrenOf(n ast.Node) []ast.Node {
return false // no recursion
})
+ // TODO(adonovan): be more careful about missing (!Pos.Valid)
+ // tokens in trees produced from invalid input.
+
// Then add fake Nodes for bare tokens.
switch n := n.(type) {
case *ast.ArrayType:
@@ -226,9 +229,12 @@ func childrenOf(n ast.Node) []ast.Node {
children = append(children, tok(n.OpPos, len(n.Op.String())))
case *ast.BlockStmt:
- children = append(children,
- tok(n.Lbrace, len("{")),
- tok(n.Rbrace, len("}")))
+ if n.Lbrace.IsValid() {
+ children = append(children, tok(n.Lbrace, len("{")))
+ }
+ if n.Rbrace.IsValid() {
+ children = append(children, tok(n.Rbrace, len("}")))
+ }
case *ast.BranchStmt:
children = append(children,
@@ -304,9 +310,12 @@ func childrenOf(n ast.Node) []ast.Node {
// TODO(adonovan): Field.{Doc,Comment,Tag}?
case *ast.FieldList:
- children = append(children,
- tok(n.Opening, len("(")), // or len("[")
- tok(n.Closing, len(")"))) // or len("]")
+ if n.Opening.IsValid() {
+ children = append(children, tok(n.Opening, len("(")))
+ }
+ if n.Closing.IsValid() {
+ children = append(children, tok(n.Closing, len(")")))
+ }
case *ast.File:
// TODO test: Doc
diff --git a/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go b/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go
index 5c8dbbb7a..4ad054930 100644
--- a/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go
+++ b/vendor/golang.org/x/tools/go/ast/astutil/rewrite.go
@@ -67,6 +67,10 @@ var abort = new(int) // singleton, to signal termination of Apply
//
// The methods Replace, Delete, InsertBefore, and InsertAfter
// can be used to change the AST without disrupting Apply.
+//
+// This type is not to be confused with [inspector.Cursor] from
+// package [golang.org/x/tools/go/ast/inspector], which provides
+// stateless navigation of immutable syntax trees.
type Cursor struct {
parent ast.Node
name string
diff --git a/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go b/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go
index 16ed3c178..d3c2913be 100644
--- a/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go
+++ b/vendor/golang.org/x/tools/go/types/objectpath/objectpath.go
@@ -603,7 +603,7 @@ func Object(pkg *types.Package, p Path) (types.Object, error) {
type hasTypeParams interface {
TypeParams() *types.TypeParamList
}
- // abstraction of *types.{Named,TypeParam}
+ // abstraction of *types.{Alias,Named,TypeParam}
type hasObj interface {
Obj() *types.TypeName
}