1 package net.sourceforge.phpdt.internal.compiler.ast;
 
   3 import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
 
   6 import java.util.ArrayList;
 
  10  * It could be a simple variable, or contains another variable.
 
  11  * @author Matthieu Casanova
 
  13 public class Variable extends AbstractVariable {
 
  15   /** The name of the variable. */
 
  18   /** A variable inside ($$varname). */
 
  19   private AbstractVariable variable;
 
  21   private static final String _GET = "_GET";
 
  22   private static final String _POST = "_POST";
 
  23   private static final String _REQUEST = "_REQUEST";
 
  24   private static final String _SERVER = "_SERVER";
 
  25   private static final String _SESSION = "_SESSION";
 
  26   private static final String _this = "this";
 
  29    * Create a new simple variable.
 
  30    * @param name the name
 
  31    * @param sourceStart the starting position
 
  32    * @param sourceEnd the ending position
 
  34   public Variable(final String name,
 
  35                   final int sourceStart,
 
  36                   final int sourceEnd) {
 
  37     super(sourceStart, sourceEnd);
 
  42    * Create a special variable ($$toto for example).
 
  43    * @param variable the variable contained
 
  44    * @param sourceStart the starting position
 
  45    * @param sourceEnd the ending position
 
  47   public Variable(final AbstractVariable variable,
 
  48                   final int sourceStart,
 
  49                   final int sourceEnd) {
 
  50     super(sourceStart, sourceEnd);
 
  51     this.variable = variable;
 
  55    * Return the expression as String.
 
  56    * @return the expression
 
  58   public String toStringExpression() {
 
  59     return "$" + getName();
 
  62   public String getName() {
 
  63     if (variable == null) {
 
  66     return variable.toStringExpression();
 
  70    * Get the variables from outside (parameters, globals ...)
 
  71    * @return the variables from outside
 
  73   public List getOutsideVariable() {
 
  74     return new ArrayList(1);
 
  78    * get the modified variables.
 
  79    * @return the variables modified
 
  81   public List getModifiedVariable() {
 
  82     return new ArrayList(1);
 
  86    * Get the variables used.
 
  87    * @return the variables used
 
  89   public List getUsedVariable() {
 
  92       varName = variable.getName();
 
  96     if (name.equals(_GET) ||
 
  98         name.equals(_REQUEST) ||
 
  99         name.equals(_SERVER) ||
 
 100         name.equals(_SESSION) ||
 
 101         name.equals(_this)) {
 
 102       return new ArrayList(1);
 
 104     final ArrayList list = new ArrayList(1);
 
 105     list.add(new VariableUsage(varName, sourceStart));