Changes:
[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 java.util.List;
4
5 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
6 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
7
8 import org.eclipse.jface.resource.ImageDescriptor;
9 import org.eclipse.jface.text.Position;
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   /**
28    * Create a new field.
29    * @param vars the array of variables.
30    * @param sourceStart the starting offset
31    * @param sourceEnd   the ending offset
32    */
33   public FieldDeclaration(final VariableDeclaration[] vars,
34                           final int sourceStart,
35                           final int sourceEnd,
36                           final Object parent) {
37     super(sourceStart, sourceEnd);
38     this.vars = vars;
39     this.parent = parent;
40     position = new Position(sourceStart, sourceEnd);
41   }
42
43   /**
44    * Return the object into String.
45    * @param tab how many tabs (not used here
46    * @return a String
47    */
48   public String toString(final int tab) {
49     final StringBuffer buff = new StringBuffer(tabString(tab));
50     buff.append("var ");//$NON-NLS-1$
51     for (int i = 0; i < vars.length; i++) {
52       if (i != 0) {
53         buff.append(",");//$NON-NLS-1$
54       }
55       buff.append(vars[i].toStringExpression());
56     }
57     return buff.toString();
58   }
59
60   /**
61    * Get the image of a variable.
62    * @return the image that represents a php variable
63    */
64   public ImageDescriptor getImage() {
65     return PHPUiImages.DESC_VAR;
66   }
67
68   public Object getParent() {
69     return parent;
70   }
71
72   public Position getPosition() {
73     return position;
74   }
75
76   /**
77    * Get the variables from outside (parameters, globals ...)
78    */
79   public void getOutsideVariable(final List list) {
80   }
81
82   /**
83    * get the modified variables.
84    */
85   public void getModifiedVariable(final List list) {
86   }
87
88   /**
89    * Get the variables used.
90    */
91   public void getUsedVariable(final List list) {
92   }
93 }