3.x RC1 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Variable.java
index add462f..3cced48 100644 (file)
@@ -1,16 +1,15 @@
 package net.sourceforge.phpdt.internal.compiler.ast;
 
-import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
-
 import java.util.List;
-import java.util.ArrayList;
+
+import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
 
 /**
  * A variable.
  * It could be a simple variable, or contains another variable.
  * @author Matthieu Casanova
  */
-public class Variable extends AbstractVariable {
+public final class Variable extends AbstractVariable {
 
   /** The name of the variable. */
   private String name;
@@ -21,16 +20,16 @@ public class Variable extends AbstractVariable {
   /** the variable is defined like this ${expression} */
   private Expression expression;
 
-  public static final String _GET = "_GET";
-  public static final String _POST = "_POST";
-  public static final String _REQUEST = "_REQUEST";
-  public static final String _SERVER = "_SERVER";
-  public static final String _SESSION = "_SESSION";
-  public static final String _this = "this";
-  public static final String GLOBALS = "GLOBALS";
-  public static final String _COOKIE = "_COOKIE";
-  public static final String _FILES = "_FILES";
-  public static final String _ENV = "_ENV";
+  private static final String _GET = "_GET";
+  private static final String _POST = "_POST";
+  private static final String _REQUEST = "_REQUEST";
+  private static final String _SERVER = "_SERVER";
+  private static final String _SESSION = "_SESSION";
+  private static final String _this = "this";
+  private static final String GLOBALS = "GLOBALS";
+  private static final String _COOKIE = "_COOKIE";
+  private static final String _FILES = "_FILES";
+  private static final String _ENV = "_ENV";
 
   /** Here is an array of all superglobals variables and the special "this". */
   public static final String[] SPECIAL_VARS = {_GET,
@@ -88,7 +87,7 @@ public class Variable extends AbstractVariable {
    * @return the expression
    */
   public String toStringExpression() {
-    return "$" + getName();
+    return '$' + getName();
   }
 
   public String getName() {
@@ -98,30 +97,25 @@ public class Variable extends AbstractVariable {
     if (variable != null) {
       return variable.toStringExpression();
     }
-    return "{" + expression.toStringExpression() + "}";
+    return '{' + expression.toStringExpression() + '}';
   }
 
   /**
    * Get the variables from outside (parameters, globals ...)
-   * @return the variables from outside
    */
-  public List getOutsideVariable() {
-    return new ArrayList(1);
+  public void getOutsideVariable(final List list) {
   }
 
   /**
    * get the modified variables.
-   * @return the variables modified
    */
-  public List getModifiedVariable() {
-    return new ArrayList(1);
+  public void getModifiedVariable(final List list) {
   }
 
   /**
    * Get the variables used.
-   * @return the variables used
    */
-  public List getUsedVariable() {
+  public void getUsedVariable(final List list) {
     final String varName;
     if (name != null) {
       varName = name;
@@ -130,11 +124,8 @@ public class Variable extends AbstractVariable {
     } else {
       varName = expression.toStringExpression();//todo : do a better thing like evaluate this ??
     }
-    if (arrayContains(SPECIAL_VARS, name)) {
-      return new ArrayList(1);
+    if (!arrayContains(SPECIAL_VARS, name)) {
+      list.add(new VariableUsage(varName, sourceStart));
     }
-    final ArrayList list = new ArrayList(1);
-    list.add(new VariableUsage(varName, sourceStart));
-    return list;
   }
 }