Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(562)

Delta Between Two Patch Sets: src/cmd/godoc/godoc.go

Issue 3699041: code review 3699041: godoc: support for regular expression full text search (Closed)
Left Patch Set: code review 3699041: godoc: support for regular expression full text search Created 14 years, 2 months ago
Right Patch Set: code review 3699041: godoc: support for regular expression full text search Created 14 years, 2 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/cmd/godoc/format.go ('k') | src/cmd/godoc/index.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 package main 5 package main
6 6
7 import ( 7 import (
8 "bytes" 8 "bytes"
9 "flag" 9 "flag"
10 "fmt" 10 "fmt"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory ") 57 goroot = flag.String("goroot", runtime.GOROOT(), "Go root directory ")
58 testDir = flag.String("testdir", "", "Go root subdirectory - for tes ting only (faster startups)") 58 testDir = flag.String("testdir", "", "Go root subdirectory - for tes ting only (faster startups)")
59 path = flag.String("path", "", "additional package directories (c olon-separated)") 59 path = flag.String("path", "", "additional package directories (c olon-separated)")
60 filter = flag.String("filter", "", "filter file containing permitte d package directory paths") 60 filter = flag.String("filter", "", "filter file containing permitte d package directory paths")
61 filterMin = flag.Int("filter_minutes", 0, "filter file update interval in minutes; disabled if <= 0") 61 filterMin = flag.Int("filter_minutes", 0, "filter file update interval in minutes; disabled if <= 0")
62 filterDelay delayTime // actual filter update interval in minutes; usual ly filterDelay == filterMin, but filterDelay may back off exponentially 62 filterDelay delayTime // actual filter update interval in minutes; usual ly filterDelay == filterMin, but filterDelay may back off exponentially
63 63
64 // layout control 64 // layout control
65 tabwidth = flag.Int("tabwidth", 4, "tab width") 65 tabwidth = flag.Int("tabwidth", 4, "tab width")
66 showTimestamps = flag.Bool("timestamps", true, "show timestamps with dir ectory listings") 66 showTimestamps = flag.Bool("timestamps", true, "show timestamps with dir ectory listings")
67 » fulltextIndex = flag.Bool("fulltext", false, "build full text index for search queries") 67 » fulltextIndex = flag.Bool("fulltext", false, "build full text index for regular expression queries")
68 » regexpQueries = flag.Bool("regexp", false, "interpret queries as regula r expressions for full text search")
69 68
70 // file system mapping 69 // file system mapping
71 fsMap Mapping // user-defined mapping 70 fsMap Mapping // user-defined mapping
72 fsTree RWValue // *Directory tree of packages, updated with each syn c 71 fsTree RWValue // *Directory tree of packages, updated with each syn c
73 pathFilter RWValue // filter used when building fsMap directory trees 72 pathFilter RWValue // filter used when building fsMap directory trees
74 fsModified RWValue // timestamp of last call to invalidateIndex 73 fsModified RWValue // timestamp of last call to invalidateIndex
75 74
76 // http handlers 75 // http handlers
77 fileServer http.Handler // default file server 76 fileServer http.Handler // default file server
78 cmdHandler httpHandler 77 cmdHandler httpHandler
(...skipping 1074 matching lines...) Expand 10 before | Expand all | Expand 10 after
1153 // textual matches 1152 // textual matches
1154 Found int // number of textual occurrences found 1153 Found int // number of textual occurrences found
1155 Textual []FileLines // textual matches of Query 1154 Textual []FileLines // textual matches of Query
1156 Complete bool // true if all textual occurrences of Query are rep orted 1155 Complete bool // true if all textual occurrences of Query are rep orted
1157 } 1156 }
1158 1157
1159 1158
1160 func lookup(query string) (result SearchResult) { 1159 func lookup(query string) (result SearchResult) {
1161 result.Query = query 1160 result.Query = query
1162 1161
1163 // if regexp queries are disabled, quote the query string:
1164 // it will always compile and look like a regexp literal
1165 if !*regexpQueries {
1166 query = regexp.QuoteMeta(query)
1167 }
1168
1169 // determine identifier lookup string and full text regexp 1162 // determine identifier lookup string and full text regexp
1170 lookupStr := "" 1163 lookupStr := ""
1171 lookupRx, err := regexp.Compile(query) 1164 lookupRx, err := regexp.Compile(query)
1172 if err != nil { 1165 if err != nil {
1173 result.Alert = "Error in query regular expression: " + err.Strin g() 1166 result.Alert = "Error in query regular expression: " + err.Strin g()
1174 return 1167 return
1175 } 1168 }
1176 if prefix, complete := lookupRx.LiteralPrefix(); complete { 1169 if prefix, complete := lookupRx.LiteralPrefix(); complete {
1177 // otherwise we lookup "" (with no result) because 1170 // otherwise we lookup "" (with no result) because
1178 // identifier lookup doesn't support regexp search 1171 // identifier lookup doesn't support regexp search
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 log.Printf("after GC: bytes = %d footprint = %d", runti me.MemStats.HeapAlloc, runtime.MemStats.Sys) 1292 log.Printf("after GC: bytes = %d footprint = %d", runti me.MemStats.HeapAlloc, runtime.MemStats.Sys)
1300 } 1293 }
1301 var delay int64 = 60 * 1e9 // by default, try every 60s 1294 var delay int64 = 60 * 1e9 // by default, try every 60s
1302 if *testDir != "" { 1295 if *testDir != "" {
1303 // in test mode, try once a second for fast startup 1296 // in test mode, try once a second for fast startup
1304 delay = 1 * 1e9 1297 delay = 1 * 1e9
1305 } 1298 }
1306 time.Sleep(delay) 1299 time.Sleep(delay)
1307 } 1300 }
1308 } 1301 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b