A little bug in the tostring method fixed
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Define.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import org.eclipse.jface.text.Position;
4 import org.eclipse.jface.resource.ImageDescriptor;
5 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
6 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
7
8 /**
9  * a Define.
10  * define(expression,expression)
11  * @author Matthieu Casanova
12  */
13 public class Define extends Statement implements Outlineable {
14
15   public Expression defineName,defineValue;
16
17   private Object parent;
18   private Position position;
19
20   public Define(final Object parent,
21                 final Expression defineName,
22                 final Expression defineValue,
23                 final int sourceStart,
24                 final int sourceEnd) {
25     super(sourceStart, sourceEnd);
26     this.parent = parent;
27     this.defineName = defineName;
28     this.defineValue = defineValue;
29     position = new Position(sourceStart, sourceEnd);
30   }
31
32   public String toString(final int tab) {
33     final StringBuffer buff = new StringBuffer(tabString(tab));
34     buff.append("define(");
35     buff.append(defineName.toStringExpression());
36     buff.append(", ");
37     buff.append(defineValue.toStringExpression());
38     buff.append(")");
39     return buff.toString();
40   }
41
42   public String toString() {
43     final StringBuffer buff = new StringBuffer(defineName.toStringExpression());
44     buff.append(" = ");
45     buff.append(defineValue.toStringExpression());
46     return buff.toString();
47   }
48
49   public ImageDescriptor getImage() {
50     return PHPUiImages.DESC_VAR;
51   }
52
53   public Object getParent() {
54     return parent;
55   }
56
57   public Position getPosition() {
58     return position;
59   }
60 }