int (@Nullable String region) { var visitor = new SnippetVisitor() { int maxIndent = Integer.MAX_VALUE; @Override public void visitPlainText(@NotNull PlainText plainText, @NotNull List<@NotNull LocationMarkupNode> activeNodes) { if (maxIndent == 0) return; String content = plainText.content(); if (content.isBlank()) return; int curIndent = 0; while (curIndent < content.length() && content.charAt(curIndent) != '\n' && Character.isWhitespace(content.charAt(curIndent))) { curIndent++; } maxIndent = Math.min(maxIndent, curIndent); } }; visitSnippet(region, visitor); return visitor.maxIndent == Integer.MAX_VALUE ? 0 : visitor.maxIndent; }