class ERBLint::Utils::BlockMap

def build_map

def build_map
  erb_nodes.each do |erb_node|
    indicator_node, _, code_node, _ = *erb_node
    length = code_node.loc.size
    start = current_pos
    if indicator_node.nil?
      append("#{code_node.loc.source}\n")
    elsif block?(code_node.loc.source)
      append("src= #{code_node.loc.source}\n")
      start += 5
    else
      append("src=(#{code_node.loc.source});\n")
      start += 5
    end
    ruby_range = Range.new(start, start + length)
    @entries << Entry.new(erb_node, ruby_range)
  end
  ruby_node = BetterHtml::TestHelper::RubyNode.parse(@ruby_code)
  raise ParseError unless ruby_node
  ruby_node.descendants(:block, :if, :for).each do |node|
    @connections << ConnectedErbNodes.new(
      node.type,
      extract_map_locations(node)
        .map { |loc| find_entry(loc) }
        .compact.map(&:node),
    )
  end
  ruby_node.descendants(:kwbegin).each do |node|
    @connections << ConnectedErbNodes.new(
      :begin,
      (extract_map_locations(node) + rescue_locations(node))
        .map { |loc| find_entry(loc) }
        .compact.map(&:node),
    )
  end
  ruby_node.descendants(:case).each do |node|
    @connections << ConnectedErbNodes.new(
      node.type,
      (extract_map_locations(node) + when_locations(node))
        .map { |loc| find_entry(loc) }
        .compact.map(&:node),
    )
  end
  group_overlapping_connections
end