Commit 6c8fdbe8 authored by Robert Griesemer's avatar Robert Griesemer

godoc: line numbers for all remote search results

Instead of returning the index lookup result via
RPC which has to be corrected for the client,
simply render it on the server and return the
final output.

R=rsc, r
CC=golang-dev
https://golang.org/cl/669041
parent e8fb0b01
QUERY = {Query}
QUERY
{Query}
{.section Accurate}
{.or}
......
......@@ -746,8 +746,9 @@ func infoLineFmt(w io.Writer, x interface{}, format string) {
line = index.(*Index).Snippet(line).Line
} else {
// no line information available because
// we don't have an index
// TODO(gri) Fix this for remote search
// we don't have an index - this should
// never happen; be conservative and don't
// crash
line = 0
}
}
......@@ -1392,10 +1393,15 @@ type Query struct {
}
type Result struct {
Result []byte
}
type IndexServer struct{}
func (s *IndexServer) Lookup(query *Query, result *SearchResult) os.Error {
*result = lookup(query.Query)
func (s *IndexServer) Lookup(query *Query, result *Result) os.Error {
result.Result = applyTemplate(searchText, "searchText", lookup(query.Query))
return nil
}
......@@ -158,7 +158,7 @@ func loggingHandler(h http.Handler) http.Handler {
}
func remoteLookup(query string) (result *SearchResult, err os.Error) {
func remoteLookup(query string) (result *Result, err os.Error) {
var client *rpc.Client
if *serverAddr != "" {
// try server only
......@@ -178,7 +178,7 @@ func remoteLookup(query string) (result *SearchResult, err os.Error) {
}
}
result = new(SearchResult)
result = new(Result)
err = client.Call("IndexServer.Lookup", &Query{query}, result)
if err != nil {
return nil, err
......@@ -281,9 +281,7 @@ func main() {
if err != nil {
log.Exitf("remoteLookup: %s", err)
}
if err := searchText.Execute(result, os.Stdout); err != nil {
log.Exitf("searchText.Execute: %s", err)
}
os.Stdout.Write(result.Result)
}
return
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment