Skip to content

Add reposet token to query parser #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@
"cwd": "${workspaceFolder}",
"args": ["-index", "${input:indexPath}"]
},
{
"name": "Webserver (rpc)",
"type": "go",
"request": "launch",
"mode": "auto",
"program": "cmd/zoekt-webserver",
"cwd": "${workspaceFolder}",
"args": ["-index", "${input:indexPath}", "-rpc"],
// Set a long watchdog tick to help with debugging
"env": {
"ZOEKT_WATCHDOG_TICK": "24h",
"SRC_LOG_LEVEL": "debug"
}
},
{
"name": "Attach to Process (from list)",
"type": "go",
Expand Down
16 changes: 16 additions & 0 deletions query/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"log"
"regexp/syntax"
"strings"

"github.com/grafana/regexp"
"github.com/sourcegraph/zoekt/internal/languages"
Expand Down Expand Up @@ -239,6 +240,18 @@ func parseExpr(in []byte) (Q, int, error) {
}
// Later we will lift this into a root, like we do for caseQ
expr = &Type{Type: t, Child: nil}
case tokRepoSet:
// Split the text by commas to get individual repo names
repos := strings.Split(text, ",")
set := make(map[string]bool)
for _, repo := range repos {
repo = strings.TrimSpace(repo)
if repo != "" {
set[repo] = true
}
}

expr = &RepoSet{Set: set}
}

return expr, len(in) - len(b), nil
Expand Down Expand Up @@ -392,6 +405,7 @@ const (
tokArchived = 15
tokPublic = 16
tokFork = 17
tokRepoSet = 18
)

var tokNames = map[int]string{
Expand All @@ -412,6 +426,7 @@ var tokNames = map[int]string{
tokLang: "Language",
tokSym: "Symbol",
tokType: "Type",
tokRepoSet: "RepoSet",
}

var prefixes = map[string]int{
Expand All @@ -432,6 +447,7 @@ var prefixes = map[string]int{
"sym:": tokSym,
"t:": tokType,
"type:": tokType,
"reposet:": tokRepoSet,
}

var reservedWords = map[string]int{
Expand Down
Loading