1
0
mirror of https://github.com/golang/go synced 2024-11-22 08:04:39 -07:00

godoc: proper file path conversion for remote search

R=rsc
CC=golang-dev
https://golang.org/cl/664041
This commit is contained in:
Robert Griesemer 2010-03-19 17:07:16 -07:00
parent f9d6af9fb8
commit b037bfa684
2 changed files with 28 additions and 3 deletions

View File

@ -1,4 +1,5 @@
QUERY = {Query} QUERY
{Query}
{.section Accurate} {.section Accurate}
{.or} {.or}
@ -21,7 +22,7 @@ package {Pak.Name}
{.repeated section Files} {.repeated section Files}
{.repeated section Groups} {.repeated section Groups}
{.repeated section Infos} {.repeated section Infos}
{File.Path|url-src}:{@|infoLine} {File.Path}:{@|infoLine}
{.end} {.end}
{.end} {.end}
{.end} {.end}
@ -36,7 +37,7 @@ package {Pak.Name}
{.repeated section Files} {.repeated section Files}
{.repeated section Groups} {.repeated section Groups}
{.repeated section Infos} {.repeated section Infos}
{File.Path|url-src}:{@|infoLine} {File.Path}:{@|infoLine}
{.end} {.end}
{.end} {.end}
{.end} {.end}

View File

@ -1394,5 +1394,29 @@ type IndexServer struct{}
func (s *IndexServer) Lookup(query *Query, result *SearchResult) os.Error { func (s *IndexServer) Lookup(query *Query, result *SearchResult) os.Error {
*result = lookup(query.Query) *result = lookup(query.Query)
if hit := result.Hit; hit != nil {
// the hitlists contain absolute server file paths;
// convert them into relative paths on the server
// because the client usually has a different file
// mapping
mapHitList(hit.Decls)
mapHitList(hit.Others)
}
return nil return nil
} }
func mapHitList(list HitList) {
for _, prun := range list {
for _, frun := range prun.Files {
// convert absolute file paths to relative paths
f := frun.File
if f != nil && len(f.Path) > 0 && f.Path[0] == '/' {
f.Path = relativePath(f.Path)
}
// TODO(gri) convert SpotInfos containing snippets
// so that the line number is available
// on the client side
}
}
}