Dependency updates

This commit is contained in:
Stash Dev
2019-05-27 12:34:26 -07:00
parent 69917999ef
commit 4b037e1040
359 changed files with 60172 additions and 18749 deletions

View File

@@ -23,6 +23,8 @@ import (
"strings"
"sync"
"time"
"unicode"
"unicode/utf8"
"golang.org/x/tools/go/ast/astutil"
"golang.org/x/tools/go/packages"
@@ -289,7 +291,7 @@ func (p *pass) importIdentifier(imp *importInfo) string {
if known != nil && known.name != "" {
return known.name
}
return importPathToNameBasic(imp.importPath, p.srcDir)
return importPathToAssumedName(imp.importPath)
}
// load reads in everything necessary to run a pass, and reports whether the
@@ -389,7 +391,7 @@ func (p *pass) fix() bool {
}
path := strings.Trim(imp.Path.Value, `""`)
ident := p.importIdentifier(&importInfo{importPath: path})
if ident != importPathToNameBasic(path, p.srcDir) {
if ident != importPathToAssumedName(path) {
imp.Name = &ast.Ident{Name: ident, NamePos: imp.Pos()}
}
}
@@ -648,7 +650,7 @@ func (r *goPackagesResolver) loadPackageNames(importPaths []string, srcDir strin
if _, ok := names[path]; ok {
continue
}
names[path] = importPathToNameBasic(path, srcDir)
names[path] = importPathToAssumedName(path)
}
return names, nil
@@ -657,7 +659,7 @@ func (r *goPackagesResolver) loadPackageNames(importPaths []string, srcDir strin
func (r *goPackagesResolver) scan(refs references) ([]*pkg, error) {
var loadQueries []string
for pkgName := range refs {
loadQueries = append(loadQueries, "name="+pkgName)
loadQueries = append(loadQueries, "iamashamedtousethedisabledqueryname="+pkgName)
}
sort.Strings(loadQueries)
cfg := r.env.newPackagesConfig(packages.LoadFiles)
@@ -741,18 +743,36 @@ func addExternalCandidates(pass *pass, refs references, filename string) error {
return firstErr
}
// importPathToNameBasic assumes the package name is the base of import path,
// except that if the path ends in foo/vN, it assumes the package name is foo.
func importPathToNameBasic(importPath, srcDir string) (packageName string) {
// notIdentifier reports whether ch is an invalid identifier character.
func notIdentifier(ch rune) bool {
return !('a' <= ch && ch <= 'z' || 'A' <= ch && ch <= 'Z' ||
'0' <= ch && ch <= '9' ||
ch == '_' ||
ch >= utf8.RuneSelf && (unicode.IsLetter(ch) || unicode.IsDigit(ch)))
}
// importPathToAssumedName returns the assumed package name of an import path.
// It does this using only string parsing of the import path.
// It picks the last element of the path that does not look like a major
// version, and then picks the valid identifier off the start of that element.
// It is used to determine if a local rename should be added to an import for
// clarity.
// This function could be moved to a standard package and exported if we want
// for use in other tools.
func importPathToAssumedName(importPath string) string {
base := path.Base(importPath)
if strings.HasPrefix(base, "v") {
if _, err := strconv.Atoi(base[1:]); err == nil {
dir := path.Dir(importPath)
if dir != "." {
return path.Base(dir)
base = path.Base(dir)
}
}
}
base = strings.TrimPrefix(base, "go-")
if i := strings.IndexFunc(base, notIdentifier); i >= 0 {
base = base[:i]
}
return base
}
@@ -1023,7 +1043,7 @@ func findImport(ctx context.Context, env *fixEnv, dirScan []*pkg, pkgName string
// Find candidate packages, looking only at their directory names first.
var candidates []pkgDistance
for _, pkg := range dirScan {
if pkgIsCandidate(filename, pkgName, pkg) {
if pkg.dir != pkgDir && pkgIsCandidate(filename, pkgName, pkg) {
candidates = append(candidates, pkgDistance{
pkg: pkg,
distance: distance(pkgDir, pkg.dir),

View File

@@ -14,6 +14,7 @@ import (
"io/ioutil"
"log"
"os"
"os/exec"
"path/filepath"
"regexp"
"runtime"
@@ -58,6 +59,11 @@ func main() {
mustOpen(api("go1.9.txt")),
mustOpen(api("go1.10.txt")),
mustOpen(api("go1.11.txt")),
mustOpen(api("go1.12.txt")),
// The API of the syscall/js package needs to be computed explicitly,
// because it's not included in the GOROOT/api/go1.*.txt files at this time.
syscallJSAPI(),
)
sc := bufio.NewScanner(f)
@@ -109,3 +115,18 @@ func main() {
log.Fatal(err)
}
}
// syscallJSAPI returns the API of the syscall/js package.
// It's computed from the contents of $(go env GOROOT)/src/syscall/js.
func syscallJSAPI() io.Reader {
var exeSuffix string
if runtime.GOOS == "windows" {
exeSuffix = ".exe"
}
cmd := exec.Command("go"+exeSuffix, "run", "cmd/api", "-contexts", "js-wasm", "syscall/js")
out, err := cmd.Output()
if err != nil {
log.Fatalln(err)
}
return bytes.NewReader(out)
}

View File

@@ -24,6 +24,7 @@ import (
type moduleResolver struct {
env *fixEnv
initialized bool
main *moduleJSON
modsByModPath []*moduleJSON // All modules, ordered by # of path components in module Path...
modsByDir []*moduleJSON // ...or Dir.
@@ -48,7 +49,7 @@ type moduleErrorJSON struct {
}
func (r *moduleResolver) init() error {
if r.main != nil {
if r.initialized {
return nil
}
stdout, err := r.env.invokeGo("list", "-m", "-json", "...")
@@ -87,6 +88,7 @@ func (r *moduleResolver) init() error {
return count(j) < count(i) // descending order
})
r.initialized = true
return nil
}
@@ -202,7 +204,9 @@ func (r *moduleResolver) scan(_ references) ([]*pkg, error) {
// Walk GOROOT, GOPATH/pkg/mod, and the main module.
roots := []gopathwalk.Root{
{filepath.Join(r.env.GOROOT, "/src"), gopathwalk.RootGOROOT},
{r.main.Dir, gopathwalk.RootCurrentModule},
}
if r.main != nil {
roots = append(roots, gopathwalk.Root{r.main.Dir, gopathwalk.RootCurrentModule})
}
for _, p := range filepath.SplitList(r.env.GOPATH) {
roots = append(roots, gopathwalk.Root{filepath.Join(p, "/pkg/mod"), gopathwalk.RootModuleCache})

View File

@@ -112,6 +112,7 @@ var stdlib = map[string]map[string]bool{
"Reader": true,
"Repeat": true,
"Replace": true,
"ReplaceAll": true,
"Runes": true,
"Split": true,
"SplitAfter": true,
@@ -441,6 +442,9 @@ var stdlib = map[string]map[string]bool{
"RequireAnyClientCert": true,
"Server": true,
"SignatureScheme": true,
"TLS_AES_128_GCM_SHA256": true,
"TLS_AES_256_GCM_SHA384": true,
"TLS_CHACHA20_POLY1305_SHA256": true,
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA": true,
"TLS_ECDHE_ECDSA_WITH_AES_128_CBC_SHA256": true,
"TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256": true,
@@ -469,6 +473,7 @@ var stdlib = map[string]map[string]bool{
"VersionTLS10": true,
"VersionTLS11": true,
"VersionTLS12": true,
"VersionTLS13": true,
"X25519": true,
"X509KeyPair": true,
},
@@ -1835,6 +1840,7 @@ var stdlib = map[string]map[string]bool{
"R_PPC_UADDR32": true,
"R_RISCV": true,
"R_RISCV_32": true,
"R_RISCV_32_PCREL": true,
"R_RISCV_64": true,
"R_RISCV_ADD16": true,
"R_RISCV_ADD32": true,
@@ -2260,6 +2266,7 @@ var stdlib = map[string]map[string]bool{
"IMAGE_FILE_MACHINE_AMD64": true,
"IMAGE_FILE_MACHINE_ARM": true,
"IMAGE_FILE_MACHINE_ARM64": true,
"IMAGE_FILE_MACHINE_ARMNT": true,
"IMAGE_FILE_MACHINE_EBC": true,
"IMAGE_FILE_MACHINE_I386": true,
"IMAGE_FILE_MACHINE_IA64": true,
@@ -2753,6 +2760,7 @@ var stdlib = map[string]map[string]bool{
"New": true,
"Note": true,
"Package": true,
"PreserveAST": true,
"Synopsis": true,
"ToHTML": true,
"ToText": true,
@@ -2764,9 +2772,10 @@ var stdlib = map[string]map[string]bool{
"Source": true,
},
"go/importer": map[string]bool{
"Default": true,
"For": true,
"Lookup": true,
"Default": true,
"For": true,
"ForCompiler": true,
"Lookup": true,
},
"go/parser": map[string]bool{
"AllErrors": true,
@@ -3296,6 +3305,7 @@ var stdlib = map[string]map[string]bool{
"SeekEnd": true,
"SeekStart": true,
"Seeker": true,
"StringWriter": true,
"TeeReader": true,
"WriteCloser": true,
"WriteSeeker": true,
@@ -3498,6 +3508,12 @@ var stdlib = map[string]map[string]bool{
"Word": true,
},
"math/bits": map[string]bool{
"Add": true,
"Add32": true,
"Add64": true,
"Div": true,
"Div32": true,
"Div64": true,
"LeadingZeros": true,
"LeadingZeros16": true,
"LeadingZeros32": true,
@@ -3508,6 +3524,9 @@ var stdlib = map[string]map[string]bool{
"Len32": true,
"Len64": true,
"Len8": true,
"Mul": true,
"Mul32": true,
"Mul64": true,
"OnesCount": true,
"OnesCount16": true,
"OnesCount32": true,
@@ -3527,6 +3546,9 @@ var stdlib = map[string]map[string]bool{
"RotateLeft32": true,
"RotateLeft64": true,
"RotateLeft8": true,
"Sub": true,
"Sub32": true,
"Sub64": true,
"TrailingZeros": true,
"TrailingZeros16": true,
"TrailingZeros32": true,
@@ -3870,6 +3892,7 @@ var stdlib = map[string]map[string]bool{
"StatusTeapot": true,
"StatusTemporaryRedirect": true,
"StatusText": true,
"StatusTooEarly": true,
"StatusTooManyRequests": true,
"StatusUnauthorized": true,
"StatusUnavailableForLegalReasons": true,
@@ -4140,6 +4163,7 @@ var stdlib = map[string]map[string]bool{
"Truncate": true,
"Unsetenv": true,
"UserCacheDir": true,
"UserHomeDir": true,
},
"os/exec": map[string]bool{
"Cmd": true,
@@ -4244,6 +4268,7 @@ var stdlib = map[string]map[string]bool{
"MakeMapWithSize": true,
"MakeSlice": true,
"Map": true,
"MapIter": true,
"MapOf": true,
"Method": true,
"New": true,
@@ -4419,9 +4444,12 @@ var stdlib = map[string]map[string]bool{
"Version": true,
},
"runtime/debug": map[string]bool{
"BuildInfo": true,
"FreeOSMemory": true,
"GCStats": true,
"Module": true,
"PrintStack": true,
"ReadBuildInfo": true,
"ReadGCStats": true,
"SetGCPercent": true,
"SetMaxStack": true,
@@ -4547,6 +4575,7 @@ var stdlib = map[string]map[string]bool{
"Reader": true,
"Repeat": true,
"Replace": true,
"ReplaceAll": true,
"Replacer": true,
"Split": true,
"SplitAfter": true,
@@ -6105,6 +6134,7 @@ var stdlib = map[string]map[string]bool{
"FreeLibrary": true,
"Fsid": true,
"Fstat": true,
"Fstatat": true,
"Fstatfs": true,
"Fstore_t": true,
"Fsync": true,
@@ -9362,6 +9392,7 @@ var stdlib = map[string]map[string]bool{
"Syscall": true,
"Syscall12": true,
"Syscall15": true,
"Syscall18": true,
"Syscall6": true,
"Syscall9": true,
"Sysctl": true,
@@ -9630,6 +9661,7 @@ var stdlib = map[string]map[string]bool{
"TransmitFile": true,
"TransmitFileBuffers": true,
"Truncate": true,
"UNIX_PATH_MAX": true,
"USAGE_MATCH_TYPE_AND": true,
"USAGE_MATCH_TYPE_OR": true,
"UTF16FromString": true,
@@ -9751,6 +9783,29 @@ var stdlib = map[string]map[string]bool{
"XP1_UNI_RECV": true,
"XP1_UNI_SEND": true,
},
"syscall/js": map[string]bool{
"Error": true,
"Func": true,
"FuncOf": true,
"Global": true,
"Null": true,
"Type": true,
"TypeBoolean": true,
"TypeFunction": true,
"TypeNull": true,
"TypeNumber": true,
"TypeObject": true,
"TypeString": true,
"TypeSymbol": true,
"TypeUndefined": true,
"TypedArray": true,
"TypedArrayOf": true,
"Undefined": true,
"Value": true,
"ValueError": true,
"ValueOf": true,
"Wrapper": true,
},
"testing": map[string]bool{
"AllocsPerRun": true,
"B": true,