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 name the name of the variable
39 * @param sourceStart the start point
41 public VariableDeclaration(Object parent,
45 super(name, sourceStart, sourceEnd);
49 public void setReference(boolean reference) {
50 this.reference = reference;
55 * @param initialization the initialization
56 * @param name the name of the variable
57 * @param sourceStart the start point
59 public VariableDeclaration(char[] name,
60 Expression initialization,
62 super(name, sourceStart, initialization.sourceEnd);
63 this.initialization = initialization;
68 * @param name the name of the variable
69 * @param sourceStart the start point
71 public VariableDeclaration(char[] name,
73 super(name, sourceStart, sourceStart + name.length);
77 * Return the variable into String.
80 public String toStringExpression() {
81 final StringBuffer buff;
83 buff = new StringBuffer('&');
85 buff = new StringBuffer();
88 if (initialization != null) {
89 buff.append(" = "); //$NON-NLS-1$
90 buff.append(initialization.toStringExpression());
92 return buff.toString();
95 public Object getParent() {
100 * Get the image of a variable.
101 * @return the image that represents a php variable
103 public ImageDescriptor getImage() {
104 return PHPUiImages.DESC_VAR;