3 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 
   6  * A Variable usage. It could be a first use, an in code use of an already declared var.
 
   7  * In fact I'm not sure for the moment I will keep this
 
   8  * @author Matthieu Casanova
 
  12   /** The name of the variable. It couldn't be changed. */
 
  13   private final String name;
 
  15   /** The value. It could change. */
 
  18   private String prefix;
 
  21    * Does the variable have a value or not.
 
  22    * If we don't know if it was initialized it should be set on true.
 
  23    * (when we have a global keyword for example)
 
  25   private boolean initialized;
 
  27   /** This variable indicate if it is used or not in the code. */
 
  31    * We initialize the name and the value of the variable.
 
  32    * @param name the name of the variable
 
  33    * @param value the value of the variable
 
  35   public PHPVar(String name, String value) {
 
  38     initialized = value != null;
 
  42    * We initialize the name of the variable. The value will be null
 
  43    * @param name the name of the variable
 
  45   public PHPVar(String name) {
 
  50    * Initialize the variable name and set the initialization status.
 
  51    * @param name the name of the variable
 
  52    * @param initialized the initialization status (it should be true or it's unuseful)
 
  54   public PHPVar(String name, boolean initialized) {
 
  56     this.initialized = initialized;
 
  60    * Give a prefix to the variable.
 
  61    * @param prefix a prefix
 
  63   public void setPrefix(String prefix) {
 
  67   public void setUsed(boolean used) {
 
  68     PHPeclipsePlugin.log(1,name + " is used");
 
  72   public String getName() {
 
  76   public boolean isUsed() {
 
  81    * Return a human readable variable (:
 
  82    * @return  a string representation of the object.
 
  84   public String toString() {
 
  87         return prefix + "$" + name;
 
  92       return prefix + "$" + name + "=" + value;
 
  94     return "$" + name + "=" + value;