X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java index 4322f61..215c9ea 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayVariableDeclaration.java @@ -1,24 +1,25 @@ package net.sourceforge.phpdt.internal.compiler.ast; import java.util.List; -import java.util.ArrayList; /** * a variable declaration in an array(). * it could take Expression as key. + * * @author Matthieu Casanova */ -public class ArrayVariableDeclaration extends Expression { +public final class ArrayVariableDeclaration extends Expression { /** the array key. */ - public Expression key; + private final Expression key; /** the array value. */ - public Expression value; + private Expression value; /** * Create a new array variable declaration. - * @param key the key + * + * @param key the key * @param value the value */ public ArrayVariableDeclaration(final Expression key, final Expression value) { @@ -29,7 +30,8 @@ public class ArrayVariableDeclaration extends Expression { /** * Create a new array variable declaration. - * @param key the key + * + * @param key the key * @param sourceEnd the end position */ public ArrayVariableDeclaration(final Expression key, final int sourceEnd) { @@ -39,49 +41,53 @@ public class ArrayVariableDeclaration extends Expression { /** * Return the expression as String. + * * @return the expression */ public String toStringExpression() { - final StringBuffer buff = new StringBuffer(); - buff.append(key.toStringExpression()); - if (value != null) { + if (value == null) { + return key.toStringExpression(); + } else { + final String keyString = key.toStringExpression(); + final String valueString = value.toStringExpression(); + final StringBuffer buff = new StringBuffer(keyString.length() + valueString.length() + 3); + buff.append(keyString); buff.append(" => "); - buff.append(value.toStringExpression()); + buff.append(valueString); + return buff.toString(); } - return buff.toString(); } /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside + * + * @param list the list where we will put variables */ - public List getOutsideVariable() { - return new ArrayList(); + 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(key.getModifiedVariable()); + public void getModifiedVariable(final List list) { + key.getModifiedVariable(list); if (value != null) { - list.addAll(value.getModifiedVariable()); + value.getModifiedVariable(list); } - return 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(); + public void getUsedVariable(final List list) { + key.getUsedVariable(list); if (value != null) { - list.addAll(value.getUsedVariable()); + value.getUsedVariable(list); } - return list; } }