diff options
author | Robert Griesemer <gri@golang.org> | 2010-03-19 17:07:16 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2010-03-19 17:07:16 -0700 |
commit | b037bfa684f25ca76a1d3fdb7f81151684732352 (patch) | |
tree | 055e0f926ca7063e24fbf7ef9eb9352e38f51c60 | |
parent | f9d6af9fb8d9882ed4b01c22568f49ce37906eed (diff) | |
download | go-b037bfa684f25ca76a1d3fdb7f81151684732352.tar.gz go-b037bfa684f25ca76a1d3fdb7f81151684732352.zip |
godoc: proper file path conversion for remote search
R=rsc
CC=golang-dev
https://golang.org/cl/664041
-rw-r--r-- | lib/godoc/search.txt | 7 | ||||
-rw-r--r-- | src/cmd/godoc/godoc.go | 24 |
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/godoc/search.txt b/lib/godoc/search.txt index 46f7ae478e..5724da404d 100644 --- a/lib/godoc/search.txt +++ b/lib/godoc/search.txt @@ -1,4 +1,5 @@ -QUERY = {Query} +QUERY +{Query} {.section Accurate} {.or} @@ -21,7 +22,7 @@ package {Pak.Name} {.repeated section Files} {.repeated section Groups} {.repeated section Infos} - {File.Path|url-src}:{@|infoLine} + {File.Path}:{@|infoLine} {.end} {.end} {.end} @@ -36,7 +37,7 @@ package {Pak.Name} {.repeated section Files} {.repeated section Groups} {.repeated section Infos} - {File.Path|url-src}:{@|infoLine} + {File.Path}:{@|infoLine} {.end} {.end} {.end} diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go index ab45880464..1baa6f2c65 100644 --- a/src/cmd/godoc/godoc.go +++ b/src/cmd/godoc/godoc.go @@ -1394,5 +1394,29 @@ type IndexServer struct{} func (s *IndexServer) Lookup(query *Query, result *SearchResult) os.Error { *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 } + + +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 + } + } +} |