speedup typecheck on large project with compilation errors
This commit is contained in:
parent
2b7ea844ab
commit
2216387fa7
@ -10,7 +10,7 @@ import (
|
|||||||
|
|
||||||
//nolint:gocyclo
|
//nolint:gocyclo
|
||||||
func ExtractErrors(pkg *packages.Package, astCache *astcache.Cache) []packages.Error {
|
func ExtractErrors(pkg *packages.Package, astCache *astcache.Cache) []packages.Error {
|
||||||
errors := extractErrorsImpl(pkg)
|
errors := extractErrorsImpl(pkg, map[*packages.Package]bool{})
|
||||||
if len(errors) == 0 {
|
if len(errors) == 0 {
|
||||||
return errors
|
return errors
|
||||||
}
|
}
|
||||||
@ -48,7 +48,12 @@ func ExtractErrors(pkg *packages.Package, astCache *astcache.Cache) []packages.E
|
|||||||
return uniqErrors
|
return uniqErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
func extractErrorsImpl(pkg *packages.Package) []packages.Error {
|
func extractErrorsImpl(pkg *packages.Package, seenPackages map[*packages.Package]bool) []packages.Error {
|
||||||
|
if seenPackages[pkg] {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
seenPackages[pkg] = true
|
||||||
|
|
||||||
if !pkg.IllTyped { // otherwise it may take hours to traverse all deps many times
|
if !pkg.IllTyped { // otherwise it may take hours to traverse all deps many times
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
@ -59,7 +64,7 @@ func extractErrorsImpl(pkg *packages.Package) []packages.Error {
|
|||||||
|
|
||||||
var errors []packages.Error
|
var errors []packages.Error
|
||||||
for _, iPkg := range pkg.Imports {
|
for _, iPkg := range pkg.Imports {
|
||||||
iPkgErrors := extractErrorsImpl(iPkg)
|
iPkgErrors := extractErrorsImpl(iPkg, seenPackages)
|
||||||
if iPkgErrors != nil {
|
if iPkgErrors != nil {
|
||||||
errors = append(errors, iPkgErrors...)
|
errors = append(errors, iPkgErrors...)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user