1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
4 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
5 import org.eclipse.jface.resource.ImageDescriptor;
8 * A variable declaration.
9 * @author Matthieu Casanova
11 public class VariableDeclaration extends AbstractVariableDeclaration implements Outlineable {
13 /** The value for variable initialization. */
14 public Expression initialization;
16 private Object parent;
17 private boolean reference;
21 * @param initialization the initialization
22 * @param name the name of the variable
23 * @param sourceStart the start point
25 public VariableDeclaration(Object parent,
27 Expression initialization,
29 super(name, sourceStart, initialization.sourceEnd);
30 this.initialization = initialization;
36 * @param name the name of the variable
37 * @param sourceStart the start point
39 public VariableDeclaration(Object parent,
43 super(name, sourceStart, sourceEnd);
47 public void setReference(boolean reference) {
48 this.reference = reference;
53 * @param initialization the initialization
54 * @param name the name of the variable
55 * @param sourceStart the start point
57 public VariableDeclaration(char[] name,
58 Expression initialization,
60 super(name, sourceStart, initialization.sourceEnd);
61 this.initialization = initialization;
66 * @param name the name of the variable
67 * @param sourceStart the start point
69 public VariableDeclaration(char[] name,
71 super(name, sourceStart, sourceStart + name.length);
75 * Return the variable into String.
78 public String toStringExpression() {
79 final StringBuffer buff;
81 buff = new StringBuffer("&$"); //$NON-NLS-1$
83 buff = new StringBuffer("$");//$NON-NLS-1$
86 if (initialization != null) {
87 buff.append(" = "); //$NON-NLS-1$
88 buff.append(initialization.toStringExpression());
90 return buff.toString();
93 public Object getParent() {
98 * Get the image of a variable.
99 * @return the image that represents a php variable
101 public ImageDescriptor getImage() {
102 return PHPUiImages.DESC_VAR;