def scan_file(path)
      @parser.reset
      ast, comments = @parser.parse_with_comments(make_buffer(path))

      results = @call_finder.collect_calls ast do |send_node, method_name|
        send_node_to_key_occurrence(send_node, method_name)
      end

      magic_comments  = comments.select { |comment| comment.text =~ MAGIC_COMMENT_PREFIX }
      comment_to_node = Parser::Source::Comment.associate_locations(ast, magic_comments).tap do |h|
        # transform_values is only available in ActiveSupport 4.2+
        h.each { |k, v| h[k] = v.first }
      end.invert
      results + (magic_comments.flat_map do |comment|
        @parser.reset
        associated_node = comment_to_node[comment]
        @call_finder.collect_calls(
          @parser.parse(make_buffer(path, comment.text.sub(MAGIC_COMMENT_PREFIX, '').split(/\s+(?=t)/).join('; ')))
        ) do |send_node, _method_name|
          # method_name is not available at this stage
          send_node_to_key_occurrence(send_node, nil, location: associated_node || comment.location)
        end
      end)
    rescue Exception => e # rubocop:disable Lint/RescueException
      raise ::I18n::Tasks::CommandError.new(e, "Error scanning #{path}: #{e.message}")
    end
def scan_file(path)
      @parser.reset
      ast, comments = @parser.parse_with_comments(make_buffer(path))

      results = @call_finder.collect_calls ast do |send_node, method_name|
        send_node_to_key_occurrence(send_node, method_name)
      end

      magic_comments  = comments.select { |comment| comment.text =~ MAGIC_COMMENT_PREFIX }
      comment_to_node = Parser::Source::Comment.associate_locations(ast, magic_comments).tap do |h|
        # transform_values is only available in ActiveSupport 4.2+
        h.each { |k, v| h[k] = v.first }
      end.invert
      results + (magic_comments.flat_map do |comment|
        @parser.reset
        associated_node = comment_to_node[comment]
        @call_finder.collect_calls(
          @parser.parse(make_buffer(path, comment.text.sub(MAGIC_COMMENT_PREFIX, '').split(/\s+(?=t)/).join('; ')))
        ) do |send_node, _method_name|
          # method_name is not available at this stage
          send_node_to_key_occurrence(send_node, nil, location: associated_node || comment.location)
        end
      end)
    rescue Exception => e # rubocop:disable Lint/RescueException
      raise ::I18n::Tasks::CommandError.new(e, "Error scanning #{path}: #{e.message}")
    end
Extract all occurrences of translate calls from the file at the given path.

 @return [Array<[key, Results::KeyOccurrence]>] each occurrence found in the file