*** empty log message ***
[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     buffer.append(toString());
55     return buffer.toString();
56   }
57
58   public String toString() {
59     final StringBuffer buffer = new StringBuffer();
60     if (silent) {
61       buffer.append('@');
62     }
63     buffer.append(keywordToString());
64     buffer.append(" ");
65     buffer.append(expression.toStringExpression());
66     return buffer.toString();
67   }
68
69   /**
70    * Get the image of a variable.
71    * @return the image that represents a php variable
72    */
73   public ImageDescriptor getImage() {
74     return PHPUiImages.DESC_INC;
75   }
76
77   public Object getParent() {
78     return parent;
79   }
80 }