public ImmutableList<Replacement> format(
      SnippetKind kind,
      String source,
      List<Range<Integer>> ranges,
      int initialIndent,
      boolean includeComments)
      throws FormatterException {
    RangeSet<Integer> rangeSet = TreeRangeSet.create();
    for (Range<Integer> range : ranges) {
      rangeSet.add(range);
    }
    if (includeComments) {
      if (kind != SnippetKind.COMPILATION_UNIT) {
        throw new IllegalArgumentException(
            "comment formatting is only supported for compilation units");
      }
      return formatter.getFormatReplacements(source, ranges);
    }
    SnippetWrapper wrapper = snippetWrapper(kind, source, initialIndent);
    ranges = offsetRanges(ranges, wrapper.offset);

    String replacement = formatter.formatSource(wrapper.contents.toString(), ranges);
    replacement =
        replacement.substring(
            wrapper.offset,
            replacement.length() - (wrapper.contents.length() - wrapper.offset - source.length()));

    return toReplacements(source, replacement).stream()
        .filter(r -> rangeSet.encloses(r.getReplaceRange()))
        .collect(toImmutableList());
  }
@Test
  public void classMember() throws FormatterException {
    String input = "void f() {\n}";
    List<Replacement> replacements =
        new SnippetFormatter()
            .format(
                SnippetKind.CLASS_BODY_DECLARATIONS,
                input,
                ImmutableList.of(Range.closedOpen(0, input.length())),
                4,
                false);
    assertThat(replacements).containsExactly(Replacement.create(10, 11, ""));
  }