1 package net.sourceforge.phpdt.internal.compiler.ast;
7 * @author Matthieu Casanova
9 public final class ClassAccess extends AbstractVariable {
11 /** a static class access : "::". */
12 public static final int STATIC = 0;
14 /** a normal class access : "->". */
15 public static final int NORMAL = 1;
17 private final Expression prefix;
20 private final Expression suffix;
22 /** the type of access. */
23 private final int type;
26 * Create a new class access.
29 * @param type the type of access {@link #STATIC} or {@link #NORMAL}
31 public ClassAccess(final Expression prefix,
32 final Expression suffix,
34 super(prefix.sourceStart, suffix.sourceEnd);
40 private String toStringOperator() {
42 case STATIC : return "::"; //$NON-NLS-1$
43 case NORMAL : return "->"; //$NON-NLS-1$
45 return "unknown operator"; //$NON-NLS-1$
49 * Return the expression as String.
50 * @return the expression
52 public String toStringExpression() {
53 final String prefixString = prefix.toStringExpression();
54 final String operatorString = toStringOperator();
55 final String suffixString = suffix.toStringExpression();
56 final StringBuffer buff = new StringBuffer(prefixString.length() +
57 operatorString.length() +
58 suffixString.length());
59 buff.append(prefixString);
60 buff.append(operatorString);
61 buff.append(suffixString);
62 return buff.toString();
66 * todo: find a better way to handle this
67 * @return the name of the variable
69 public String getName() {
70 if (prefix instanceof AbstractVariable) {
71 return ((AbstractVariable)prefix).getName();
73 return prefix.toStringExpression();
77 * Get the variables from outside (parameters, globals ...)
79 * @param list the list where we will put variables
81 public void getOutsideVariable(final List list) {}
84 * get the modified variables.
86 * @param list the list where we will put variables
88 public void getModifiedVariable(final List list) {}
91 * Get the variables used.
93 * @param list the list where we will put variables
95 public void getUsedVariable(final List list) {
96 prefix.getUsedVariable(list);
97 suffix.getUsedVariable(list);