mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Update gitea-vet to v0.2.1 (#12282)
* change to new code location * vendor * tagged version v0.2.0 * gitea-vet v0.2.1 Co-authored-by: techknowlogick <techknowlogick@gitea.io>
This commit is contained in:
		
							
								
								
									
										80
									
								
								vendor/golang.org/x/tools/go/packages/packages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										80
									
								
								vendor/golang.org/x/tools/go/packages/packages.go
									
									
									
										generated
									
									
										vendored
									
									
								
							@@ -21,9 +21,12 @@ import (
 | 
			
		||||
	"path/filepath"
 | 
			
		||||
	"strings"
 | 
			
		||||
	"sync"
 | 
			
		||||
	"time"
 | 
			
		||||
 | 
			
		||||
	"golang.org/x/tools/go/gcexportdata"
 | 
			
		||||
	"golang.org/x/tools/internal/gocommand"
 | 
			
		||||
	"golang.org/x/tools/internal/packagesinternal"
 | 
			
		||||
	"golang.org/x/tools/internal/typesinternal"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// A LoadMode controls the amount of detail to return when loading.
 | 
			
		||||
@@ -69,6 +72,13 @@ const (
 | 
			
		||||
 | 
			
		||||
	// NeedTypesSizes adds TypesSizes.
 | 
			
		||||
	NeedTypesSizes
 | 
			
		||||
 | 
			
		||||
	// typecheckCgo enables full support for type checking cgo. Requires Go 1.15+.
 | 
			
		||||
	// Modifies CompiledGoFiles and Types, and has no effect on its own.
 | 
			
		||||
	typecheckCgo
 | 
			
		||||
 | 
			
		||||
	// NeedModule adds Module.
 | 
			
		||||
	NeedModule
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -127,6 +137,9 @@ type Config struct {
 | 
			
		||||
	//
 | 
			
		||||
	Env []string
 | 
			
		||||
 | 
			
		||||
	// gocmdRunner guards go command calls from concurrency errors.
 | 
			
		||||
	gocmdRunner *gocommand.Runner
 | 
			
		||||
 | 
			
		||||
	// BuildFlags is a list of command-line flags to be passed through to
 | 
			
		||||
	// the build system's query tool.
 | 
			
		||||
	BuildFlags []string
 | 
			
		||||
@@ -178,6 +191,13 @@ type driver func(cfg *Config, patterns ...string) (*driverResponse, error)
 | 
			
		||||
 | 
			
		||||
// driverResponse contains the results for a driver query.
 | 
			
		||||
type driverResponse struct {
 | 
			
		||||
	// NotHandled is returned if the request can't be handled by the current
 | 
			
		||||
	// driver. If an external driver returns a response with NotHandled, the
 | 
			
		||||
	// rest of the driverResponse is ignored, and go/packages will fallback
 | 
			
		||||
	// to the next driver. If go/packages is extended in the future to support
 | 
			
		||||
	// lists of multiple drivers, go/packages will fall back to the next driver.
 | 
			
		||||
	NotHandled bool
 | 
			
		||||
 | 
			
		||||
	// Sizes, if not nil, is the types.Sizes to use when type checking.
 | 
			
		||||
	Sizes *types.StdSizes
 | 
			
		||||
 | 
			
		||||
@@ -219,14 +239,22 @@ func Load(cfg *Config, patterns ...string) ([]*Package, error) {
 | 
			
		||||
	return l.refine(response.Roots, response.Packages...)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// defaultDriver is a driver that looks for an external driver binary, and if
 | 
			
		||||
// it does not find it falls back to the built in go list driver.
 | 
			
		||||
// defaultDriver is a driver that implements go/packages' fallback behavior.
 | 
			
		||||
// It will try to request to an external driver, if one exists. If there's
 | 
			
		||||
// no external driver, or the driver returns a response with NotHandled set,
 | 
			
		||||
// defaultDriver will fall back to the go list driver.
 | 
			
		||||
func defaultDriver(cfg *Config, patterns ...string) (*driverResponse, error) {
 | 
			
		||||
	driver := findExternalDriver(cfg)
 | 
			
		||||
	if driver == nil {
 | 
			
		||||
		driver = goListDriver
 | 
			
		||||
	}
 | 
			
		||||
	return driver(cfg, patterns...)
 | 
			
		||||
	response, err := driver(cfg, patterns...)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return response, err
 | 
			
		||||
	} else if response.NotHandled {
 | 
			
		||||
		return goListDriver(cfg, patterns...)
 | 
			
		||||
	}
 | 
			
		||||
	return response, nil
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// A Package describes a loaded Go package.
 | 
			
		||||
@@ -253,7 +281,7 @@ type Package struct {
 | 
			
		||||
	GoFiles []string
 | 
			
		||||
 | 
			
		||||
	// CompiledGoFiles lists the absolute file paths of the package's source
 | 
			
		||||
	// files that were presented to the compiler.
 | 
			
		||||
	// files that are suitable for type checking.
 | 
			
		||||
	// This may differ from GoFiles if files are processed before compilation.
 | 
			
		||||
	CompiledGoFiles []string
 | 
			
		||||
 | 
			
		||||
@@ -301,16 +329,39 @@ type Package struct {
 | 
			
		||||
	forTest string
 | 
			
		||||
 | 
			
		||||
	// module is the module information for the package if it exists.
 | 
			
		||||
	module *packagesinternal.Module
 | 
			
		||||
	Module *Module
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Module provides module information for a package.
 | 
			
		||||
type Module struct {
 | 
			
		||||
	Path      string       // module path
 | 
			
		||||
	Version   string       // module version
 | 
			
		||||
	Replace   *Module      // replaced by this module
 | 
			
		||||
	Time      *time.Time   // time version was created
 | 
			
		||||
	Main      bool         // is this the main module?
 | 
			
		||||
	Indirect  bool         // is this module only an indirect dependency of main module?
 | 
			
		||||
	Dir       string       // directory holding files for this module, if any
 | 
			
		||||
	GoMod     string       // path to go.mod file used when loading this module, if any
 | 
			
		||||
	GoVersion string       // go version used in module
 | 
			
		||||
	Error     *ModuleError // error loading module
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// ModuleError holds errors loading a module.
 | 
			
		||||
type ModuleError struct {
 | 
			
		||||
	Err string // the error itself
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	packagesinternal.GetForTest = func(p interface{}) string {
 | 
			
		||||
		return p.(*Package).forTest
 | 
			
		||||
	}
 | 
			
		||||
	packagesinternal.GetModule = func(p interface{}) *packagesinternal.Module {
 | 
			
		||||
		return p.(*Package).module
 | 
			
		||||
	packagesinternal.GetGoCmdRunner = func(config interface{}) *gocommand.Runner {
 | 
			
		||||
		return config.(*Config).gocmdRunner
 | 
			
		||||
	}
 | 
			
		||||
	packagesinternal.SetGoCmdRunner = func(config interface{}, runner *gocommand.Runner) {
 | 
			
		||||
		config.(*Config).gocmdRunner = runner
 | 
			
		||||
	}
 | 
			
		||||
	packagesinternal.TypecheckCgo = int(typecheckCgo)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// An Error describes a problem with a package's metadata, syntax, or types.
 | 
			
		||||
@@ -473,6 +524,9 @@ func newLoader(cfg *Config) *loader {
 | 
			
		||||
	if ld.Config.Env == nil {
 | 
			
		||||
		ld.Config.Env = os.Environ()
 | 
			
		||||
	}
 | 
			
		||||
	if ld.Config.gocmdRunner == nil {
 | 
			
		||||
		ld.Config.gocmdRunner = &gocommand.Runner{}
 | 
			
		||||
	}
 | 
			
		||||
	if ld.Context == nil {
 | 
			
		||||
		ld.Context = context.Background()
 | 
			
		||||
	}
 | 
			
		||||
@@ -690,6 +744,9 @@ func (ld *loader) refine(roots []string, list ...*Package) ([]*Package, error) {
 | 
			
		||||
		if ld.requestedMode&NeedTypesSizes == 0 {
 | 
			
		||||
			ld.pkgs[i].TypesSizes = nil
 | 
			
		||||
		}
 | 
			
		||||
		if ld.requestedMode&NeedModule == 0 {
 | 
			
		||||
			ld.pkgs[i].Module = nil
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return result, nil
 | 
			
		||||
@@ -865,6 +922,15 @@ func (ld *loader) loadPackage(lpkg *loaderPackage) {
 | 
			
		||||
		Error: appendError,
 | 
			
		||||
		Sizes: ld.sizes,
 | 
			
		||||
	}
 | 
			
		||||
	if (ld.Mode & typecheckCgo) != 0 {
 | 
			
		||||
		if !typesinternal.SetUsesCgo(tc) {
 | 
			
		||||
			appendError(Error{
 | 
			
		||||
				Msg:  "typecheckCgo requires Go 1.15+",
 | 
			
		||||
				Kind: ListError,
 | 
			
		||||
			})
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	types.NewChecker(tc, ld.Fset, lpkg.Types, lpkg.TypesInfo).Files(lpkg.Syntax)
 | 
			
		||||
 | 
			
		||||
	lpkg.importErrors = nil // no longer needed
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user