diff --git a/build/builder.go b/build/builder.go index 82aba3be..fa666821 100644 --- a/build/builder.go +++ b/build/builder.go @@ -249,8 +249,8 @@ type Builder struct { docChecker zoekt.DocChecker size int - parserMap ctags.ParserMap - building sync.WaitGroup + parserFactory ctags.ParserFactory + building sync.WaitGroup errMu sync.Mutex buildError error @@ -563,7 +563,7 @@ func NewBuilder(opts Options) (*Builder, error) { finishedShards: map[string]string{}, } - parserMap, err := ctags.NewParserMap( + parserFactory, err := ctags.NewParserFactory( ctags.ParserBinMap{ ctags.UniversalCTags: b.opts.CTagsPath, ctags.ScipCTags: b.opts.ScipCTagsPath, @@ -576,7 +576,7 @@ func NewBuilder(opts Options) (*Builder, error) { return nil, err } - b.parserMap = parserMap + b.parserFactory = parserFactory b.shardLogger = &lumberjack.Logger{ Filename: filepath.Join(opts.IndexDir, "zoekt-builder-shard-log.tsv"), @@ -1021,7 +1021,7 @@ func sortDocuments(todo []*zoekt.Document) { func (b *Builder) buildShard(todo []*zoekt.Document, nextShardNum int) (*finishedShard, error) { if !b.opts.DisableCTags && (b.opts.CTagsPath != "" || b.opts.ScipCTagsPath != "") { - err := ctagsAddSymbolsParserMap(todo, b.opts.LanguageMap, b.parserMap) + err := parseSymbols(todo, b.opts.LanguageMap, b.parserFactory) if b.opts.CTagsMustSucceed && err != nil { return nil, err } diff --git a/build/ctags.go b/build/ctags.go index 7308371f..074ba53a 100644 --- a/build/ctags.go +++ b/build/ctags.go @@ -42,7 +42,7 @@ func normalizeLanguage(filetype string) string { return normalized } -func ctagsAddSymbolsParserMap(todo []*zoekt.Document, languageMap ctags.LanguageMap, parserMap ctags.ParserMap) error { +func parseSymbols(todo []*zoekt.Document, languageMap ctags.LanguageMap, parserFactory ctags.ParserFactory) error { monitor := newMonitor() defer monitor.Stop() @@ -65,7 +65,7 @@ func ctagsAddSymbolsParserMap(todo []*zoekt.Document, languageMap ctags.Language parserKind = ctags.UniversalCTags } - parser := parserMap[parserKind] + parser := parserFactory[parserKind] if parser == nil { // this happens if CTagsMustSucceed is false and we didn't find the binary continue diff --git a/ctags/parser_map.go b/ctags/parser_map.go index fb601617..73f235bd 100644 --- a/ctags/parser_map.go +++ b/ctags/parser_map.go @@ -60,11 +60,11 @@ func StringToParser(str string) CTagsParserType { } } -type ParserMap map[CTagsParserType]Parser +type ParserFactory map[CTagsParserType]Parser type ParserBinMap map[CTagsParserType]string -func NewParserMap(bins ParserBinMap, languageMap LanguageMap, cTagsMustSucceed bool) (ParserMap, error) { - parsers := make(ParserMap) +func NewParserFactory(bins ParserBinMap, languageMap LanguageMap, cTagsMustSucceed bool) (ParserFactory, error) { + parsers := make(ParserFactory) requiredTypes := []CTagsParserType{UniversalCTags} for _, parserType := range languageMap { @@ -81,7 +81,7 @@ func NewParserMap(bins ParserBinMap, languageMap LanguageMap, cTagsMustSucceed b } if err := checkBinary(parserType, bin); err != nil && cTagsMustSucceed { - return nil, fmt.Errorf("ctags.NewParserMap: %v", err) + return nil, fmt.Errorf("ctags.NewParserFactory: %v", err) } parsers[parserType] = NewParser(bin)