// and reprinting.
// In cgo mode, we ignore ast2 and just apply edits directly
// the text behind ast1. In godefs mode we modify and print ast2.
- ast1 := parse(abspath, src, parser.ParseComments)
- ast2 := parse(abspath, src, 0)
+ ast1 := parse(abspath, src, parser.SkipObjectResolution|parser.ParseComments)
+ ast2 := parse(abspath, src, parser.SkipObjectResolution)
f.Package = ast1.Name.Name
f.Name = make(map[string]*Name)
return err
}
defer src.Close()
- f, err := parser.ParseFile(testFileSet, filename, src, parser.ParseComments)
+ f, err := parser.ParseFile(testFileSet, filename, src, parser.ParseComments|parser.SkipObjectResolution)
if err != nil {
return err
}
errors[i] = err // open provides operation and filename in error
return
}
- files[i], errors[i] = parser.ParseFile(p.fset, filepath, src, 0)
+ files[i], errors[i] = parser.ParseFile(p.fset, filepath, src, parser.SkipObjectResolution)
src.Close() // ignore Close error - parsing may have succeeded which is all we need
}(i, p.joinPath(dir, filename))
}
return nil, fmt.Errorf("go tool cgo: %w", err)
}
- return parser.ParseFile(p.fset, filepath.Join(tmpdir, "_cgo_gotypes.go"), nil, 0)
+ return parser.ParseFile(p.fset, filepath.Join(tmpdir, "_cgo_gotypes.go"), nil, parser.SkipObjectResolution)
}
// context-controlled file system operations