MarkdownTableRow (@NotNull Project project, @NotNull Collection<String> contents) { final var builder = new StringBuilder(); builder.append('|'); //noinspection StringRepeatCanBeUsed for (int count = 0; count < contents.size(); count += 1) { builder.append(" |"); } builder.append('\n'); builder.append('|'); //noinspection StringRepeatCanBeUsed for (int count = 0; count < contents.size(); count += 1) { builder.append("-----|"); } builder.append('\n'); builder.append('|'); for (var content : contents) { builder.append(content); builder.append('|'); } builder.append('\n'); builder.append('|'); //noinspection StringRepeatCanBeUsed for (int count = 0; count < contents.size(); count += 1) { builder.append(" |"); } builder.append('\n'); final var file = createFile(project, builder.toString()); final var element = Objects.requireNonNull(file.findElementAt(0)); final var row = Objects.requireNonNull(findTable(element).getLastChild().getPrevSibling().getPrevSibling()); if (row instanceof MarkdownTableRow) { return (MarkdownTableRow)row; } else { throw new IllegalStateException("Failed to find row element"); } }