void (@NotNull String input, @Nullable String region, boolean processReplacements, @NotNull String expected) { var visitor = new SnippetMarkup.SnippetVisitor() { final StringBuilder sb = new StringBuilder(); @Override public void visitPlainText(@NotNull PlainText plainText, @NotNull List<@NotNull LocationMarkupNode> activeNodes) { if (plainText.content().isEmpty()) return; if (!activeNodes.isEmpty()) { sb.append("// ").append(activeNodes).append("\n"); } sb.append(plainText.content()); } @Override public void visitError(@NotNull ErrorMarkup errorMarkup) { sb.append("Error: ").append(errorMarkup.message()).append("\n"); } }; SnippetMarkup.parse(input).visitSnippet(region, processReplacements, visitor); assertEquals(expected, visitor.sb.toString()); }