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

Configure Feed

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

ctags: require scip-ctags to be present (#700)

Previously, we didn't require that scip-ctags be available even if if you set
`require_ctags` and set `language_map` to something like `go:scip`. Instead, we
silently fell back to `universal-ctags`. This is tricky and could mask a real
issue where we expect scip-ctags to be available but it isn't.

Now, we check if SCIP is needed based on `language_map`, and if so require that
scip-ctags is available.

+28 -17
+8 -8
build/builder.go
··· 564 564 finishedShards: map[string]string{}, 565 565 } 566 566 567 - if b.opts.CTagsPath == "" && b.opts.CTagsMustSucceed { 568 - return nil, fmt.Errorf("ctags binary not found, but CTagsMustSucceed set") 569 - } 570 - 571 - parserMap, err := ctags.NewParserMap(ctags.ParserBinMap{ 572 - ctags.UniversalCTags: b.opts.CTagsPath, 573 - ctags.ScipCTags: b.opts.ScipCTagsPath, 574 - }, b.opts.CTagsMustSucceed) 567 + parserMap, err := ctags.NewParserMap( 568 + ctags.ParserBinMap{ 569 + ctags.UniversalCTags: b.opts.CTagsPath, 570 + ctags.ScipCTags: b.opts.ScipCTagsPath, 571 + }, 572 + opts.LanguageMap, 573 + b.opts.CTagsMustSucceed, 574 + ) 575 575 576 576 if err != nil { 577 577 return nil, err
+7 -5
build/ctags.go
··· 60 60 continue 61 61 } 62 62 63 + // If the parser kind is unknown, default to universal-ctags 64 + if parserKind == ctags.UnknownCTags { 65 + parserKind = ctags.UniversalCTags 66 + } 67 + 63 68 parser := parserMap[parserKind] 64 69 if parser == nil { 65 - parser = parserMap[ctags.UniversalCTags] 66 - if parser == nil { 67 - // this happens if CTagsMustSucceed is not true and we didn't find universal-ctags 68 - continue 69 - } 70 + // this happens if CTagsMustSucceed is false and we didn't find the binary 71 + continue 70 72 } 71 73 72 74 monitor.BeginParsing(doc)
+13 -4
ctags/parser_map.go
··· 60 60 type ParserMap map[CTagsParserType]Parser 61 61 type ParserBinMap map[CTagsParserType]string 62 62 63 - func NewParserMap(bins ParserBinMap, cTagsMustSucceed bool) (ParserMap, error) { 63 + func NewParserMap(bins ParserBinMap, languageMap LanguageMap, cTagsMustSucceed bool) (ParserMap, error) { 64 64 parsers := make(ParserMap) 65 65 66 - for _, parserType := range []CTagsParserType{UniversalCTags, ScipCTags} { 66 + requiredTypes := []CTagsParserType{UniversalCTags} 67 + for _, parserType := range languageMap { 68 + if parserType == ScipCTags { 69 + requiredTypes = append(requiredTypes, ScipCTags) 70 + break 71 + } 72 + } 73 + 74 + for _, parserType := range requiredTypes { 67 75 bin := bins[parserType] 68 - if bin != "" { 76 + if bin == "" && cTagsMustSucceed { 77 + return nil, fmt.Errorf("ctags binary not found for %s parser type", ParserToString(parserType)) 78 + } else { 69 79 parser, err := NewParser(parserType, bin) 70 - 71 80 if err != nil && cTagsMustSucceed { 72 81 return nil, fmt.Errorf("ctags.NewParserMap: %v", err) 73 82 }