misc parser bugfixes; still very ugly state
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / ClassAccess.java
index 303b62a..5a0553b 100644 (file)
@@ -6,21 +6,21 @@ import java.util.List;
  * Any class access.
  * @author Matthieu Casanova
  */
-public class ClassAccess extends AbstractVariable {
+public final class ClassAccess extends AbstractVariable {
 
-  /** a static class access : "::" */
+  /** a static class access : "::". */
   public static final int STATIC = 0;
 
-  /** a normal class access : "->" */
+  /** a normal class access : "->". */
   public static final int NORMAL = 1;
 
-  public Expression prefix;
+  private final Expression prefix;
 
   /** the suffix. */
-  public Expression suffix;
+  private final Expression suffix;
 
   /** the type of access. */
-  public int type;
+  private final int type;
 
   /**
    * Create a new class access.
@@ -37,7 +37,7 @@ public class ClassAccess extends AbstractVariable {
     this.type = type;
   }
 
-  public String toStringOperator() {
+  private String toStringOperator() {
     switch (type) {
       case STATIC : return "::"; //$NON-NLS-1$
       case NORMAL : return "->"; //$NON-NLS-1$
@@ -50,16 +50,21 @@ public class ClassAccess extends AbstractVariable {
    * @return the expression
    */
   public String toStringExpression() {
-    final StringBuffer buff = new StringBuffer();
-    buff.append(prefix.toStringExpression());
-    buff.append(toStringOperator());
-    buff.append(suffix.toStringExpression());
+    final String prefixString = prefix.toStringExpression();
+    final String operatorString = toStringOperator();
+    final String suffixString = suffix.toStringExpression();
+    final StringBuffer buff = new StringBuffer(prefixString.length() +
+                                               operatorString.length() +
+                                               suffixString.length());
+    buff.append(prefixString);
+    buff.append(operatorString);
+    buff.append(suffixString);
     return buff.toString();
   }
 
   /**
    * todo: find a better way to handle this
-   * @return
+   * @return the name of the variable
    */
   public String getName() {
     if (prefix instanceof AbstractVariable) {
@@ -70,18 +75,22 @@ public class ClassAccess extends AbstractVariable {
 
   /**
    * Get the variables from outside (parameters, globals ...)
+   *
+   * @param list the list where we will put variables
    */
-  public void getOutsideVariable(final List list) {
-  }
+  public void getOutsideVariable(final List list) {}
 
   /**
    * get the modified variables.
+   *
+   * @param list the list where we will put variables
    */
-  public void getModifiedVariable(final List list) {
-  }
+  public void getModifiedVariable(final List list) {}
 
   /**
    * Get the variables used.
+   *
+   * @param list the list where we will put variables
    */
   public void getUsedVariable(final List list) {
     prefix.getUsedVariable(list);