Changes:
[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 java.util.List;
4
5 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
6 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
7 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
8
9 import org.eclipse.jface.resource.ImageDescriptor;
10 import org.eclipse.jface.text.Position;
11
12 /**
13  * a Define.
14  * define(expression,expression)
15  * @author Matthieu Casanova
16  */
17 public class Define extends Statement implements Outlineable {
18
19   public Expression defineName,defineValue;
20
21   private Object parent;
22   private Position position;
23
24   public Define(final Object parent,
25                 final Expression defineName,
26                 final Expression defineValue,
27                 final int sourceStart,
28                 final int sourceEnd) {
29     super(sourceStart, sourceEnd);
30     this.parent = parent;
31     this.defineName = defineName;
32     this.defineValue = defineValue;
33     position = new Position(sourceStart, sourceEnd);
34   }
35
36   public String toString(final int tab) {
37     final StringBuffer buff = new StringBuffer(tabString(tab));
38     buff.append("define(");
39     buff.append(defineName.toStringExpression());
40     buff.append(", ");
41     buff.append(defineValue.toStringExpression());
42     buff.append(")");
43     return buff.toString();
44   }
45
46   public String toString() {
47     final StringBuffer buff = new StringBuffer(defineName.toStringExpression());
48     buff.append(" = ");
49     buff.append(defineValue.toStringExpression());
50     return buff.toString();
51   }
52
53   public ImageDescriptor getImage() {
54     return PHPUiImages.DESC_VAR;
55   }
56
57   public Object getParent() {
58     return parent;
59   }
60
61   public Position getPosition() {
62     return position;
63   }
64
65   /**
66    * Get the variables from outside (parameters, globals ...)
67    */
68   public void getOutsideVariable(final List list) {
69     list.add(new VariableUsage(defineName.toStringExpression(),sourceStart));//todo: someday : evaluate the defineName
70   }
71
72   /**
73    * get the modified variables.
74    */
75   public void getModifiedVariable(final List list) {
76   }
77
78   /**
79    * Get the variables used.
80    */
81   public void getUsedVariable(final List list) {
82   }
83 }