package net.sourceforge.phpdt.internal.compiler.ast; import java.util.List; 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; /** * @author Matthieu Casanova */ public class InclusionStatement extends Statement implements Outlineable { public static final int INCLUDE = 0; public static final int INCLUDE_ONCE = 1; public static final int REQUIRE = 2; public static final int REQUIRE_ONCE = 3; public boolean silent; /** The kind of include. */ public int keyword; public Expression expression; private Object parent; private Position position; public InclusionStatement(final Object parent, final int keyword, final Expression expression, final int sourceStart, final int sourceEnd) { super(sourceStart, sourceEnd); this.keyword = keyword; this.expression = expression; this.parent = parent; position = new Position(sourceStart, sourceEnd); } public String keywordToString() { switch (keyword) { case INCLUDE: return "include"; //$NON-NLS-1$ case INCLUDE_ONCE: return "include_once"; //$NON-NLS-1$ case REQUIRE: return "require"; //$NON-NLS-1$ case REQUIRE_ONCE: return "require_once"; //$NON-NLS-1$ } return "unknown keyword";//$NON-NLS-1$ } /** * Return the object into String. * @param tab how many tabs (not used here * @return a String */ public String toString(final int tab) { final StringBuffer buffer = new StringBuffer(tabString(tab)); buffer.append(toString()); return buffer.toString(); } public String toString() { final StringBuffer buffer = new StringBuffer(); if (silent) { buffer.append('@'); } buffer.append(keywordToString()); buffer.append(" "); buffer.append(expression.toStringExpression()); return buffer.toString(); } /** * Get the image of a variable. * @return the image that represents a php variable */ public ImageDescriptor getImage() { return PHPUiImages.DESC_INC; } public Object getParent() { return parent; } public Position getPosition() { return position; } /** * Get the variables from outside (parameters, globals ...) */ public void getOutsideVariable(final List list) { expression.getOutsideVariable(list); } /** * get the modified variables. */ public void getModifiedVariable(final List list) { expression.getModifiedVariable(list); } /** * Get the variables used. */ public void getUsedVariable(final List list) { expression.getUsedVariable(list); } }