Skip to content

Commit 7d18962

Browse files
Add reposet token to query parser (#5)
1 parent 57019fe commit 7d18962

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

.vscode/launch.json

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222
"cwd": "${workspaceFolder}",
2323
"args": ["-index", "${input:indexPath}"]
2424
},
25+
{
26+
"name": "Webserver (rpc)",
27+
"type": "go",
28+
"request": "launch",
29+
"mode": "auto",
30+
"program": "cmd/zoekt-webserver",
31+
"cwd": "${workspaceFolder}",
32+
"args": ["-index", "${input:indexPath}", "-rpc"],
33+
// Set a long watchdog tick to help with debugging
34+
"env": {
35+
"ZOEKT_WATCHDOG_TICK": "24h",
36+
"SRC_LOG_LEVEL": "debug"
37+
}
38+
},
2539
{
2640
"name": "Attach to Process (from list)",
2741
"type": "go",

query/parse.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"fmt"
2020
"log"
2121
"regexp/syntax"
22+
"strings"
2223

2324
"github.com/grafana/regexp"
2425
"github.com/sourcegraph/zoekt/internal/languages"
@@ -239,6 +240,18 @@ func parseExpr(in []byte) (Q, int, error) {
239240
}
240241
// Later we will lift this into a root, like we do for caseQ
241242
expr = &Type{Type: t, Child: nil}
243+
case tokRepoSet:
244+
// Split the text by commas to get individual repo names
245+
repos := strings.Split(text, ",")
246+
set := make(map[string]bool)
247+
for _, repo := range repos {
248+
repo = strings.TrimSpace(repo)
249+
if repo != "" {
250+
set[repo] = true
251+
}
252+
}
253+
254+
expr = &RepoSet{Set: set}
242255
}
243256

244257
return expr, len(in) - len(b), nil
@@ -392,6 +405,7 @@ const (
392405
tokArchived = 15
393406
tokPublic = 16
394407
tokFork = 17
408+
tokRepoSet = 18
395409
)
396410

397411
var tokNames = map[int]string{
@@ -412,6 +426,7 @@ var tokNames = map[int]string{
412426
tokLang: "Language",
413427
tokSym: "Symbol",
414428
tokType: "Type",
429+
tokRepoSet: "RepoSet",
415430
}
416431

417432
var prefixes = map[string]int{
@@ -432,6 +447,7 @@ var prefixes = map[string]int{
432447
"sym:": tokSym,
433448
"t:": tokType,
434449
"type:": tokType,
450+
"reposet:": tokRepoSet,
435451
}
436452

437453
var reservedWords = map[string]int{

0 commit comments

Comments
 (0)