MCPcopy Index your code
hub / github.com/google/codesearch / implies

Method implies

index/regexp.go:174–196  ·  view source on GitHub ↗

implies reports whether q implies r. It is okay for it to return false negatives.

(r *Query)

Source from the content-addressed store, hash-verified

172// implies reports whether q implies r.
173// It is okay for it to return false negatives.
174func (q *Query) implies(r *Query) bool {
175 if q.Op == QNone || r.Op == QAll {
176 // False implies everything.
177 // Everything implies True.
178 return true
179 }
180 if q.Op == QAll || r.Op == QNone {
181 // True implies nothing.
182 // Nothing implies False.
183 return false
184 }
185
186 if q.Op == QAnd || (q.Op == QOr && len(q.Trigram) == 1 && len(q.Sub) == 0) {
187 return trigramsImply(q.Trigram, r)
188 }
189
190 if q.Op == QOr && r.Op == QOr &&
191 len(q.Trigram) > 0 && len(q.Sub) == 0 &&
192 stringSet.isSubsetOf(q.Trigram, r.Trigram) {
193 return true
194 }
195 return false
196}
197
198func trigramsImply(t []string, q *Query) bool {
199 switch q.Op {

Callers 1

andOrMethod · 0.95

Calls 2

trigramsImplyFunction · 0.85
isSubsetOfMethod · 0.80

Tested by

no test coverage detected