From c278e42052062ce9ce8e49addfee691bc4bd44c7 Mon Sep 17 00:00:00 2001 From: kpouer Date: Thu, 14 Aug 2003 00:29:01 +0000 Subject: [PATCH] some bugfixes --- .../internal/compiler/ast/ArrayInitializer.java | 15 +++-- .../phpdt/internal/compiler/ast/ForStatement.java | 69 ++++++++++++++----- 2 files changed, 61 insertions(+), 23 deletions(-) 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 42ab9e4..ecabbc6 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 @@ -28,17 +28,18 @@ public class ArrayInitializer extends Expression { public String toStringExpression() { final StringBuffer buff = new StringBuffer("array("); for (int i = 0; i < vars.length; i++) { - final ArrayVariableDeclaration var = vars[i]; if (i != 0) { buff.append(","); } - buff.append(var.toStringExpression()); + if (vars[i] != null) { + buff.append(vars[i].toStringExpression()); + } } buff.append(")"); return buff.toString(); } - /** + /** * Get the variables from outside (parameters, globals ...) * @return the variables from outside */ @@ -53,7 +54,9 @@ public class ArrayInitializer extends Expression { public List getModifiedVariable() { final ArrayList list = new ArrayList(); for (int i = 0; i < vars.length; i++) { - list.addAll(vars[i].getModifiedVariable()); + if (vars[i] != null) { + list.addAll(vars[i].getModifiedVariable()); + } } return list; } @@ -65,7 +68,9 @@ public class ArrayInitializer extends Expression { public List getUsedVariable() { final ArrayList list = new ArrayList(); for (int i = 0; i < vars.length; i++) { - list.addAll(vars[i].getUsedVariable()); + if (vars[i] != null) { + list.addAll(vars[i].getUsedVariable()); + } } return 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 212d451..689a737 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 @@ -20,6 +20,15 @@ public class ForStatement extends Statement { public Statement action; + /** + * a for statement + * @param initializations the initializations expressions + * @param condition the condition when the for get out + * @param increments the increments statements + * @param action the action (a statement, a block ...) + * @param sourceStart the beginning sources + * @param sourceEnd the ending sources + */ public ForStatement(final Expression[] initializations, final Expression condition, final Expression[] increments, @@ -74,13 +83,21 @@ public class ForStatement extends Statement { */ public List getOutsideVariable() { final ArrayList list = new ArrayList(); - list.addAll(condition.getOutsideVariable()); - list.addAll(action.getOutsideVariable()); - for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getOutsideVariable()); + if (condition != null) { + list.addAll(condition.getOutsideVariable()); + } + if (action != null) { + list.addAll(action.getOutsideVariable()); } - for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getOutsideVariable()); + if (initializations != null) { + for (int i = 0; i < initializations.length; i++) { + list.addAll(initializations[i].getOutsideVariable()); + } + } + if (increments != null) { + for (int i = 0; i < increments.length; i++) { + list.addAll(increments[i].getOutsideVariable()); + } } return list; } @@ -91,13 +108,21 @@ public class ForStatement extends Statement { */ public List getModifiedVariable() { final ArrayList list = new ArrayList(); - list.addAll(condition.getModifiedVariable()); - list.addAll(action.getModifiedVariable()); - for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getModifiedVariable()); + if (condition != null) { + list.addAll(condition.getModifiedVariable()); } - for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getModifiedVariable()); + if (action != null) { + list.addAll(action.getModifiedVariable()); + } + if (initializations != null) { + for (int i = 0; i < initializations.length; i++) { + list.addAll(initializations[i].getModifiedVariable()); + } + } + if (increments != null) { + for (int i = 0; i < increments.length; i++) { + list.addAll(increments[i].getModifiedVariable()); + } } return list; } @@ -108,13 +133,21 @@ public class ForStatement extends Statement { */ public List getUsedVariable() { final ArrayList list = new ArrayList(); - list.addAll(condition.getUsedVariable()); - list.addAll(action.getUsedVariable()); - for (int i = 0; i < initializations.length; i++) { - list.addAll(initializations[i].getUsedVariable()); + if (condition != null) { + list.addAll(condition.getUsedVariable()); + } + if (action != null) { + list.addAll(action.getUsedVariable()); } - for (int i = 0; i < increments.length; i++) { - list.addAll(increments[i].getUsedVariable()); + if (initializations != null) { + for (int i = 0; i < initializations.length; i++) { + list.addAll(initializations[i].getUsedVariable()); + } + } + if (increments != null) { + for (int i = 0; i < increments.length; i++) { + list.addAll(increments[i].getUsedVariable()); + } } return list; } -- 1.7.1