mirror of
https://github.com/golang/go
synced 2024-11-18 18:04:46 -07:00
go.tools/go/loader: Add Program.FilePath convenience method for getting the full path of a source file.
LGTM=gri R=gri, adonovan CC=golang-codereviews https://golang.org/cl/107160049
This commit is contained in:
parent
9ba88c9a99
commit
3309b0d879
@ -460,6 +460,16 @@ func (prog *Program) InitialPackages() []*PackageInfo {
|
||||
return infos
|
||||
}
|
||||
|
||||
// FilePath returns the full path to the specified file. It returns the empty
|
||||
// string if the file does not belong to one of this Program's packages.
|
||||
//
|
||||
func (prog *Program) FilePath(file *ast.File) string {
|
||||
if f := prog.Fset.File(file.Package); f != nil {
|
||||
return f.Name()
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// ---------- Implementation ----------
|
||||
|
||||
// importer holds the working state of the algorithm.
|
||||
|
Loading…
Reference in New Issue
Block a user