fork of https://github.com/sourcegraph/zoekt
0

Configure Feed

Select the types of activity you want to include in your feed.

eval: shortcut Language query.

If a shard that doesn't have any files with a certain language,
evaluate the language atom as false.

Fixes #43

Change-Id: Ic63ebcef5e820f23f3329d234813293eaf547220

+25
+6
eval.go
··· 62 62 if r, ok := q.(*query.Repo); ok { 63 63 return &query.Const{Value: strings.Contains(d.repoMetaData.Name, r.Pattern)} 64 64 } 65 + if l, ok := q.(*query.Language); ok { 66 + _, has := d.metaData.LanguageMap[l.Language] 67 + if !has { 68 + return &query.Const{Value: false} 69 + } 70 + } 65 71 return q 66 72 }) 67 73 return query.Simplify(eval)
+19
index_test.go
··· 1541 1541 } 1542 1542 } 1543 1543 1544 + func TestLangShortcut(t *testing.T) { 1545 + content := []byte("bla needle bla") 1546 + b := testIndexBuilder(t, &Repository{Name: "reponame"}, 1547 + Document{Name: "f2", Language: "java", Content: content}, 1548 + Document{Name: "f3", Language: "cpp", Content: content}, 1549 + ) 1550 + 1551 + q := query.NewAnd(&query.Substring{Pattern: "needle"}, 1552 + &query.Language{Language: "fortran"}) 1553 + 1554 + res := searchForTest(t, b, q) 1555 + if len(res.Files) != 0 { 1556 + t.Fatalf("got %v, want 0 results", res.Files) 1557 + } 1558 + if res.Stats.IndexBytesLoaded > 0 { 1559 + t.Errorf("got IndexBytesLoaded %d, want 0", res.Stats.IndexBytesLoaded) 1560 + } 1561 + } 1562 + 1544 1563 func TestNoTextMatchAtoms(t *testing.T) { 1545 1564 content := []byte("bla needle bla") 1546 1565 b := testIndexBuilder(t, &Repository{Name: "reponame"},