void (FlyweightCapableTreeStructure<LighterASTNode> tree, @NotNull LighterASTNode node, Appendable buffer, int indent, boolean showWhitespaces) { IElementType tokenType = node.getTokenType(); if (!showWhitespaces && tokenType == TokenType.WHITE_SPACE) return; boolean isLeaf = node instanceof LighterASTTokenNode; StringUtil.repeatSymbol(buffer, ' ', indent); try { if (tokenType == TokenType.ERROR_ELEMENT) { buffer.append("PsiErrorElement:").append(PsiBuilderImpl.getErrorMessage(node)); } else if (tokenType == TokenType.WHITE_SPACE) { buffer.append("PsiWhiteSpace"); } else { buffer.append(isLeaf ? "PsiElement" : "Element").append('(').append(tokenType.toString()).append(')'); } if (isLeaf) { String text = ((LighterASTTokenNode)node).getText().toString(); buffer.append("('").append(fixWhiteSpaces(text)).append("')"); } buffer.append('\n'); if (!isLeaf) { Ref<LighterASTNode[]> kids = new Ref<>(); int numKids = tree.getChildren(node, kids); if (numKids == 0) { StringUtil.repeatSymbol(buffer, ' ', indent + 2); buffer.append("<empty list>\n"); } else { for (int i = 0; i < numKids; i++) { lightTreeToBuffer(tree, kids.get()[i], buffer, indent + 2, showWhitespaces); } } } } catch (IOException e) { LOG.error(e); } }