*** empty log message ***
[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
7 /**
8  * A Field declaration.
9  * This is a variable declaration for a php class
10  * In fact it's an array of VariableDeclaration, since a field could contains
11  * several vars :
12  * var $toto,$tata;
13  * @author Matthieu Casanova
14  */
15 public class FieldDeclaration extends Statement implements Outlineable {
16
17   /** The variables. */
18   public VariableDeclaration[] vars;
19
20   private Object parent;
21   /**
22    * Create a new field.
23    * @param vars the array of variables.
24    * @param sourceStart the starting offset
25    * @param sourceEnd   the ending offset
26    */
27   public FieldDeclaration(VariableDeclaration[] vars, int sourceStart, int sourceEnd, Object parent) {
28     super(sourceStart, sourceEnd);
29     this.vars = vars;
30     this.parent = parent;
31   }
32
33   /**
34    * Return the object into String.
35    * @param tab how many tabs (not used here
36    * @return a String
37    */
38   public String toString(int tab) {
39     final StringBuffer buff = new StringBuffer(tabString(tab));
40     buff.append("var ");//$NON-NLS-1$
41     for (int i = 0; i < vars.length; i++) {
42       VariableDeclaration var = vars[i];
43       if (i != 0) {
44         buff.append(',');//$NON-NLS-1$
45       }
46       buff.append(var.toStringExpression());
47     }
48     return buff.toString();
49   }
50
51   /**
52    * Get the image of a variable.
53    * @return the image that represents a php variable
54    */
55   public ImageDescriptor getImage() {
56       return PHPUiImages.DESC_VAR;
57   }
58
59   public Object getParent() {
60     return parent;
61   }
62 }