61d4c8b245a3030702698f3b4370358cf53e6655
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / FieldDeclaration.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 import org.eclipse.jface.text.Position;
7
8 import java.util.List;
9 import java.util.ArrayList;
10
11 /**
12  * A Field declaration.
13  * This is a variable declaration for a php class
14  * In fact it's an array of VariableUsage, since a field could contains
15  * several var :
16  * var $toto,$tata;
17  * @author Matthieu Casanova
18  */
19 public class FieldDeclaration extends Statement implements Outlineable {
20
21   /** The variables. */
22   public VariableDeclaration[] vars;
23
24   private Object parent;
25   private Position position;
26   /**
27    * Create a new field.
28    * @param vars the array of variables.
29    * @param sourceStart the starting offset
30    * @param sourceEnd   the ending offset
31    */
32   public FieldDeclaration(final VariableDeclaration[] vars,
33                           final int sourceStart,
34                           final int sourceEnd,
35                           final Object parent) {
36     super(sourceStart, sourceEnd);
37     this.vars = vars;
38     this.parent = parent;
39     position = new Position(sourceStart, sourceEnd);
40   }
41
42   /**
43    * Return the object into String.
44    * @param tab how many tabs (not used here
45    * @return a String
46    */
47   public String toString(final int tab) {
48     final StringBuffer buff = new StringBuffer(tabString(tab));
49     buff.append("var ");//$NON-NLS-1$
50     for (int i = 0; i < vars.length; i++) {
51       if (i != 0) {
52         buff.append(",");//$NON-NLS-1$
53       }
54       buff.append(vars[i].toStringExpression());
55     }
56     return buff.toString();
57   }
58
59   /**
60    * Get the image of a variable.
61    * @return the image that represents a php variable
62    */
63   public ImageDescriptor getImage() {
64       return PHPUiImages.DESC_VAR;
65   }
66
67   public Object getParent() {
68     return parent;
69   }
70
71   public Position getPosition() {
72     return position;
73   }
74
75     /**
76    * Get the variables from outside (parameters, globals ...)
77    * @return the variables from outside
78    */
79   public List getOutsideVariable() {
80     return new ArrayList(1);
81   }
82
83   /**
84    * get the modified variables.
85    * @return the variables from we change value
86    */
87   public List getModifiedVariable() {
88     return new ArrayList(1);
89   }
90
91   /**
92    * Get the variables used.
93    * @return the variables used
94    */
95   public List getUsedVariable() {
96     return new ArrayList(1);
97   }
98 }