1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:38:33 -06:00

internal/imports: add all interfaces in mkstdlib

In api/*.txt, interface declarations are represented with lines like:
  pkg container/heap, type Interface interface { Len, Less, Pop, Push, Swap }
or, when they have no exported methods:
  pkg go/ast, type Expr interface, unexported methods

The latter form confuses mkstdlib into thinking that it's a method
because of the extra comma, and then it skips the interface entirely.
Running this program is a matter of seconds once per release, so rather
than trying to fix the optimization, just remove it. The parsing logic
doesn't care about the extra lines.

And the corresponding change to the copy in lsp/testdata/unimported.

Updates golang/go#34199

Change-Id: Ic34b8a47537608401e4ef6683617d797f9f50f8a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/194568
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
This commit is contained in:
Heschi Kreinick 2019-09-10 15:15:18 -04:00
parent 5e3480f0e0
commit d0542c01b0
3 changed files with 10 additions and 9 deletions

View File

@ -19,7 +19,6 @@ import (
"regexp"
"runtime"
"sort"
"strings"
)
func mustOpen(name string) io.Reader {
@ -75,10 +74,6 @@ func main() {
for sc.Scan() {
l := sc.Text()
has := func(v string) bool { return strings.Contains(l, v) }
if has("struct, ") || has("interface, ") || has(", method (") {
continue
}
if m := sym.FindStringSubmatch(l); m != nil {
path, sym := m[1], m[2]

View File

@ -2637,10 +2637,12 @@ var stdlib = map[string]map[string]bool{
"CommentMap": true,
"CompositeLit": true,
"Con": true,
"Decl": true,
"DeclStmt": true,
"DeferStmt": true,
"Ellipsis": true,
"EmptyStmt": true,
"Expr": true,
"ExprStmt": true,
"Field": true,
"FieldFilter": true,
@ -2701,7 +2703,9 @@ var stdlib = map[string]map[string]bool{
"SendStmt": true,
"SliceExpr": true,
"SortImports": true,
"Spec": true,
"StarExpr": true,
"Stmt": true,
"StructType": true,
"SwitchStmt": true,
"Typ": true,
@ -2770,6 +2774,7 @@ var stdlib = map[string]map[string]bool{
"UnaryOp": true,
"Unknown": true,
"Val": true,
"Value": true,
},
"go/doc": map[string]bool{
"AllDecls": true,
@ -3019,6 +3024,7 @@ var stdlib = map[string]map[string]bool{
"NewTypeName": true,
"NewVar": true,
"Nil": true,
"Object": true,
"ObjectString": true,
"Package": true,
"PkgName": true,
@ -4326,6 +4332,7 @@ var stdlib = map[string]map[string]bool{
"StructOf": true,
"StructTag": true,
"Swapper": true,
"Type": true,
"TypeOf": true,
"Uint": true,
"Uint16": true,
@ -8023,6 +8030,7 @@ var stdlib = map[string]map[string]bool{
"Rmdir": true,
"RouteMessage": true,
"RouteRIB": true,
"RoutingMessage": true,
"RtAttr": true,
"RtGenmsg": true,
"RtMetrics": true,
@ -9391,6 +9399,7 @@ var stdlib = map[string]map[string]bool{
"SlicePtrFromStrings": true,
"SockFilter": true,
"SockFprog": true,
"Sockaddr": true,
"SockaddrDatalink": true,
"SockaddrGen": true,
"SockaddrInet4": true,
@ -9863,6 +9872,7 @@ var stdlib = map[string]map[string]bool{
"RunTests": true,
"Short": true,
"T": true,
"TB": true,
"Verbose": true,
},
"testing/iotest": map[string]bool{

View File

@ -72,10 +72,6 @@ func main() {
paths := []string{"unsafe", "syscall/js"}
for sc.Scan() {
l := sc.Text()
has := func(v string) bool { return strings.Contains(l, v) }
if has("struct, ") || has("interface, ") || has(", method (") {
continue
}
if m := sym.FindStringSubmatch(l); m != nil {
path, _ := m[1], m[2]