mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Update github.com/blevesearch/bleve v1.0.13 -> v1.0.14 (#13947)
This commit is contained in:
34
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
34
vendor/golang.org/x/tools/internal/imports/fix.go
generated
vendored
@@ -83,7 +83,7 @@ type ImportFix struct {
|
||||
IdentName string
|
||||
// FixType is the type of fix this is (AddImport, DeleteImport, SetImportName).
|
||||
FixType ImportFixType
|
||||
Relevance int // see pkg
|
||||
Relevance float64 // see pkg
|
||||
}
|
||||
|
||||
// An ImportInfo represents a single import statement.
|
||||
@@ -592,9 +592,9 @@ func getFixes(fset *token.FileSet, f *ast.File, filename string, env *ProcessEnv
|
||||
return fixes, nil
|
||||
}
|
||||
|
||||
// Highest relevance, used for the standard library. Chosen arbitrarily to
|
||||
// match pre-existing gopls code.
|
||||
const MaxRelevance = 7
|
||||
// MaxRelevance is the highest relevance, used for the standard library.
|
||||
// Chosen arbitrarily to match pre-existing gopls code.
|
||||
const MaxRelevance = 7.0
|
||||
|
||||
// getCandidatePkgs works with the passed callback to find all acceptable packages.
|
||||
// It deduplicates by import path, and uses a cached stdlib rather than reading
|
||||
@@ -607,6 +607,10 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
var mu sync.Mutex // to guard asynchronous access to dupCheck
|
||||
dupCheck := map[string]struct{}{}
|
||||
|
||||
// Start off with the standard library.
|
||||
for importPath, exports := range stdlib {
|
||||
p := &pkg{
|
||||
@@ -615,14 +619,12 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena
|
||||
packageName: path.Base(importPath),
|
||||
relevance: MaxRelevance,
|
||||
}
|
||||
dupCheck[importPath] = struct{}{}
|
||||
if notSelf(p) && wrappedCallback.dirFound(p) && wrappedCallback.packageNameLoaded(p) {
|
||||
wrappedCallback.exportsLoaded(p, exports)
|
||||
}
|
||||
}
|
||||
|
||||
var mu sync.Mutex
|
||||
dupCheck := map[string]struct{}{}
|
||||
|
||||
scanFilter := &scanCallback{
|
||||
rootFound: func(root gopathwalk.Root) bool {
|
||||
// Exclude goroot results -- getting them is relatively expensive, not cached,
|
||||
@@ -658,8 +660,8 @@ func getCandidatePkgs(ctx context.Context, wrappedCallback *scanCallback, filena
|
||||
return resolver.scan(ctx, scanFilter)
|
||||
}
|
||||
|
||||
func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]int, error) {
|
||||
result := make(map[string]int)
|
||||
func ScoreImportPaths(ctx context.Context, env *ProcessEnv, paths []string) (map[string]float64, error) {
|
||||
result := make(map[string]float64)
|
||||
resolver, err := env.GetResolver()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -802,6 +804,8 @@ type ProcessEnv struct {
|
||||
GocmdRunner *gocommand.Runner
|
||||
|
||||
BuildFlags []string
|
||||
ModFlag string
|
||||
ModFile string
|
||||
|
||||
// Env overrides the OS environment, and can be used to specify
|
||||
// GOPROXY, GO111MODULE, etc. PATH cannot be set here, because
|
||||
@@ -995,7 +999,7 @@ type Resolver interface {
|
||||
// loadExports may be called concurrently.
|
||||
loadExports(ctx context.Context, pkg *pkg, includeTest bool) (string, []string, error)
|
||||
// scoreImportPath returns the relevance for an import path.
|
||||
scoreImportPath(ctx context.Context, path string) int
|
||||
scoreImportPath(ctx context.Context, path string) float64
|
||||
|
||||
ClearForNewScan()
|
||||
}
|
||||
@@ -1260,10 +1264,10 @@ func packageDirToName(dir string) (packageName string, err error) {
|
||||
}
|
||||
|
||||
type pkg struct {
|
||||
dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http")
|
||||
importPathShort string // vendorless import path ("net/http", "a/b")
|
||||
packageName string // package name loaded from source if requested
|
||||
relevance int // a weakly-defined score of how relevant a package is. 0 is most relevant.
|
||||
dir string // absolute file path to pkg directory ("/usr/lib/go/src/net/http")
|
||||
importPathShort string // vendorless import path ("net/http", "a/b")
|
||||
packageName string // package name loaded from source if requested
|
||||
relevance float64 // a weakly-defined score of how relevant a package is. 0 is most relevant.
|
||||
}
|
||||
|
||||
type pkgDistance struct {
|
||||
@@ -1389,7 +1393,7 @@ func (r *gopathResolver) scan(ctx context.Context, callback *scanCallback) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) int {
|
||||
func (r *gopathResolver) scoreImportPath(ctx context.Context, path string) float64 {
|
||||
if _, ok := stdlib[path]; ok {
|
||||
return MaxRelevance
|
||||
}
|
||||
|
26
vendor/golang.org/x/tools/internal/imports/mod.go
generated
vendored
26
vendor/golang.org/x/tools/internal/imports/mod.go
generated
vendored
@@ -59,6 +59,8 @@ func (r *ModuleResolver) init() error {
|
||||
}
|
||||
inv := gocommand.Invocation{
|
||||
BuildFlags: r.env.BuildFlags,
|
||||
ModFlag: r.env.ModFlag,
|
||||
ModFile: r.env.ModFile,
|
||||
Env: r.env.env(),
|
||||
Logf: r.env.Logf,
|
||||
WorkingDir: r.env.WorkingDir,
|
||||
@@ -487,7 +489,7 @@ func (r *ModuleResolver) scan(ctx context.Context, callback *scanCallback) error
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int {
|
||||
func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) float64 {
|
||||
if _, ok := stdlib[path]; ok {
|
||||
return MaxRelevance
|
||||
}
|
||||
@@ -495,17 +497,31 @@ func (r *ModuleResolver) scoreImportPath(ctx context.Context, path string) int {
|
||||
return modRelevance(mod)
|
||||
}
|
||||
|
||||
func modRelevance(mod *gocommand.ModuleJSON) int {
|
||||
func modRelevance(mod *gocommand.ModuleJSON) float64 {
|
||||
var relevance float64
|
||||
switch {
|
||||
case mod == nil: // out of scope
|
||||
return MaxRelevance - 4
|
||||
case mod.Indirect:
|
||||
return MaxRelevance - 3
|
||||
relevance = MaxRelevance - 3
|
||||
case !mod.Main:
|
||||
return MaxRelevance - 2
|
||||
relevance = MaxRelevance - 2
|
||||
default:
|
||||
return MaxRelevance - 1 // main module ties with stdlib
|
||||
relevance = MaxRelevance - 1 // main module ties with stdlib
|
||||
}
|
||||
|
||||
_, versionString, ok := module.SplitPathVersion(mod.Path)
|
||||
if ok {
|
||||
index := strings.Index(versionString, "v")
|
||||
if index == -1 {
|
||||
return relevance
|
||||
}
|
||||
if versionNumber, err := strconv.ParseFloat(versionString[index+1:], 64); err == nil {
|
||||
relevance += versionNumber / 1000
|
||||
}
|
||||
}
|
||||
|
||||
return relevance
|
||||
}
|
||||
|
||||
// canonicalize gets the result of canonicalizing the packages using the results
|
||||
|
Reference in New Issue
Block a user