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 final 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. */ private final int keyword; private final Expression expression; private final Object parent; private final 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); } private 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 String keyword = keywordToString(); final String expressionString = expression.toStringExpression(); final StringBuffer buffer = new StringBuffer(keyword.length() + expressionString.length() + 2); if (silent) { buffer.append('@'); } buffer.append(keyword); buffer.append(' '); buffer.append(expressionString); 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 ...) * * @param list the list where we will put variables */ public void getOutsideVariable(final List list) { expression.getOutsideVariable(list); } /** * get the modified variables. * * @param list the list where we will put variables */ public void getModifiedVariable(final List list) { expression.getModifiedVariable(list); } /** * Get the variables used. * * @param list the list where we will put variables */ public void getUsedVariable(final List list) { expression.getUsedVariable(list); } }