Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / BinaryExpression.java
index 3455363..7488cb8 100644 (file)
@@ -1,16 +1,26 @@
 package net.sourceforge.phpdt.internal.compiler.ast;
 
 import java.util.List;
-import java.util.ArrayList;
 
 /**
+ * a binary expression is a combination of two expressions with an operator.
+ * 
  * @author Matthieu Casanova
  */
-public class BinaryExpression extends OperatorExpression {
+public final class BinaryExpression extends OperatorExpression {
 
-  /** The two expressions. */
-  public Expression left,right;
+  /** The left expression. */
+  private final Expression left;
+  /** The right expression. */
+  private final Expression right;
 
+  /**
+   * Create a binary expression.
+   * 
+   * @param left     the left expression
+   * @param right    the right expression
+   * @param operator an operator taken in the {@link OperatorExpression} interface
+   */
   public BinaryExpression(final Expression left,
                           final Expression right,
                           final int operator) {
@@ -20,40 +30,41 @@ public class BinaryExpression extends OperatorExpression {
   }
 
   public String toStringExpression() {
-    final StringBuffer buff = new StringBuffer(left.toStringExpression());
-    buff.append(operatorToString());
-    buff.append(right.toStringExpression());
+    final String leftString = left.toStringExpression();
+    final String operatorString = operatorToString();
+    final String rightString = right.toStringExpression();
+    final StringBuffer buff = new StringBuffer(leftString.length() + operatorString.length() + rightString.length());
+    buff.append(leftString);
+    buff.append(operatorString);
+    buff.append(rightString);
     return buff.toString();
   }
 
   /**
    * Get the variables from outside (parameters, globals ...)
-   * @return the variables from outside
+   * 
+   * @param list the list where we will put variables
    */
-  public List getOutsideVariable() {
-    return new ArrayList();
-  }
+  public void getOutsideVariable(final List list) {}
 
   /**
    * get the modified variables.
-   * @return the variables from we change value
+   * 
+   * @param list the list where we will put variables
    */
-  public List getModifiedVariable() {
-    final ArrayList list = new ArrayList();
-    list.addAll(left.getModifiedVariable());
-    list.addAll(right.getModifiedVariable());
-    return list;
+  public void getModifiedVariable(final List list) {
+    left.getModifiedVariable(list);
+    right.getModifiedVariable(list);
   }
 
   /**
    * Get the variables used.
-   * @return the variables used
+   * 
+   * @param list the list where we will put variables
    */
-  public List getUsedVariable() {
-    final ArrayList list = new ArrayList();
-    list.addAll(left.getUsedVariable());
-    list.addAll(right.getUsedVariable());
-    return list;
+  public void getUsedVariable(final List list) {
+    left.getUsedVariable(list);
+    right.getUsedVariable(list);
   }
 
 }