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;
36 public void setReference(boolean reference) {
37 this.reference = reference;
42 * @param initialization the initialization
43 * @param name the name of the variable
44 * @param sourceStart the start point
46 public VariableDeclaration(char[] name,
47 Expression initialization,
49 super(name, sourceStart, initialization.sourceEnd);
50 this.initialization = initialization;
53 * Return the variable into String.
56 public String toStringExpression() {
57 final StringBuffer buff;
59 buff = new StringBuffer('&');
61 buff = new StringBuffer();
64 if (initialization != null) {
65 buff.append(" = "); //$NON-NLS-1$
66 buff.append(initialization.toStringExpression());
68 return buff.toString();
71 public Object getParent() {
76 * Get the image of a variable.
77 * @return the image that represents a php variable
79 public ImageDescriptor getImage() {
80 return PHPUiImages.DESC_VAR;