MCPcopy Index your code
hub / github.com/coder/coder / newQueryPlan

Function newQueryPlan

agent/filefinder/query.go:36–66  ·  view source on GitHub ↗
(q string)

Source from the content-addressed store, hash-verified

34}
35
36func newQueryPlan(q string) *queryPlan {
37 norm := normalizeQuery(q)
38 p := &queryPlan{Original: q, Normalized: norm}
39 if len(norm) == 0 {
40 p.IsShort = true
41 return p
42 }
43 raw := strings.ReplaceAll(norm, "/", " ")
44 parts := strings.Fields(raw)
45 p.HasSlash = strings.ContainsRune(norm, '/')
46 for _, part := range parts {
47 p.Tokens = append(p.Tokens, []byte(part))
48 }
49 if len(p.Tokens) > 0 {
50 p.BasenameQ = p.Tokens[len(p.Tokens)-1]
51 if len(p.Tokens) > 1 {
52 p.DirTokens = p.Tokens[:len(p.Tokens)-1]
53 }
54 }
55 p.IsShort = true
56 for _, tok := range p.Tokens {
57 if len(tok) >= 3 {
58 p.IsShort = false
59 break
60 }
61 }
62 if !p.IsShort {
63 p.Trigrams = extractQueryTrigrams(p.Tokens)
64 }
65 return p
66}
67
68func extractQueryTrigrams(tokens [][]byte) []uint32 {
69 seen := make(map[uint32]struct{})

Callers 1

SearchMethod · 0.85

Calls 3

normalizeQueryFunction · 0.85
extractQueryTrigramsFunction · 0.85
FieldsMethod · 0.65

Tested by

no test coverage detected