X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java index 3f3e474..53e5b62 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java @@ -1,22 +1,31 @@ package net.sourceforge.phpdt.internal.compiler.ast; import java.util.List; -import java.util.ArrayList; /** + * An access to a key of an array. * @author Matthieu Casanova */ -public class ArrayDeclarator extends AbstractSuffixExpression { +public final class ArrayDeclarator extends AbstractVariable { - public Expression prefix; - public Expression vars; + /** The name of the array. */ + private final AbstractVariable prefix; - public ArrayDeclarator(final Expression prefix, - final Expression vars, + /** The key. */ + private final Expression key; + + /** + * Create an ArrayDeclarator. + * @param prefix the prefix, it could be a variable. + * @param key the key + * @param sourceEnd the end of the expression + */ + public ArrayDeclarator(final AbstractVariable prefix, + final Expression key, final int sourceEnd) { super(prefix.sourceStart, sourceEnd); this.prefix = prefix; - this.vars = vars; + this.key = key; } /** @@ -26,40 +35,46 @@ public class ArrayDeclarator extends AbstractSuffixExpression { public String toStringExpression() { final StringBuffer buff = new StringBuffer(prefix.toStringExpression()); buff.append('['); - if (vars != null) { - buff.append(vars.toStringExpression()); + if (key != null) { + buff.append(key.toStringExpression()); } buff.append(']'); return buff.toString(); } - /** - * Get the variables from outside (parameters, globals ...) - * @return the variables from outside + /** + * Return the name of the variable. + * @return the name of the functionName variable */ - public List getOutsideVariable() { - return new ArrayList(); + public String getName() { + return prefix.getName(); } /** + * Get the variables from outside (parameters, globals ...) + * @param list the list where we will put variables + */ + public void getOutsideVariable(final List list) {} + + /** * get the modified variables. - * @return the variables from we change value + * @param list the list where we will put variables */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(prefix.getModifiedVariable()); - list.addAll(vars.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + prefix.getModifiedVariable(list); + if (key != null) { + key.getModifiedVariable(list); + } } /** * Get the variables used. - * @return the variables used + * @param list the list where we will put variables */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(prefix.getUsedVariable()); - list.addAll(vars.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + prefix.getUsedVariable(list); + if (key != null) { + key.getUsedVariable(list); + } } }