ASTNode () { return new CompositeElement(this) { @Override public void replaceChildInternal(@NotNull ASTNode child, @NotNull TreeElement newElement) { super.replaceChildInternal(child, JavaSourceUtil.addParenthToReplacedChild(child, newElement, getManager())); } @Override public int getChildRole(@NotNull ASTNode child) { IElementType elType = child.getElementType(); if (elType == JavaTokenType.ARROW) return ChildRole.ARROW; if (elType == JavaElementType.PARAMETER_LIST) return ChildRole.PARAMETER_LIST; if (elType == JavaElementType.CODE_BLOCK) return ChildRole.LBRACE; return ChildRole.EXPRESSION; } }; }