package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; /** * @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; public InclusionStatement(Object parent, int keyword, Expression expression, int sourceStart) { super(sourceStart, expression.sourceEnd); this.keyword = keyword; this.expression = expression; this.parent = parent; } 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(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; } }