1 package net.sourceforge.phpdt.internal.compiler.ast;
4 import java.util.ArrayList;
8 * @author Matthieu Casanova
10 public class ClassAccess extends AbstractVariable {
12 /** a static class access : "::" */
13 public static final int STATIC = 0;
15 /** a normal class access : "->" */
16 public static final int NORMAL = 1;
18 public Expression prefix;
21 public Expression suffix;
23 /** the type of access. */
27 * Create a new class access.
30 * @param type the type of access {@link #STATIC} or {@link #NORMAL}
32 public ClassAccess(final Expression prefix,
33 final Expression suffix,
35 super(prefix.getSourceStart(), suffix.getSourceEnd());
41 public String toStringOperator() {
43 case STATIC : return "::"; //$NON-NLS-1$
44 case NORMAL : return "->"; //$NON-NLS-1$
46 return "unknown operator"; //$NON-NLS-1$
50 * Return the expression as String.
51 * @return the expression
53 public String toStringExpression() {
54 final StringBuffer buff = new StringBuffer();
55 buff.append(prefix.toStringExpression());
56 buff.append(toStringOperator());
57 buff.append(suffix.toStringExpression());
58 return buff.toString();
62 * todo: find a better way to handle this
65 public String getName() {
66 if (prefix instanceof AbstractVariable) {
67 return ((AbstractVariable)prefix).getName();
69 return prefix.toStringExpression();
73 * Get the variables from outside (parameters, globals ...)
74 * @return the variables from outside
76 public List getOutsideVariable() {
77 return new ArrayList(1);
81 * get the modified variables.
82 * @return the variables from we change value
84 public List getModifiedVariable() {
85 return new ArrayList(1);
89 * Get the variables used.
90 * @return the variables used
92 public List getUsedVariable() {
93 final List list = prefix.getUsedVariable();
94 list.addAll(suffix.getUsedVariable());