1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.ast.Expression;
4 import net.sourceforge.phpdt.internal.compiler.ast.AbstractVariableDeclaration;
5 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
6 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
7 import org.eclipse.jface.resource.ImageDescriptor;
10 * A variable declaration.
11 * @author Matthieu Casanova
13 public class VariableDeclaration extends AbstractVariableDeclaration implements Outlineable {
15 /** The value for variable initialization. */
16 public Expression initialization;
18 private Object parent;
19 private boolean reference;
23 * @param initialization the initialization
24 * @param name the name of the variable
25 * @param sourceStart the start point
27 public VariableDeclaration(Object parent,
29 Expression initialization,
31 super(name, sourceStart, initialization.sourceEnd);
32 this.initialization = initialization;
38 * @param initialization the initialization
39 * @param name the name of the variable
40 * @param sourceStart the start point
42 public VariableDeclaration(Object parent,
46 super(name, sourceStart, sourceEnd);
47 this.initialization = initialization;
51 public void setReference(boolean reference) {
52 this.reference = reference;
57 * @param initialization the initialization
58 * @param name the name of the variable
59 * @param sourceStart the start point
61 public VariableDeclaration(char[] name,
62 Expression initialization,
64 super(name, sourceStart, initialization.sourceEnd);
65 this.initialization = initialization;
68 * Return the variable into String.
71 public String toStringExpression() {
72 final StringBuffer buff;
74 buff = new StringBuffer('&');
76 buff = new StringBuffer();
79 if (initialization != null) {
80 buff.append(" = "); //$NON-NLS-1$
81 buff.append(initialization.toStringExpression());
83 return buff.toString();
86 public Object getParent() {
91 * Get the image of a variable.
92 * @return the image that represents a php variable
94 public ImageDescriptor getImage() {
95 return PHPUiImages.DESC_VAR;