LEFT | RIGHT |
(no file at all) | |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 // Api computes the exported API of a set of Go packages. | 5 // Api computes the exported API of a set of Go packages. |
6 // | 6 // |
7 // BUG(bradfitz): Note that this tool is only currently suitable | 7 // BUG(bradfitz): Note that this tool is only currently suitable |
8 // for use on the Go standard library, not arbitrary packages. | 8 // for use on the Go standard library, not arbitrary packages. |
9 // Once the Go AST has type information, this tool will be more | 9 // Once the Go AST has type information, this tool will be more |
10 // reliable without hard-coded hacks throughout. | 10 // reliable without hard-coded hacks throughout. |
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
716 // until the Go AST has type information. | 716 // until the Go AST has type information. |
717 nodeStr := w.nodeString(v.Fun) | 717 nodeStr := w.nodeString(v.Fun) |
718 switch nodeStr { | 718 switch nodeStr { |
719 case "string", "[]byte": | 719 case "string", "[]byte": |
720 return nodeStr, nil | 720 return nodeStr, nil |
721 } | 721 } |
722 return "", fmt.Errorf("not a known function %q", nodeStr) | 722 return "", fmt.Errorf("not a known function %q", nodeStr) |
723 default: | 723 default: |
724 return "", fmt.Errorf("unknown const value type %T", vi) | 724 return "", fmt.Errorf("unknown const value type %T", vi) |
725 } | 725 } |
726 panic("unreachable") | |
727 } | 726 } |
728 | 727 |
729 // resolveName finds a top-level node named name and returns the node | 728 // resolveName finds a top-level node named name and returns the node |
730 // v and its type t, if known. | 729 // v and its type t, if known. |
731 func (w *Walker) resolveName(name string) (v interface{}, t interface{}, ok bool
) { | 730 func (w *Walker) resolveName(name string) (v interface{}, t interface{}, ok bool
) { |
732 for _, file := range w.curPackage.Files { | 731 for _, file := range w.curPackage.Files { |
733 for _, di := range file.Decls { | 732 for _, di := range file.Decls { |
734 switch d := di.(type) { | 733 switch d := di.(type) { |
735 case *ast.GenDecl: | 734 case *ast.GenDecl: |
736 switch d.Tok { | 735 switch d.Tok { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1175 } | 1174 } |
1176 | 1175 |
1177 func strListContains(l []string, s string) bool { | 1176 func strListContains(l []string, s string) bool { |
1178 for _, v := range l { | 1177 for _, v := range l { |
1179 if v == s { | 1178 if v == s { |
1180 return true | 1179 return true |
1181 } | 1180 } |
1182 } | 1181 } |
1183 return false | 1182 return false |
1184 } | 1183 } |
LEFT | RIGHT |