From: kpouer Date: Tue, 26 Aug 2003 08:12:21 +0000 (+0000) Subject: The methods to get variables do not instantiate ArrayList each time, only one is... X-Git-Url: http://secure.phpeclipse.com The methods to get variables do not instantiate ArrayList each time, only one is used now --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java index 0af2440..0f26744 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractCase.java @@ -28,37 +28,28 @@ public abstract class AbstractCase extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getOutsideVariable()); + statements[i].getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getUsedVariable()); + statements[i].getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java index 9eee781..5bdc86e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AbstractPHPComment.java @@ -24,23 +24,20 @@ public abstract class AbstractPHPComment extends AstNode { * Get the variables from outside (parameters, globals ...) * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(); + public void getModifiedVariable(final List list) { } /** * Get the variables used. * @return an empty list */ - public List getUsedVariable() { - return new ArrayList(); + public void getUsedVariable(final List list) { } } 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 8d2930a..e080c20 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 @@ -43,33 +43,27 @@ public class ArrayDeclarator extends AbstractVariable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final List list = prefix.getModifiedVariable(); + public void getModifiedVariable(final List list) { + prefix.getModifiedVariable(list); if (var != null) { - list.addAll(var.getModifiedVariable()); + var.getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final List list = prefix.getUsedVariable(); + public void getUsedVariable(final List list) { + prefix.getUsedVariable(list); if (var != null) { - list.addAll(var.getUsedVariable()); + var.getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java index ecabbc6..247cd34 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java @@ -41,37 +41,29 @@ public class ArrayInitializer extends Expression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < vars.length; i++) { if (vars[i] != null) { - list.addAll(vars[i].getModifiedVariable()); + vars[i].getModifiedVariable(list); } } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < vars.length; i++) { if (vars[i] != null) { - list.addAll(vars[i].getUsedVariable()); + vars[i].getUsedVariable(list); } } - return list; } } 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..4a306e6 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 @@ -54,34 +54,27 @@ public class ArrayVariableDeclaration extends Expression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - 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 */ - 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; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java index 56dddfd..da77815 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/AstNode.java @@ -53,21 +53,18 @@ public abstract class AstNode { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public abstract List getOutsideVariable(); + public abstract void getOutsideVariable(List list); /** * get the modified variables. - * @return the variables modified */ - public abstract List getModifiedVariable(); + public abstract void getModifiedVariable(List list); /** * Get the variables used. - * @return the variables used */ - public abstract List getUsedVariable(); + public abstract void getUsedVariable(List list); /** * This method will analyze the code. diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java index 3455363..46643d1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BinaryExpression.java @@ -28,32 +28,24 @@ public class BinaryExpression extends OperatorExpression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(left.getModifiedVariable()); - list.addAll(right.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + left.getModifiedVariable(list); + right.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(left.getUsedVariable()); - list.addAll(right.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + left.getUsedVariable(list); + right.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java index d2371be..acaf451 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java @@ -56,37 +56,28 @@ public class Block extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getOutsideVariable()); + statements[i].getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getUsedVariable()); + statements[i].getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java index 2c164c4..a1354ef 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/BranchStatement.java @@ -18,34 +18,28 @@ public abstract class BranchStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - if (expression == null) { - return new ArrayList(); + public void getOutsideVariable(final List list) { + if (expression != null) { + expression.getOutsideVariable(list); } - return expression.getOutsideVariable(); } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - if (expression == null) { - return new ArrayList(); + public void getModifiedVariable(final List list) { + if (expression != null) { + expression.getModifiedVariable(list); } - return expression.getModifiedVariable(); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - if (expression == null) { - return new ArrayList(); + public void getUsedVariable(final List list) { + if (expression != null) { + expression.getUsedVariable(list); } - return expression.getUsedVariable(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java index 1428b25..8a623d4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java @@ -39,21 +39,17 @@ public class Case extends AbstractCase { /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final List list = super.getModifiedVariable(); - list.addAll(value.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + super.getModifiedVariable(list); + value.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final List list = super.getUsedVariable(); - list.addAll(value.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + super.getUsedVariable(list); + value.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java index 8291f62..6b434d0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java @@ -43,27 +43,23 @@ public class CastExpression extends Expression { return buff.toString(); } - /** + /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return expression.getModifiedVariable(); + public void getModifiedVariable(final List list) { + expression.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return expression.getUsedVariable(); + public void getUsedVariable(final List list) { + expression.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java index 384d192..27f3f73 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassAccess.java @@ -71,27 +71,21 @@ public class ClassAccess extends AbstractVariable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final List list = prefix.getUsedVariable(); - list.addAll(suffix.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + prefix.getUsedVariable(list); + suffix.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java index af9ed52..56a9d7f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java @@ -189,25 +189,19 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java index 121a158..fd36a8a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConditionalExpression.java @@ -32,33 +32,25 @@ public class ConditionalExpression extends OperatorExpression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getModifiedVariable()); - list.addAll(valueIfTrue.getModifiedVariable()); - list.addAll(valueIfFalse.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + condition.getModifiedVariable(list); + valueIfTrue.getModifiedVariable(list); + valueIfFalse.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getUsedVariable()); - list.addAll(valueIfTrue.getUsedVariable()); - list.addAll(valueIfFalse.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + condition.getUsedVariable(list); + valueIfTrue.getUsedVariable(list); + valueIfFalse.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java index bd1f4a1..04994c1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ConstantIdentifier.java @@ -32,27 +32,21 @@ public class ConstantIdentifier extends Expression { return name; } - /** + /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java index 68f96df..0457816 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Define.java @@ -64,27 +64,20 @@ public class Define extends Statement implements Outlineable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(1); + public void getOutsideVariable(final List list) { list.add(new VariableUsage(defineName.toStringExpression(),sourceStart));//todo: someday : evaluate the defineName - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java index f3ee853..9c0689a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/DoStatement.java @@ -44,34 +44,25 @@ public class DoStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getOutsideVariable()); // todo: check if unuseful - list.addAll(action.getOutsideVariable()); - return list; + public void getOutsideVariable(final List list) { + condition.getOutsideVariable(list); // todo: check if unuseful + action.getOutsideVariable(list); } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getModifiedVariable()); - list.addAll(action.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + condition.getModifiedVariable(list); + action.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getUsedVariable()); - list.addAll(action.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + condition.getUsedVariable(list); + action.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java index 0122b26..84e1819 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java @@ -43,37 +43,28 @@ public class EchoStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < expressions.length; i++) { - list.addAll(expressions[i].getOutsideVariable()); + expressions[i].getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < expressions.length; i++) { - list.addAll(expressions[i].getModifiedVariable()); + expressions[i].getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < expressions.length; i++) { - list.addAll(expressions[i].getUsedVariable()); + expressions[i].getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java index 302d650..367abc3 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Else.java @@ -58,37 +58,28 @@ public class Else extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getOutsideVariable()); + statements[i].getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from outside */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables from outside */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getUsedVariable()); + statements[i].getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java index 3602231..dff3ecd 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java @@ -42,39 +42,30 @@ public class ElseIf extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } - list.addAll(condition.getModifiedVariable()); - return list; + condition.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getUsedVariable()); + statements[i].getUsedVariable(list); } - list.addAll(condition.getUsedVariable()); - return list; + condition.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java index 1585fc4..2964394 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java @@ -19,25 +19,19 @@ public class EmptyStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return an empty list */ - public List getUsedVariable() { - return new ArrayList(); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java index 61d4c8b..b41df20 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java @@ -23,6 +23,7 @@ public class FieldDeclaration extends Statement implements Outlineable { private Object parent; private Position position; + /** * Create a new field. * @param vars the array of variables. @@ -61,7 +62,7 @@ public class FieldDeclaration extends Statement implements Outlineable { * @return the image that represents a php variable */ public ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; + return PHPUiImages.DESC_VAR; } public Object getParent() { @@ -72,27 +73,21 @@ public class FieldDeclaration extends Statement implements Outlineable { return position; } - /** + /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java index 689a737..54d0292 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForStatement.java @@ -79,76 +79,67 @@ public class ForStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { if (condition != null) { - list.addAll(condition.getOutsideVariable()); + condition.getOutsideVariable(list); } if (action != null) { - list.addAll(action.getOutsideVariable()); + action.getOutsideVariable(list); } if (initializations != null) { for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getOutsideVariable()); + initializations[i].getOutsideVariable(list); } } if (increments != null) { for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getOutsideVariable()); + increments[i].getOutsideVariable(list); } } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { if (condition != null) { - list.addAll(condition.getModifiedVariable()); + condition.getModifiedVariable(list); } if (action != null) { - list.addAll(action.getModifiedVariable()); + action.getModifiedVariable(list); } if (initializations != null) { for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getModifiedVariable()); + initializations[i].getModifiedVariable(list); } } if (increments != null) { for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getModifiedVariable()); + increments[i].getModifiedVariable(list); } } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { if (condition != null) { - list.addAll(condition.getUsedVariable()); + condition.getUsedVariable(list); } if (action != null) { - list.addAll(action.getUsedVariable()); + action.getUsedVariable(list); } if (initializations != null) { for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getUsedVariable()); + initializations[i].getUsedVariable(list); } } if (increments != null) { for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getUsedVariable()); + increments[i].getUsedVariable(list); } } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java index 827c2aa..4f05ab4 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ForeachStatement.java @@ -42,36 +42,27 @@ public class ForeachStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); - list.addAll(expression.getOutsideVariable()); - list.addAll(variable.getOutsideVariable()); - list.addAll(statement.getOutsideVariable()); - return list; + public void getOutsideVariable(final List list) { + expression.getOutsideVariable(list); + variable.getOutsideVariable(list); + statement.getOutsideVariable(list); } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(expression.getModifiedVariable()); - list.addAll(variable.getModifiedVariable()); - list.addAll(statement.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + expression.getModifiedVariable(list); + variable.getUsedVariable(list); + statement.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(expression.getUsedVariable()); - list.addAll(statement.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + expression.getUsedVariable(list); + statement.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java index 6e270c7..1d1e4c8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java @@ -45,38 +45,30 @@ public class FunctionCall extends AbstractSuffixExpression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - if (args == null) { - return new ArrayList(1); - } - final ArrayList list = new ArrayList(); - for (int i = 0; i < args.length; i++) { - list.addAll(args[i].getModifiedVariable()); + public void getModifiedVariable(final List list) { + if (args != null) { + for (int i = 0; i < args.length; i++) { + args[i].getModifiedVariable(list); + } } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final List list = functionName.getUsedVariable(); + public void getUsedVariable(final List list) { + functionName.getUsedVariable(list); if (args != null) { for (int i = 0; i < args.length; i++) { - list.addAll(args[i].getUsedVariable()); + args[i].getUsedVariable(list); } } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java index bb09275..57c483e 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java @@ -69,30 +69,23 @@ public class GlobalStatement extends Statement implements Outlineable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(variables.length); + public void getOutsideVariable(final List list) { for (int i = 0; i < variables.length; i++) { - list.addAll(variables[i].getUsedVariable()); + variables[i].getUsedVariable(list); } - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java index 496ca72..2d40de1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLBlock.java @@ -32,25 +32,19 @@ public class HTMLBlock extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return an empty list */ - public List getUsedVariable() { - return new ArrayList(); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLCode.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLCode.java index 7c324b8..7e9d327 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLCode.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/HTMLCode.java @@ -1,7 +1,6 @@ package net.sourceforge.phpdt.internal.compiler.ast; import java.util.List; -import java.util.ArrayList; /** @@ -48,23 +47,20 @@ public class HTMLCode extends AstNode { * Get the variables from outside (parameters, globals ...) * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(); + public void getModifiedVariable(final List list) { } /** * Get the variables used. * @return an empty list */ - public List getUsedVariable() { - return new ArrayList(); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java index cb6c88b..899f2a2 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java @@ -65,58 +65,49 @@ public class IfStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getOutsideVariable()); // todo: check if unuseful + public void getOutsideVariable(final List list) { + condition.getOutsideVariable(list); // todo: check if unuseful if (statement != null) { - list.addAll(statement.getOutsideVariable()); + statement.getOutsideVariable(list); } for (int i = 0; i < elseifs.length; i++) { - list.addAll(elseifs[i].getOutsideVariable()); + elseifs[i].getOutsideVariable(list); } if (els != null) { - list.addAll(els.getOutsideVariable()); + els.getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getModifiedVariable()); + public void getModifiedVariable(final List list) { + condition.getModifiedVariable(list); if (statement != null) { - list.addAll(statement.getModifiedVariable()); + statement.getModifiedVariable(list); } for (int i = 0; i < elseifs.length; i++) { - list.addAll(elseifs[i].getModifiedVariable()); + elseifs[i].getModifiedVariable(list); } if (els != null) { - list.addAll(els.getModifiedVariable()); + els.getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getUsedVariable()); + public void getUsedVariable(final List list) { + condition.getUsedVariable(list); if (statement != null) { - list.addAll(statement.getUsedVariable()); + statement.getUsedVariable(list); } for (int i = 0; i < elseifs.length; i++) { - list.addAll(elseifs[i].getUsedVariable()); + elseifs[i].getUsedVariable(list); } if (els != null) { - list.addAll(els.getUsedVariable()); + els.getUsedVariable(list); } - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java index 7cba496..268f234 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java @@ -92,25 +92,22 @@ public class InclusionStatement extends Statement implements Outlineable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return expression.getOutsideVariable(); + public void getOutsideVariable(final List list) { + expression.getOutsideVariable(list); } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return expression.getModifiedVariable(); + public void getModifiedVariable(final List list) { + expression.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return expression.getUsedVariable(); + public void getUsedVariable(final List list) { + expression.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java index c9730ea..d0f38f0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java @@ -40,25 +40,22 @@ public class LabeledStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return statement.getOutsideVariable(); + public void getOutsideVariable(final List list) { + statement.getOutsideVariable(list); } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return statement.getModifiedVariable(); + public void getModifiedVariable(final List list) { + statement.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return statement.getUsedVariable(); + public void getUsedVariable(final List list) { + statement.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java index a167d1a..ad5c35c 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ListExpression.java @@ -50,39 +50,32 @@ public class ListExpression extends Expression { return buff.toString(); } - /** + /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < vars.length; i++) { if (vars[i] != null) { - list.addAll(vars[i].getUsedVariable()); + vars[i].getUsedVariable(list); } } if (expression != null) { - list.addAll(expression.getModifiedVariable()); + expression.getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - if (expression == null) { - return new ArrayList(1); + public void getUsedVariable(final List list) { + if (expression != null) { + expression.getUsedVariable(list); } - return expression.getUsedVariable(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Literal.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Literal.java index ae58b8a..3f6e8aa 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Literal.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Literal.java @@ -20,25 +20,19 @@ public abstract class Literal extends Expression { /** * Get the variables from outside (parameters, globals ...) - * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return an empty list */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java index b61470f..6934c07 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java @@ -156,34 +156,27 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } /** no outside variables. */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } /** * Get global variables (not parameters). - * @return the variables from outside */ - public List getGlobalVariable() { - final ArrayList list = new ArrayList(); - + public void getGlobalVariable(final List list) { if (statements != null) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getOutsideVariable()); + statements[i].getOutsideVariable(list); } } - return list; } - private List getParameters(final List list) { + private void getParameters(final List list) { if (arguments != null) { final Enumeration vars = arguments.elements(); while (vars.hasMoreElements()) { @@ -191,35 +184,28 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild list.add(new VariableUsage(variable.name(), variable.sourceStart)); } } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - private List getAssignedVariableInCode() { - final ArrayList list = new ArrayList(); + private void getAssignedVariableInCode(final List list) { if (statements != null) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getModifiedVariable()); + statements[i].getModifiedVariable(list); } } - return list; } /** * Get the variables used. - * @return the variables used */ - private List getUsedVariableInCode() { - final ArrayList list = new ArrayList(); + private void getUsedVariableInCode(final List list) { if (statements != null) { for (int i = 0; i < statements.length; i++) { - list.addAll(statements[i].getUsedVariable()); + statements[i].getUsedVariable(list); } } - return list; } private boolean isVariableDeclaredBefore(final List list, final VariableUsage var) { @@ -243,22 +229,26 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } } - final List globalsVars = getGlobalVariable(); - final List modifiedVars = getAssignedVariableInCode(); - final List parameters = getParameters(new ArrayList()); + final List globalsVars = new ArrayList(); + getGlobalVariable(globalsVars); + final List modifiedVars = new ArrayList(); + getAssignedVariableInCode(modifiedVars); + final List parameters = new ArrayList(); + getParameters(parameters); final List declaredVars = new ArrayList(globalsVars.size() + modifiedVars.size()); declaredVars.addAll(globalsVars); declaredVars.addAll(modifiedVars); declaredVars.addAll(parameters); - final List usedVars = getUsedVariableInCode(); - final List readOrWriteVars = new ArrayList(modifiedVars.size()+usedVars.size()); + final List usedVars = new ArrayList(); + getUsedVariableInCode(usedVars); + final List readOrWriteVars = new ArrayList(modifiedVars.size() + usedVars.size()); readOrWriteVars.addAll(modifiedVars); readOrWriteVars.addAll(usedVars); //look for used variables that were not declared before - findUnusedParameters(readOrWriteVars,parameters); + findUnusedParameters(readOrWriteVars, parameters); findUnknownUsedVars(usedVars, declaredVars); } @@ -269,14 +259,15 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild */ private void findUnusedParameters(final List vars, final List parameters) { for (int i = 0; i < parameters.size(); i++) { - final VariableUsage param = ((VariableUsage)parameters.get(i)); - if (!isVariableInList(param.getName(),vars)) { + final VariableUsage param = ((VariableUsage) parameters.get(i)); + if (!isVariableInList(param.getName(), vars)) { try { - PHPParserSuperclass.setMarker("warning, the parameter "+param.getName() +" seems to be never used in your method", - param.getStartOffset(), - param.getStartOffset() + param.getName().length(), - PHPParserSuperclass.WARNING, - ""); + PHPParserSuperclass.setMarker( + "warning, the parameter " + param.getName() + " seems to be never used in your method", + param.getStartOffset(), + param.getStartOffset() + param.getName().length(), + PHPParserSuperclass.WARNING, + ""); } catch (CoreException e) { PHPeclipsePlugin.log(e); } @@ -304,11 +295,12 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild if (variableUsage.getName().equals("this")) continue; // this is a special variable if (!isVariableDeclaredBefore(declaredVars, variableUsage)) { try { - PHPParserSuperclass.setMarker("warning, usage of a variable that seems to be unassigned yet : " + variableUsage.getName(), - variableUsage.getStartOffset(), - variableUsage.getStartOffset() + variableUsage.getName().length(), - PHPParserSuperclass.WARNING, - ""); + PHPParserSuperclass.setMarker( + "warning, usage of a variable that seems to be unassigned yet : " + variableUsage.getName(), + variableUsage.getStartOffset(), + variableUsage.getStartOffset() + variableUsage.getName().length(), + PHPParserSuperclass.WARNING, + ""); } catch (CoreException e) { PHPeclipsePlugin.log(e); } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java index 674f9d1..dab65cb 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPEchoBlock.java @@ -48,25 +48,20 @@ public class PHPEchoBlock extends AstNode { /** * Get the variables from outside (parameters, globals ...) - * @return an empty list */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return an empty list */ - public List getModifiedVariable() { - return new ArrayList(); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the used variables are the used variables from the expression */ - public List getUsedVariable() { - return expr.getUsedVariable(); + public void getUsedVariable(final List list) { + expr.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java index 86d5d7e..772dee0 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PrintExpression.java @@ -25,25 +25,22 @@ public class PrintExpression extends Expression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return expression.getOutsideVariable(); + public void getOutsideVariable(final List list) { + expression.getOutsideVariable(list); } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return expression.getModifiedVariable(); + public void getModifiedVariable(final List list) { + expression.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return expression.getUsedVariable(); + public void getUsedVariable(final List list) { + expression.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java index 13822d7..61585ca 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java @@ -26,31 +26,25 @@ public class ReturnStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - if (expression == null) { - return new ArrayList(); + public void getModifiedVariable(final List list) { + if (expression != null) { + expression.getModifiedVariable(list); } - return expression.getModifiedVariable(); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - if (expression == null) { - return new ArrayList(); + public void getUsedVariable(final List list) { + if (expression != null) { + expression.getUsedVariable(list); } - return expression.getUsedVariable(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java index ac8bd2d..6643729 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/StaticStatement.java @@ -34,29 +34,22 @@ public class StaticStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < variables.length; i++) { - list.addAll(variables[i].getModifiedVariable()); + variables[i].getModifiedVariable(list); } - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return new ArrayList(1); + public void getUsedVariable(final List list) { } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java index ad8f484..b1a0cda 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/SwitchStatement.java @@ -39,39 +39,30 @@ public class SwitchStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); + public void getOutsideVariable(final List list) { for (int i = 0; i < cases.length; i++) { - list.addAll(cases[i].getOutsideVariable()); + cases[i].getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); + public void getModifiedVariable(final List list) { for (int i = 0; i < cases.length; i++) { - list.addAll(cases[i].getModifiedVariable()); + cases[i].getModifiedVariable(list); } - list.addAll(variable.getModifiedVariable()); - return list; + variable.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); + public void getUsedVariable(final List list) { for (int i = 0; i < cases.length; i++) { - list.addAll(cases[i].getUsedVariable()); + cases[i].getUsedVariable(list); } - list.addAll(variable.getUsedVariable()); - return list; + variable.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java index 5e50628..b2b434a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/UnaryExpression.java @@ -17,25 +17,21 @@ public abstract class UnaryExpression extends OperatorExpression { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - return expression.getModifiedVariable(); + public void getModifiedVariable(final List list) { + expression.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - return expression.getUsedVariable(); + public void getUsedVariable(final List list) { + expression.getUsedVariable(list); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java index 5fb5cd3..17879e5 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java @@ -103,32 +103,24 @@ public class VarAssignation extends Expression { } - /** + /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(variableName.getUsedVariable()); - list.addAll(initializer.getModifiedVariable()); - return list; + public void getModifiedVariable(final List list) { + variableName.getUsedVariable(list); + initializer.getModifiedVariable(list); } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(initializer.getUsedVariable()); - return list; + public void getUsedVariable(final List list) { + initializer.getUsedVariable(list); } } 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 add462f..cba56c4 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 @@ -103,25 +103,20 @@ public class Variable extends AbstractVariable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables modified */ - public List getModifiedVariable() { - return new ArrayList(1); + public void getModifiedVariable(final List list) { } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { + public void getUsedVariable(final List list) { final String varName; if (name != null) { varName = name; @@ -130,11 +125,8 @@ public class Variable extends AbstractVariable { } else { varName = expression.toStringExpression();//todo : do a better thing like evaluate this ?? } - if (arrayContains(SPECIAL_VARS, name)) { - return new ArrayList(1); + if (!arrayContains(SPECIAL_VARS, name)) { + list.add(new VariableUsage(varName, sourceStart)); } - final ArrayList list = new ArrayList(1); - list.add(new VariableUsage(varName, sourceStart)); - return list; } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java index 8d08f65..463128a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java @@ -191,32 +191,26 @@ public class VariableDeclaration extends Expression implements Outlineable { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - return new ArrayList(1); + public void getOutsideVariable(final List list) { } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final List list = variable.getUsedVariable(); + public void getModifiedVariable(final List list) { + variable.getUsedVariable(list); if (initialization != null) { - list.addAll(initialization.getModifiedVariable()); + initialization.getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { + public void getUsedVariable(final List list) { if (initialization != null) { - return initialization.getUsedVariable(); + initialization.getUsedVariable(list); } - return new ArrayList(1); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java index 24d668b..80ff26a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/WhileStatement.java @@ -49,40 +49,31 @@ public class WhileStatement extends Statement { /** * Get the variables from outside (parameters, globals ...) - * @return the variables from outside */ - public List getOutsideVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getOutsideVariable()); // todo: check if unuseful + public void getOutsideVariable(final List list) { + condition.getOutsideVariable(list); // todo: check if unuseful if (action != null) { - list.addAll(action.getOutsideVariable()); + action.getOutsideVariable(list); } - return list; } /** * get the modified variables. - * @return the variables from we change value */ - public List getModifiedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getModifiedVariable()); + public void getModifiedVariable(final List list) { + condition.getModifiedVariable(list); if (action != null) { - list.addAll(action.getModifiedVariable()); + action.getModifiedVariable(list); } - return list; } /** * Get the variables used. - * @return the variables used */ - public List getUsedVariable() { - final ArrayList list = new ArrayList(); - list.addAll(condition.getUsedVariable()); + public void getUsedVariable(final List list) { + condition.getUsedVariable(list); if (action != null) { - list.addAll(action.getUsedVariable()); + action.getUsedVariable(list); } - return list; } }