1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
4 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
5 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
6 import org.eclipse.jface.resource.ImageDescriptor;
7 import org.eclipse.jface.text.Position;
13 * define(expression,expression)
15 * @author Matthieu Casanova
17 public final class Define extends Statement implements Outlineable {
19 private final Expression defineName;
20 private final Expression defineValue;
22 private final Object parent;
23 private final Position position;
25 public Define(final Object parent,
26 final Expression defineName,
27 final Expression defineValue,
28 final int sourceStart,
29 final int sourceEnd) {
30 super(sourceStart, sourceEnd);
32 this.defineName = defineName;
33 this.defineValue = defineValue;
34 position = new Position(sourceStart, sourceEnd);
37 public String toString(final int tab) {
38 final String nameString = defineName.toStringExpression();
39 final String valueString = defineValue.toStringExpression();
40 final StringBuffer buff = new StringBuffer(tab + 10 + nameString.length() + valueString.length());
41 buff.append(tabString(tab));
42 buff.append("define(");
43 buff.append(nameString);
45 buff.append(valueString);
47 return buff.toString();
50 public String toString() {
51 final String nameString = defineName.toStringExpression();
52 final String valueString = defineValue.toStringExpression();
53 final StringBuffer buff = new StringBuffer(nameString.length() + valueString.length() + 3);
54 buff.append(nameString);
56 buff.append(valueString);
57 return buff.toString();
60 public ImageDescriptor getImage() {
61 return PHPUiImages.DESC_VAR;
64 public Object getParent() {
68 public Position getPosition() {
73 * Get the variables from outside (parameters, globals ...)
75 * @param list the list where we will put variables
77 public void getOutsideVariable(final List list) {
78 list.add(new VariableUsage(defineName.toStringExpression(), sourceStart));//todo: someday : evaluate the defineName
82 * get the modified variables.
84 * @param list the list where we will put variables
86 public void getModifiedVariable(final List list) {}
89 * Get the variables used.
91 * @param list the list where we will put variables
93 public void getUsedVariable(final List list) {}