1 package net.sourceforge.phpdt.internal.compiler.ast;
 
   5 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
 
   6 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
 
   8 import org.eclipse.jface.resource.ImageDescriptor;
 
   9 import org.eclipse.jface.text.Position;
 
  12  * @author Matthieu Casanova
 
  14 public final class InclusionStatement extends Statement implements Outlineable {
 
  16   public static final int INCLUDE = 0;
 
  17   public static final int INCLUDE_ONCE = 1;
 
  18   public static final int REQUIRE = 2;
 
  19   public static final int REQUIRE_ONCE = 3;
 
  20   public boolean silent;
 
  21   /** The kind of include. */
 
  22   private final int keyword;
 
  23   private final Expression expression;
 
  25   private final Object parent;
 
  27   private final Position position;
 
  29   public InclusionStatement(final Object parent,
 
  31                             final Expression expression,
 
  32                             final int sourceStart,
 
  33                             final int sourceEnd) {
 
  34     super(sourceStart, sourceEnd);
 
  35     this.keyword = keyword;
 
  36     this.expression = expression;
 
  38     position = new Position(sourceStart, sourceEnd);
 
  41   private String keywordToString() {
 
  44         return "include";       //$NON-NLS-1$
 
  46         return "include_once";  //$NON-NLS-1$
 
  48         return "require";       //$NON-NLS-1$
 
  50         return "require_once";  //$NON-NLS-1$
 
  52     return "unknown keyword";//$NON-NLS-1$
 
  56    * Return the object into String.
 
  57    * @param tab how many tabs (not used here
 
  60   public String toString(final int tab) {
 
  61     final StringBuffer buffer = new StringBuffer(tabString(tab));
 
  62     buffer.append(toString());
 
  63     return buffer.toString();
 
  66   public String toString() {
 
  67     final String keyword = keywordToString();
 
  68     final String expressionString = expression.toStringExpression();
 
  69     final StringBuffer buffer = new StringBuffer(keyword.length() +
 
  70                                                  expressionString.length() + 2);
 
  74     buffer.append(keyword);
 
  76     buffer.append(expressionString);
 
  77     return buffer.toString();
 
  81    * Get the image of a variable.
 
  82    * @return the image that represents a php variable
 
  84   public ImageDescriptor getImage() {
 
  85     return PHPUiImages.DESC_INC;
 
  88   public Object getParent() {
 
  92   public Position getPosition() {
 
  97    * Get the variables from outside (parameters, globals ...)
 
  99    * @param list the list where we will put variables
 
 101   public void getOutsideVariable(final List list) {
 
 102     expression.getOutsideVariable(list);
 
 106    * get the modified variables.
 
 108    * @param list the list where we will put variables
 
 110   public void getModifiedVariable(final List list) {
 
 111     expression.getModifiedVariable(list);
 
 115    * Get the variables used.
 
 117    * @param list the list where we will put variables
 
 119   public void getUsedVariable(final List list) {
 
 120     expression.getUsedVariable(list);