Some minor changes
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / BinaryExpression.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import java.util.List;
4
5 /**
6  * a binary expression is a combination of two expressions with an operator.
7  * 
8  * @author Matthieu Casanova
9  */
10 public final class BinaryExpression extends OperatorExpression {
11
12   /** The left expression. */
13   private final Expression left;
14   /** The right expression. */
15   private final Expression right;
16
17   /**
18    * Create a binary expression.
19    * 
20    * @param left     the left expression
21    * @param right    the right expression
22    * @param operator an operator taken in the {@link OperatorExpression} interface
23    */
24   public BinaryExpression(final Expression left,
25                           final Expression right,
26                           final int operator) {
27     super(operator, left.sourceStart, right.sourceEnd);
28     this.left = left;
29     this.right = right;
30   }
31
32   public String toStringExpression() {
33     final String leftString = left.toStringExpression();
34     final String operatorString = operatorToString();
35     final String rightString = right.toStringExpression();
36     final StringBuffer buff = new StringBuffer(leftString.length() + operatorString.length() + rightString.length());
37     buff.append(leftString);
38     buff.append(operatorString);
39     buff.append(rightString);
40     return buff.toString();
41   }
42
43   /**
44    * Get the variables from outside (parameters, globals ...)
45    * 
46    * @param list the list where we will put variables
47    */
48   public void getOutsideVariable(final List list) {}
49
50   /**
51    * get the modified variables.
52    * 
53    * @param list the list where we will put variables
54    */
55   public void getModifiedVariable(final List list) {
56     left.getModifiedVariable(list);
57     right.getModifiedVariable(list);
58   }
59
60   /**
61    * Get the variables used.
62    * 
63    * @param list the list where we will put variables
64    */
65   public void getUsedVariable(final List list) {
66     left.getUsedVariable(list);
67     right.getUsedVariable(list);
68   }
69
70 }