@Override
  public JavaFileObject createSourceFile(CharSequence name, Element... originatingElements)
      throws IOException {
    return new FormattingJavaFileObject(
        delegate.createSourceFile(name, originatingElements), formatter, messager);
  }
@Test
  public void invalidSyntaxDoesNotThrowError() throws IOException {
    List<String> logMessages = new ArrayList<>();
    Messager messager =
        new Messager() {
          @Override
          public void printMessage(javax.tools.Diagnostic.Kind kind, CharSequence msg) {
            logMessages.add(kind + ";" + msg);
          }

          @Override
          public void printMessage(javax.tools.Diagnostic.Kind kind, CharSequence msg, Element e) {}

          @Override
          public void printMessage(
              javax.tools.Diagnostic.Kind kind, CharSequence msg, Element e, AnnotationMirror a) {}

          @Override
          public void printMessage(
              javax.tools.Diagnostic.Kind kind,
              CharSequence msg,
              Element e,
              AnnotationMirror a,
              AnnotationValue v) {}
        };

    String file = Joiner.on('\n').join("package foo;", "public class Bar {");
    FormattingFiler formattingFiler = new FormattingFiler(new FakeFiler(), messager);
    try (Writer writer = formattingFiler.createSourceFile("foo.Bar").openWriter()) {
      writer.write(file);
    }

    assertThat(logMessages).containsExactly("NOTE;Error formatting foo.Bar");
  }