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.DOUBLE_COLON) return ChildRole.DOUBLE_COLON; if (elType == JavaTokenType.IDENTIFIER) return ChildRole.REFERENCE_NAME; if (elType == JavaElementType.REFERENCE_EXPRESSION) return ChildRole.CLASS_REFERENCE; return ChildRole.EXPRESSION; } }; }