/**
* Return the name of the variable.
- * @return the name of the prefix variable
+ * @return the name of the functionName variable
*/
public String getName() {
return prefix.getName();
import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
-import net.sourceforge.phpdt.internal.compiler.ast.declarations.VariableUsage;
import net.sourceforge.phpdt.internal.ui.PHPUiImages;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.Position;
import java.util.ArrayList;
import java.util.List;
-import java.util.Enumeration;
/**
public class ClassDeclaration extends Statement implements OutlineableWithChildren {
/** The name of the class. */
- public char[] name;
+ public String name;
/** The superclass. */
- public char[] superclass;
+ public String superclass;
public int declarationSourceStart;
public int declarationSourceEnd;
* @param sourceEnd ending offset
*/
public ClassDeclaration(final Object parent,
- final char[] name,
- final char[] superclass,
+ final String name,
+ final String superclass,
final int sourceStart,
final int sourceEnd) {
super(sourceStart, sourceEnd);
this.parent = parent;
this.name = name;
this.superclass = superclass;
- position = new Position(sourceStart, name.length);
+ position = new Position(sourceStart, name.length());
}
/**
* @param sourceEnd ending offset
*/
public ClassDeclaration(final Object parent,
- final char[] name,
+ final String name,
final int sourceStart,
final int sourceEnd) {
super(sourceStart, sourceEnd);
this.parent = parent;
this.name = name;
- position = new Position(sourceStart, name.length);
+ position = new Position(sourceStart, name.length());
}
+ /**
+ * Add a method to the class.
+ * @param method the method declaration
+ */
public void addMethod(final MethodDeclaration method) {
methods.add(method);
add(method);
}
public String toString() {
- final StringBuffer buff = new StringBuffer(new String(name));
+ final StringBuffer buff = new StringBuffer(name);
if (superclass != null) {
buff.append(":"); //$NON-NLS-1$
buff.append(superclass);
* @return the variables from outside
*/
public List getOutsideVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return the variables from we change value
*/
public List getModifiedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return the variables used
*/
public List getUsedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
}
/** An array of expressions in this echo statement. */
public Expression[] expressions;
- public EchoStatement (final Expression[] expressions, final int sourceStart) {
- super(sourceStart, expressions[expressions.length-1].sourceEnd);
+ public EchoStatement (final Expression[] expressions, final int sourceStart, final int sourceEnd) {
+ super(sourceStart, sourceEnd);
this.expressions = expressions;
}
* @return the variables from outside
*/
public List getOutsideVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return the variables from we change value
*/
public List getModifiedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return the variables used
*/
public List getUsedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
}
public class FunctionCall extends AbstractSuffixExpression {
/** the function name. */
- public Expression prefix;
+ public Expression functionName;
/** the arguments. */
public Expression[] args;
final Expression[] args,
final int sourceEnd) {
super(prefix.sourceStart, sourceEnd);
- this.prefix = prefix;
+ this.functionName = prefix;
this.args = args;
}
* @return the expression
*/
public String toStringExpression() {
- final StringBuffer buff = new StringBuffer(prefix.toStringExpression());
+ final StringBuffer buff = new StringBuffer(functionName.toStringExpression());
buff.append('(');
if (args != null) {
for (int i = 0; i < args.length; i++) {
* @return the variables used
*/
public List getUsedVariable() {
- final List list = prefix.getUsedVariable();
+ final List list = functionName.getUsedVariable();
if (args != null) {
for (int i = 0; i < args.length; i++) {
list.addAll(args[i].getUsedVariable());
*/
public class LabeledStatement extends Statement {
- public char[] label;
+ public String label;
public Statement statement;
- public LabeledStatement(final char[] label, final Statement statement, final int sourceStart, final int sourceEnd) {
+ public LabeledStatement(final String label,
+ final Statement statement,
+ final int sourceStart,
+ final int sourceEnd) {
super(sourceStart, sourceEnd);
this.label = label;
this.statement = statement;
* @return a String
*/
public String toString() {
- return new String(label) + statement.toString();
+ return label + statement.toString();
}
/**
public class MethodDeclaration extends Statement implements OutlineableWithChildren {
/** The name of the method. */
- public char[] name;
+ public String name;
public Hashtable arguments;
private Position position;
public MethodDeclaration(final Object parent,
- final char[] name,
+ final String name,
final Hashtable arguments,
final boolean reference,
final int sourceStart,
- final int sourceEnd) {
+ final int sourceEnd,
+ final int bodyStart,
+ final int bodyEnd) {
super(sourceStart, sourceEnd);
this.name = name;
this.arguments = arguments;
this.parent = parent;
this.reference = reference;
+ this.bodyStart = bodyStart;
+ this.bodyEnd = bodyEnd;
position = new Position(sourceStart, sourceEnd);
}
private void findUnknownUsedVars(final List usedVars, final List declaredVars) {
for (int i = 0; i < usedVars.size(); i++) {
VariableUsage variableUsage = (VariableUsage) usedVars.get(i);
+ if (variableUsage.getName().equals("this")) continue; // this is a special variable
if (!isVariableDeclaredBefore(declaredVars, variableUsage)) {
try {
- PHPeclipsePlugin.log(1,variableUsage.getName()+" "+variableUsage.getStartOffset());
PHPParserSuperclass.setMarker("warning, usage of an unknown variable : " + variableUsage.getName(),
variableUsage.getStartOffset(),
variableUsage.getStartOffset() + variableUsage.getName().length(),
* @param sourceStart the starting position
* @param sourceEnd the ending position
*/
- public Variable(final String name, final int sourceStart, final int sourceEnd) {
+ public Variable(final String name,
+ final int sourceStart,
+ final int sourceEnd) {
super(sourceStart, sourceEnd);
this.name = name;
}
* @param sourceStart the starting position
* @param sourceEnd the ending position
*/
- public Variable(final AbstractVariable variable, final int sourceStart, final int sourceEnd) {
+ public Variable(final AbstractVariable variable,
+ final int sourceStart,
+ final int sourceEnd) {
super(sourceStart, sourceEnd);
this.variable = variable;
}
private Object parent;
private boolean reference;
+
private Position position;
private int operator;
super(sourceStart, sourceEnd);
this.variable = variable;
this.parent = parent;
+ position = new Position(sourceStart, sourceEnd);
}
public void setReference(final boolean reference) {
*/
public List getUsedVariable() {
if (initialization != null) {
- return initialization.getModifiedVariable();//yes it's getModified variable (in a variable declaration $a = $b, $a is modified, event if you have only $a and no initialization
+ return initialization.getUsedVariable();
}
return new ArrayList(1);
}