X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java index a6d027a..69163ca 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java @@ -6,29 +6,53 @@ import java.util.List; import java.util.ArrayList; /** + * A variable. + * It could be a simple variable, or contains another variable. * @author Matthieu Casanova */ -public class Variable extends Expression { +public class Variable extends AbstractVariable { /** The name of the variable. */ - public char[] name; + private String name; + /** A variable inside ($$varname). */ + private AbstractVariable variable; - public Variable(final char[] name, final int sourceStart, final int sourceEnd) { + /** + * Create a new simple variable. + * @param name the name + * @param sourceStart the starting position + * @param sourceEnd the ending position + */ + public Variable(final String name, final int sourceStart, final int sourceEnd) { super(sourceStart, sourceEnd); this.name = name; } - /** + /** + * Create a special variable ($$toto for example). + * @param variable the variable contained + * @param sourceStart the starting position + * @param sourceEnd the ending position + */ + public Variable(final AbstractVariable variable, final int sourceStart, final int sourceEnd) { + super(sourceStart, sourceEnd); + this.variable = variable; + } + + /** * Return the expression as String. * @return the expression */ public String toStringExpression() { - return "$"+new String(name); + return "$" + getName(); } public String getName() { - return new String(name); + if (variable == null) { + return name; + } + return variable.toStringExpression(); } /** @@ -44,9 +68,7 @@ public class Variable extends Expression { * @return the variables modified */ public List getModifiedVariable() { - final ArrayList list = new ArrayList(1); - list.add(new VariableUsage(getName(),sourceStart)); - return list; + return new ArrayList(1); } /** @@ -54,6 +76,12 @@ public class Variable extends Expression { * @return the variables used */ public List getUsedVariable() { - return new ArrayList(1); + final ArrayList list = new ArrayList(1); + if (name == null) { + list.add(new VariableUsage(variable.getName(), getSourceStart())); + } else { + list.add(new VariableUsage(name, getSourceStart())); + } + return list; } }