···11+package models
22+33+import (
44+ "github.com/bluesky-social/indigo/atproto/syntax"
55+ "github.com/sourcegraph/zoekt"
66+)
77+88+// Result is a single matched file. A zoekt FileMatch is either a filename
99+// match or a set of content matches, never both: File is set for the former,
1010+// Chunks for the latter.
1111+type Result struct {
1212+ RepoDID syntax.DID
1313+ FilePath string
1414+ Branches []string // branch names
1515+ Commit string // commit id
1616+ Language string
1717+1818+ File *Result_FileMatch // set for a filename match
1919+ Chunks []Result_ChunkMatch // set for content matches
2020+}
2121+2222+type Result_FileMatch struct {
2323+ // Ranges are the matched span(s) within FilePath. LineNumber is always 1 for
2424+ // filename matches; Column is 1-based and in runes.
2525+ Ranges []zoekt.Range
2626+}
2727+2828+type Result_ChunkMatch struct {
2929+ // Content is a contiguous run of complete lines that fully contains Ranges.
3030+ Content string
3131+ // ContentStartLine is the 1-based line number of Content's first line.
3232+ ContentStartLine int
3333+ // Ranges are the matched span(s) within the file. LineNumber/Column are
3434+ // 1-based, Column is in runes. A Range may span multiple lines.
3535+ Ranges []zoekt.Range
3636+}
3737+3838+// IsFileMatch tells if search result is from file-name match
3939+func (r *Result) IsFileMatch() bool {
4040+ return r.File != nil
4141+}
4242+4343+// IsChunkMatch tells if search result is from chunk match
4444+func (r *Result) IsChunkMatch() bool {
4545+ return len(r.Chunks) > 0
4646+}