Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / PHPVarDeclaration.java
1 package net.sourceforge.phpdt.internal.compiler.parser;
2
3 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
4
5 import org.eclipse.jface.resource.ImageDescriptor;
6
7 import test.PHPVar;
8
9 /**
10  * A php variable declaration strongly inspired by the PHPFunctionDeclaration of Khartlage (:.
11  * @author khartlage, Matthieu Casanova
12  */
13 public class PHPVarDeclaration extends PHPSegment {
14
15   /** A PHPVar. */
16   private final PHPVar variable;
17     /**
18      * Create a php variable declaration.
19      * @param parent the parent object (it should be a php class)
20      * @param name the name of the variable
21      * @param index where the variable is in the file
22      * @param value the value
23      */
24     public PHPVarDeclaration(Object parent, String name, int index, String value) {
25       super(parent, name, index);
26       variable = new PHPVar(name,value);
27     }
28
29   /**
30    * Create a php variable declaration.
31    * @param parent the parent object (it should be a php class)
32    * @param name the name of the variable
33    * @param index where the variable is in the file
34    */
35   public PHPVarDeclaration(Object parent, String name, int index) {
36       this(parent, name, index,null);
37   }
38
39     /**
40      * Get the image of a variable.
41      * @return the image that represents a php variable
42      */
43     public ImageDescriptor getImage() {
44         return PHPUiImages.DESC_VAR;
45     }
46
47   /**
48    * Get the PHPVar.
49    * @return a phpvar object
50    */
51   public PHPVar getVariable() {
52     return variable;
53   }
54
55   public String toString() {
56     return variable.toString();
57   }
58 }