/*
 * @author max
 */
package com.intellij.psi.impl.source.tree.java;

import com.intellij.lang.ASTNode;
import com.intellij.psi.impl.source.tree.CompositePsiElement;
import com.intellij.psi.impl.source.tree.JavaElementType;
import com.intellij.psi.impl.source.tree.SourceUtil;
import com.intellij.psi.impl.source.tree.TreeElement;
import com.intellij.psi.tree.IElementType;
import org.jetbrains.annotations.NotNull;

public class ExpressionPsiElement extends CompositePsiElement {
  public ExpressionPsiElement(final IElementType type) {
    super(type);
  }

  public void replaceChildInternal(@NotNull ASTNode child, @NotNull TreeElement newElement) {
    boolean needParenth = ReplaceExpressionUtil.isNeedParenthesis(child, newElement);
    if (needParenth) {
      newElement = SourceUtil.addParenthToReplacedChild(JavaElementType.PARENTH_EXPRESSION, newElement, getManager());
    }
    super.replaceChildInternal(child, newElement);
  }
}
@@ -143,192 +143,9 @@
 ree.
-CompositePsiElement;%0Aimport com.intellij.psi.impl.source.tree.JavaElementType;%0Aimport com.intellij.psi.impl.source.tree.SourceUtil;%0Aimport com.intellij.psi.impl.source.tree.TreeElement
+*
 ;%0Aim
@@ -461,24 +461,101 @@
 wElement) %7B%0A
+    if (ElementType.EXPRESSION_BIT_SET.contains(child.getElementType())) %7B%0A  
     boolean 
@@ -628,24 +628,26 @@
 ement);%0A    
+ 
+ 
 if (needPare
@@ -649,24 +649,26 @@
 dParenth) %7B%0A
+  
       newEle
@@ -774,16 +774,24 @@
 ger());%0A
+      %7D%0A
     %7D%0A  

fix tests.