X-Git-Url: http://secure.phpeclipse.com 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 ad05eb7..7351341 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 @@ -1,27 +1,32 @@ package net.sourceforge.phpdt.internal.compiler.ast; -import org.eclipse.jface.text.Position; -import org.eclipse.jface.resource.ImageDescriptor; +import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; + +import java.util.List; /** * a Define. * define(expression,expression) + * * @author Matthieu Casanova */ -public class Define extends Statement implements Outlineable { +public final class Define extends Statement implements Outlineable { - public Expression defineName,defineValue; + private final Expression defineName; + private final Expression defineValue; - private Object parent; - private Position position; + private final Object parent; + private final Position position; - public Define(Object parent, - Expression defineName, - Expression defineValue, - int sourceStart, - int sourceEnd) { + public Define(final Object parent, + final Expression defineName, + final Expression defineValue, + final int sourceStart, + final int sourceEnd) { super(sourceStart, sourceEnd); this.parent = parent; this.defineName = defineName; @@ -29,19 +34,26 @@ public class Define extends Statement implements Outlineable { position = new Position(sourceStart, sourceEnd); } - public String toString(int tab) { - final StringBuffer buff = new StringBuffer(tabString(tab)); + public String toString(final int tab) { + final String nameString = defineName.toStringExpression(); + final String valueString = defineValue.toStringExpression(); + final StringBuffer buff = new StringBuffer(tab + 10 + nameString.length() + valueString.length()); + buff.append(tabString(tab)); buff.append("define("); - buff.append(defineName.toStringExpression()); - buff.append(defineValue.toStringExpression()); + buff.append(nameString); + buff.append(", "); + buff.append(valueString); buff.append(")"); return buff.toString(); } public String toString() { - final StringBuffer buff = new StringBuffer(defineName.toStringExpression()); + final String nameString = defineName.toStringExpression(); + final String valueString = defineValue.toStringExpression(); + final StringBuffer buff = new StringBuffer(nameString.length() + valueString.length() + 3); + buff.append(nameString); buff.append(" = "); - buff.append(defineValue.toStringExpression()); + buff.append(valueString); return buff.toString(); } @@ -56,4 +68,27 @@ public class Define extends Statement implements Outlineable { public Position getPosition() { return position; } + + /** + * Get the variables from outside (parameters, globals ...) + * + * @param list the list where we will put variables + */ + public void getOutsideVariable(final List list) { + list.add(new VariableUsage(defineName.toStringExpression(), sourceStart));//todo: someday : evaluate the defineName + } + + /** + * get the modified variables. + * + * @param list the list where we will put variables + */ + public void getModifiedVariable(final List list) {} + + /** + * Get the variables used. + * + * @param list the list where we will put variables + */ + public void getUsedVariable(final List list) {} }