package net.sourceforge.phpdt.internal.compiler.ast;
+import java.util.List;
+
/**
+ * An access to a key of an array.
* @author Matthieu Casanova
*/
-public class ArrayDeclarator extends AbstractSuffixExpression {
+public final class ArrayDeclarator extends AbstractVariable {
+
+ /** The name of the array. */
+ private final AbstractVariable prefix;
- public Expression prefix;
- public Expression vars;
+ /** The key. */
+ private final Expression key;
- public ArrayDeclarator(Expression prefix,
- Expression vars,
- int sourceEnd) {
+ /**
+ * 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;
}
/**
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();
}
+
+ /**
+ * Return the name of the variable.
+ * @return the name of the functionName variable
+ */
+ 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.
+ * @param list the list where we will put variables
+ */
+ public void getModifiedVariable(final List list) {
+ prefix.getModifiedVariable(list);
+ if (key != null) {
+ key.getModifiedVariable(list);
+ }
+ }
+
+ /**
+ * Get the variables used.
+ * @param list the list where we will put variables
+ */
+ public void getUsedVariable(final List list) {
+ prefix.getUsedVariable(list);
+ if (key != null) {
+ key.getUsedVariable(list);
+ }
+ }
}