aboutsummaryrefslogtreecommitdiff
path: root/go/analysis/analysis.go
diff options
context:
space:
mode:
Diffstat (limited to 'go/analysis/analysis.go')
-rw-r--r--go/analysis/analysis.go15
1 files changed, 2 insertions, 13 deletions
diff --git a/go/analysis/analysis.go b/go/analysis/analysis.go
index d11505a16..44ada22a0 100644
--- a/go/analysis/analysis.go
+++ b/go/analysis/analysis.go
@@ -11,8 +11,6 @@ import (
"go/token"
"go/types"
"reflect"
-
- "golang.org/x/tools/internal/analysisinternal"
)
// An Analyzer describes an analysis function and its options.
@@ -48,6 +46,7 @@ type Analyzer struct {
// RunDespiteErrors allows the driver to invoke
// the Run method of this analyzer even on a
// package that contains parse or type errors.
+ // The Pass.TypeErrors field may consequently be non-empty.
RunDespiteErrors bool
// Requires is a set of analyzers that must run successfully
@@ -75,17 +74,6 @@ type Analyzer struct {
func (a *Analyzer) String() string { return a.Name }
-func init() {
- // Set the analysisinternal functions to be able to pass type errors
- // to the Pass type without modifying the go/analysis API.
- analysisinternal.SetTypeErrors = func(p interface{}, errors []types.Error) {
- p.(*Pass).typeErrors = errors
- }
- analysisinternal.GetTypeErrors = func(p interface{}) []types.Error {
- return p.(*Pass).typeErrors
- }
-}
-
// A Pass provides information to the Run function that
// applies a specific analyzer to a single Go package.
//
@@ -106,6 +94,7 @@ type Pass struct {
Pkg *types.Package // type information about the package
TypesInfo *types.Info // type information about the syntax trees
TypesSizes types.Sizes // function for computing sizes of types
+ TypeErrors []types.Error // type errors (only if Analyzer.RunDespiteErrors)
// Report reports a Diagnostic, a finding about a specific location
// in the analyzed source code such as a potential mistake.