Skip to content
This repository has been archived by the owner on Feb 3, 2018. It is now read-only.

Commit

Permalink
revert pkgtree error types renaming
Browse files Browse the repository at this point in the history
  • Loading branch information
Vladimir Varankin committed Mar 28, 2017
1 parent ad41126 commit 9e5eeb6
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 35 deletions.
32 changes: 16 additions & 16 deletions pkgtree/pkgtree.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func ListPackages(fileRoot, importRoot string) (PackageTree, error) {

if len(lim) > 0 {
ptree.Packages[ip] = PackageOrErr{
Err: &ErrLocalImports{
Err: &LocalImportsError{
Dir: wp,
ImportPath: ip,
LocalImports: lim,
Expand Down Expand Up @@ -263,17 +263,17 @@ func fillPackage(p *build.Package) error {
return nil
}

// ErrLocalImports indicates that a package contains at least one relative
// LocalImportsError indicates that a package contains at least one relative
// import that will prevent it from compiling.
//
// TODO(sdboyer) add a Files property once we're doing our own per-file parsing
type ErrLocalImports struct {
type LocalImportsError struct {
ImportPath string
Dir string
LocalImports []string
}

func (e *ErrLocalImports) Error() string {
func (e *LocalImportsError) Error() string {
switch len(e.LocalImports) {
case 0:
// shouldn't be possible, but just cover the case
Expand All @@ -298,9 +298,9 @@ type PackageOrErr struct {
Err error
}

// ErrProblemImport describes the reason that a particular import path is
// ProblemImportError describes the reason that a particular import path is
// not safely importable.
type ErrProblemImport struct {
type ProblemImportError struct {
// The import path of the package with some problem rendering it
// unimportable.
ImportPath string
Expand All @@ -313,9 +313,9 @@ type ErrProblemImport struct {
Err error
}

// Error formats the ErrProblemImport as a string, reflecting whether the
// Error formats the ProblemImportError as a string, reflecting whether the
// error represents a direct or transitive problem.
func (e *ErrProblemImport) Error() string {
func (e *ProblemImportError) Error() string {
switch len(e.Cause) {
case 0:
return fmt.Sprintf("%q contains malformed code: %s", e.ImportPath, e.Err.Error())
Expand Down Expand Up @@ -413,7 +413,7 @@ type PackageTree struct {
// "A": []string{},
// "A/bar": []string{"B/baz"},
// }
func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore map[string]bool) (ReachMap, map[string]*ErrProblemImport) {
func (t PackageTree) ToReachMap(main, tests, backprop bool, ignore map[string]bool) (ReachMap, map[string]*ProblemImportError) {
if ignore == nil {
ignore = make(map[string]bool)
}
Expand Down Expand Up @@ -511,7 +511,7 @@ func (t PackageTree) Copy() PackageTree {
// It drops any packages with errors, and - if backprop is true - backpropagates
// those errors, causing internal packages that (transitively) import other
// internal packages having errors to also be dropped.
func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ErrProblemImport) {
func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ProblemImportError) {
// Uses depth-first exploration to compute reachability into external
// packages, dropping any internal packages on "poisoned paths" - a path
// containing a package with an error, or with a dep on an internal package
Expand All @@ -526,17 +526,17 @@ func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ErrP
colors := make(map[string]uint8)
exrsets := make(map[string]map[string]struct{})
inrsets := make(map[string]map[string]struct{})
errmap := make(map[string]*ErrProblemImport)
errmap := make(map[string]*ProblemImportError)

// poison is a helper func to eliminate specific reachsets from exrsets and
// inrsets, and populate error information along the way.
poison := func(path []string, err *ErrProblemImport) {
poison := func(path []string, err *ProblemImportError) {
for k, ppkg := range path {
delete(exrsets, ppkg)
delete(inrsets, ppkg)

// Duplicate the err for this package
kerr := &ErrProblemImport{
kerr := &ProblemImportError{
ImportPath: ppkg,
Err: err.Err,
}
Expand Down Expand Up @@ -573,7 +573,7 @@ func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ErrP
// poisonWhite wraps poison for error recording in the white-poisoning case,
// where we're constructing a new poison path.
poisonWhite := func(path []string) {
err := &ErrProblemImport{
err := &ProblemImportError{
Cause: make([]string, len(path)),
}
copy(err.Cause, path)
Expand All @@ -598,7 +598,7 @@ func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ErrP
// an empty path here.

fromErr := errmap[from]
err := &ErrProblemImport{
err := &ProblemImportError{
Err: fromErr.Err,
Cause: make([]string, 0, len(path)+len(fromErr.Cause)+1),
}
Expand Down Expand Up @@ -641,7 +641,7 @@ func wmToReach(workmap map[string]wm, backprop bool) (ReachMap, map[string]*ErrP
} else if exists {
// Only record something in the errmap if there's actually a
// package there, per the semantics of the errmap
errmap[pkg] = &ErrProblemImport{
errmap[pkg] = &ProblemImportError{
ImportPath: pkg,
Err: w.err,
}
Expand Down
38 changes: 19 additions & 19 deletions pkgtree/pkgtree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func TestWorkmapToReach(t *testing.T) {
table := map[string]struct {
workmap map[string]wm
rm ReachMap
em map[string]*ErrProblemImport
em map[string]*ProblemImportError
backprop bool
}{
"single": {
Expand Down Expand Up @@ -147,8 +147,8 @@ func TestWorkmapToReach(t *testing.T) {
External: []string{"B/baz"},
},
},
em: map[string]*ErrProblemImport{
"A": &ErrProblemImport{
em: map[string]*ProblemImportError{
"A": &ProblemImportError{
ImportPath: "A",
Cause: []string{"A/foo"},
Err: missingPkgErr("A/foo"),
Expand Down Expand Up @@ -187,13 +187,13 @@ func TestWorkmapToReach(t *testing.T) {
External: []string{"B/baz"},
},
},
em: map[string]*ErrProblemImport{
"A": &ErrProblemImport{
em: map[string]*ProblemImportError{
"A": &ProblemImportError{
ImportPath: "A",
Cause: []string{"A/foo", "A/bar"},
Err: missingPkgErr("A/bar"),
},
"A/foo": &ErrProblemImport{
"A/foo": &ProblemImportError{
ImportPath: "A/foo",
Cause: []string{"A/bar"},
Err: missingPkgErr("A/bar"),
Expand Down Expand Up @@ -227,13 +227,13 @@ func TestWorkmapToReach(t *testing.T) {
External: []string{"B/baz"},
},
},
em: map[string]*ErrProblemImport{
"A": &ErrProblemImport{
em: map[string]*ProblemImportError{
"A": &ProblemImportError{
ImportPath: "A",
Cause: []string{"A/foo"},
Err: fmt.Errorf("err pkg"),
},
"A/foo": &ErrProblemImport{
"A/foo": &ProblemImportError{
ImportPath: "A/foo",
Err: fmt.Errorf("err pkg"),
},
Expand Down Expand Up @@ -274,18 +274,18 @@ func TestWorkmapToReach(t *testing.T) {
External: []string{"B/baz"},
},
},
em: map[string]*ErrProblemImport{
"A": &ErrProblemImport{
em: map[string]*ProblemImportError{
"A": &ProblemImportError{
ImportPath: "A",
Cause: []string{"A/foo", "A/bar"},
Err: fmt.Errorf("err pkg"),
},
"A/foo": &ErrProblemImport{
"A/foo": &ProblemImportError{
ImportPath: "A/foo",
Cause: []string{"A/bar"},
Err: fmt.Errorf("err pkg"),
},
"A/bar": &ErrProblemImport{
"A/bar": &ProblemImportError{
ImportPath: "A/bar",
Err: fmt.Errorf("err pkg"),
},
Expand Down Expand Up @@ -335,8 +335,8 @@ func TestWorkmapToReach(t *testing.T) {
External: []string{"B/baz"},
},
},
em: map[string]*ErrProblemImport{
"A/bar": &ErrProblemImport{
em: map[string]*ProblemImportError{
"A/bar": &ProblemImportError{
ImportPath: "A/bar",
Err: fmt.Errorf("err pkg"),
},
Expand Down Expand Up @@ -454,7 +454,7 @@ func TestWorkmapToReach(t *testing.T) {
// needed
t.Run(name, func(t *testing.T) {
if fix.em == nil {
fix.em = make(map[string]*ErrProblemImport)
fix.em = make(map[string]*ProblemImportError)
}

rm, em := wmToReach(fix.workmap, fix.backprop)
Expand Down Expand Up @@ -1121,7 +1121,7 @@ func TestListPackages(t *testing.T) {
},
},
"relimport/dotdot": {
Err: &ErrLocalImports{
Err: &LocalImportsError{
Dir: j("relimport/dotdot"),
ImportPath: "relimport/dotdot",
LocalImports: []string{
Expand All @@ -1130,7 +1130,7 @@ func TestListPackages(t *testing.T) {
},
},
"relimport/dotslash": {
Err: &ErrLocalImports{
Err: &LocalImportsError{
Dir: j("relimport/dotslash"),
ImportPath: "relimport/dotslash",
LocalImports: []string{
Expand All @@ -1139,7 +1139,7 @@ func TestListPackages(t *testing.T) {
},
},
"relimport/dotdotslash": {
Err: &ErrLocalImports{
Err: &LocalImportsError{
Dir: j("relimport/dotdotslash"),
ImportPath: "relimport/dotdotslash",
LocalImports: []string{
Expand Down

0 comments on commit 9e5eeb6

Please sign in to comment.