First try for AST structure. A lot of things to change
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / InclusionStatement.java
1 package net.sourceforge.phpdt.internal.compiler.ast;
2
3 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
4 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
5 import org.eclipse.jface.resource.ImageDescriptor;
6
7 /**
8  * @author Matthieu Casanova
9  */
10 public class InclusionStatement extends Statement implements Outlineable {
11
12   public static final int INCLUDE = 0;
13   public static final int INCLUDE_ONCE = 1;
14   public static final int REQUIRE = 2;
15   public static final int REQUIRE_ONCE = 3;
16   public boolean silent;
17   /** The kind of include. */
18   public int keyword;
19   public Expression expression;
20
21   private Object parent;
22
23   public InclusionStatement(Object parent,
24                             int keyword,
25                             Expression expression,
26                             int sourceStart) {
27     super(sourceStart, expression.sourceEnd);
28     this.keyword = keyword;
29     this.expression = expression;
30     this.parent = parent;
31   }
32
33   public String keywordToString() {
34     switch (keyword) {
35       case INCLUDE:
36         return "include";       //$NON-NLS-1$
37       case INCLUDE_ONCE:
38         return "include_once";  //$NON-NLS-1$
39       case REQUIRE:
40         return "require";       //$NON-NLS-1$
41       case REQUIRE_ONCE:
42         return "require_once";  //$NON-NLS-1$
43     }
44     return "unknown keyword";//$NON-NLS-1$
45   }
46
47   /**
48    * Return the object into String.
49    * @param tab how many tabs (not used here
50    * @return a String
51    */
52   public String toString(int tab) {
53     final StringBuffer buffer = new StringBuffer(tabString(tab));
54     if (silent) {
55       buffer.append('@');
56     }
57     buffer.append(keywordToString());
58     buffer.append(" ");
59     buffer.append(expression.toStringExpression());
60     return buffer.toString();
61   }
62
63   /**
64    * Get the image of a variable.
65    * @return the image that represents a php variable
66    */
67   public ImageDescriptor getImage() {
68     return PHPUiImages.DESC_INC;
69   }
70
71   public Object getParent() {
72     return parent;
73   }
74 }