This commit is contained in:
Mark Bates 2019-12-03 15:29:17 -05:00
parent b24faf1070
commit ec8c803b27
3 changed files with 10 additions and 10 deletions

View File

@ -40,7 +40,7 @@ func (decls Decls) Files() ([]*File, error) {
files, err := fl.Files(v) files, err := fl.Files(v)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: %s", err, d) return nil, fmt.Errorf("%s: %s", err, d)
} }
for _, f := range files { for _, f := range files {

View File

@ -100,19 +100,19 @@ func (p *Parser) ParseDir(abs string, mode parser.Mode) ([]*ParsedSource, error)
her, err := here.Dir(abs) her, err := here.Dir(abs)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: here.Dir failed %s", err, abs) return nil, fmt.Errorf("%s: here.Dir failed %s", err, abs)
} }
pt, err := her.Parse(strings.TrimPrefix(abs, filepath.Dir(abs))) pt, err := her.Parse(strings.TrimPrefix(abs, filepath.Dir(abs)))
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: here.Parse failed %s", err, abs) return nil, fmt.Errorf("%s: here.Parse failed %s", err, abs)
} }
fset := token.NewFileSet() fset := token.NewFileSet()
pkgs, err := parser.ParseDir(fset, abs, nil, 0) pkgs, err := parser.ParseDir(fset, abs, nil, 0)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: ParseDir failed %s", err, abs) return nil, fmt.Errorf("%s: ParseDir failed %s", err, abs)
} }
var srcs []*ParsedSource var srcs []*ParsedSource
@ -205,13 +205,13 @@ func (p *Parser) parse() error {
srcs, err := p.ParseDir(path, 0) srcs, err := p.ParseDir(path, 0)
if err != nil { if err != nil {
return fmt.Errorf("%w: %s", err, path) return fmt.Errorf("%s: %s", err, path)
} }
for _, src := range srcs { for _, src := range srcs {
mm, err := src.DeclsMap() mm, err := src.DeclsMap()
if err != nil { if err != nil {
return fmt.Errorf("%w: %s", err, src.Abs) return fmt.Errorf("%s: %s", err, src.Abs)
} }
for k, v := range mm { for k, v := range mm {
p.decls[k] = append(p.decls[k], v...) p.decls[k] = append(p.decls[k], v...)

View File

@ -140,26 +140,26 @@ func (p *ParsedSource) parse() error {
n := ce.Args[0] n := ce.Args[0]
val, err := p.value(n) val, err := p.value(n)
if err != nil { if err != nil {
p.err = fmt.Errorf("%w: %s", err, n) p.err = fmt.Errorf("%s: %s", err, n)
return false return false
} }
info, err := here.Dir(filepath.Dir(p.Abs)) info, err := here.Dir(filepath.Dir(p.Abs))
if err != nil { if err != nil {
p.err = fmt.Errorf("%w: %s", err, p.Abs) p.err = fmt.Errorf("%s: %s", err, p.Abs)
return false return false
} }
pt, err := info.Parse(val) pt, err := info.Parse(val)
if err != nil { if err != nil {
p.err = fmt.Errorf("%w: %s", err, p.Abs) p.err = fmt.Errorf("%s: %s", err, p.Abs)
return false return false
} }
if pt.Pkg != info.Module.Path { if pt.Pkg != info.Module.Path {
info, err = here.Package(pt.Pkg) info, err = here.Package(pt.Pkg)
if err != nil { if err != nil {
p.err = fmt.Errorf("%w: %s", err, p.Abs) p.err = fmt.Errorf("%s: %s", err, p.Abs)
return false return false
} }
} }