def catalog bundle
      new_map_hash = {}
      # Bundle always needs to be merged if it adds or removes sources
      merged = (bundle.sources.length == source_map_hash.values.length)
      bundle.sources.each do |source|
        if source_map_hash.key?(source.filename)
          if source_map_hash[source.filename].code == source.code && source_map_hash[source.filename].source.synchronized? && source.synchronized?
            new_map_hash[source.filename] = source_map_hash[source.filename]
          elsif !source.synchronized?
            new_map_hash[source.filename] = source_map_hash[source.filename]
            # @todo Smelly instance variable access
            new_map_hash[source.filename].instance_variable_set(:@source, source)
          else
            map = Solargraph::SourceMap.map(source)
            if source_map_hash[source.filename].try_merge!(map)
              new_map_hash[source.filename] = source_map_hash[source.filename]
            else
              new_map_hash[source.filename] = map
              merged = false
            end
          end
        else
          map = Solargraph::SourceMap.map(source)
          new_map_hash[source.filename] = map
          merged = false
        end
      end
      return self if merged
      pins = []
      reqs = []
      # @param map [SourceMap]
      new_map_hash.values.each do |map|
        pins.concat map.pins
        reqs.concat map.requires.map(&:name)
      end
      reqs.concat bundle.workspace.config.required
      unless bundle.workspace.require_paths.empty?
        reqs.delete_if do |r|
          result = false
          bundle.workspace.require_paths.each do |l|
            pn = Pathname.new(bundle.workspace.directory).join(l, "#{r}.rb")
            if new_map_hash.keys.include?(pn.to_s)
              result = true
              break
            end
          end
          result
        end
      end
      yard_map.change(reqs)
      new_store = Store.new(pins + yard_map.pins)
      @mutex.synchronize {
        @cache.clear
        @source_map_hash = new_map_hash
        @store = new_store
        @unresolved_requires = yard_map.unresolved_requires
      }
      # resolve_method_aliases
      self
    end
def catalog bundle
      new_map_hash = {}
      # Bundle always needs to be merged if it adds or removes sources
      merged = (bundle.sources.length == source_map_hash.values.length)
      bundle.sources.each do |source|
        if source_map_hash.key?(source.filename)
          if source_map_hash[source.filename].code == source.code && source_map_hash[source.filename].source.synchronized? && source.synchronized?
            new_map_hash[source.filename] = source_map_hash[source.filename]
          elsif !source.synchronized?
            new_map_hash[source.filename] = source_map_hash[source.filename]
            # @todo Smelly instance variable access
            new_map_hash[source.filename].instance_variable_set(:@source, source)
          else
            map = Solargraph::SourceMap.map(source)
            if source_map_hash[source.filename].try_merge!(map)
              new_map_hash[source.filename] = source_map_hash[source.filename]
            else
              new_map_hash[source.filename] = map
              merged = false
            end
          end
        else
          map = Solargraph::SourceMap.map(source)
          new_map_hash[source.filename] = map
          merged = false
        end
      end
      return self if merged
      pins = []
      reqs = []
      # @param map [SourceMap]
      new_map_hash.values.each do |map|
        pins.concat map.pins
        reqs.concat map.requires.map(&:name)
      end
      reqs.concat bundle.workspace.config.required
      unless bundle.workspace.require_paths.empty?
        reqs.delete_if do |r|
          result = false
          bundle.workspace.require_paths.each do |l|
            pn = Pathname.new(bundle.workspace.directory).join(l, "#{r}.rb")
            if new_map_hash.keys.include?(pn.to_s)
              result = true
              break
            end
          end
          result
        end
      end
      yard_map.change(reqs)
      new_store = Store.new(pins + yard_map.pins)
      @mutex.synchronize {
        @cache.clear
        @source_map_hash = new_map_hash
        @store = new_store
        @unresolved_requires = yard_map.unresolved_requires
      }
      # resolve_method_aliases
      self
    end
Catalog a bundle.

 @param bundle [Bundle]
 @return [self]