diff --git a/platform/lang-impl/src/com/intellij/formatting/BlockDebugUtil.java b/platform/lang-impl/src/com/intellij/formatting/BlockDebugUtil.java index fc39a126d0a6..f76e2eb14be1 100644 --- a/platform/lang-impl/src/com/intellij/formatting/BlockDebugUtil.java +++ b/platform/lang-impl/src/com/intellij/formatting/BlockDebugUtil.java @@ -36,11 +36,21 @@ public class BlockDebugUtil { */ public static void dumpBlockTree(PrintStream out, Block block) { out.println("--- BLOCK TREE DUMP ---"); - dumpBlockTree(out, block, ""); + dumpBlockTree(out, block, "", true); out.println("--- END OF DUMP ---\n\n"); } - private static void dumpBlockTree(PrintStream out, Block block, String indent) { + + /** + * Print out a single block info without child blocks. + * @param out The output stream. + * @param block The block to print the info for. + */ + public static void dumpBlock(PrintStream out, Block block) { + dumpBlockTree(out, block, "", false); + } + + private static void dumpBlockTree(PrintStream out, Block block, String indent, boolean withChildren) { if (block == null) return; out.print(indent + block.getClass().getSimpleName()); if (block.getIndent() != null) { @@ -49,6 +59,7 @@ public class BlockDebugUtil { else { out.print(" "); } + out.print(" " + block.getTextRange() + " "); if (block instanceof ASTBlock) { ASTNode node = ((ASTBlock)block).getNode(); if (node != null) { @@ -61,20 +72,20 @@ public class BlockDebugUtil { out.print(" \"" + text + "\""); } } - System.out.println(); - List subBlocks = getSubBlocks(block); - if (subBlocks != null && subBlocks.size() > 0) { - out.println(indent + "{"); - for (Block child : subBlocks) { - dumpBlockTree(out, child, indent + " "); + out.println(); + if (withChildren) { + List subBlocks = getSubBlocks(block); + if (subBlocks != null && subBlocks.size() > 0) { + out.println(indent + "{"); + for (Block child : subBlocks) { + dumpBlockTree(out, child, indent + " ", true); + } + out.println(indent + "}"); } - out.println(indent + "}"); } } private static List getSubBlocks(Block root) { - if (root instanceof AbstractBlock) return ((AbstractBlock)root).getSubBlocks(); - if (root instanceof DataLanguageBlockWrapper) return ((DataLanguageBlockWrapper)root).getSubBlocks(); - return null; + return root.getSubBlocks(); } }