public ArrayDeclarator(final AbstractVariable prefix,
final Expression vars,
final int sourceEnd) {
- super(prefix.getSourceStart(), sourceEnd);
+ super(prefix.sourceStart, sourceEnd);
this.prefix = prefix;
this.var = vars;
}
* @param value the value
*/
public ArrayVariableDeclaration(final Expression key, final Expression value) {
- super(key.getSourceStart(), value.getSourceEnd());
+ super(key.sourceStart, value.sourceEnd);
this.key = key;
this.value = value;
}
* @param sourceEnd the end position
*/
public ArrayVariableDeclaration(final Expression key, final int sourceEnd) {
- super(key.getSourceStart(), sourceEnd);
+ super(key.sourceStart, sourceEnd);
this.key = key;
}
public abstract class AstNode {
/** Starting and ending position of the node in the sources. */
- private int sourceStart, sourceEnd;
+ public int sourceStart, sourceEnd;
/**
* Create a node giving starting and ending offset
* @param sourceEnd ending offset
*/
public AstNode(final int sourceStart, final int sourceEnd) {
- this.setSourceStart(sourceStart);
- this.setSourceEnd(sourceEnd);
+ this.sourceStart = sourceStart;
+ this.sourceEnd = sourceEnd;
}
/**
* @return the variables used
*/
public abstract List getUsedVariable();
-
- public int getSourceStart() {
- return sourceStart;
- }
-
- public int getSourceEnd() {
- return sourceEnd;
- }
-
- public void setSourceStart(int sourceStart) {
- this.sourceStart = sourceStart;
- }
-
- public void setSourceEnd(int sourceEnd) {
- this.sourceEnd = sourceEnd;
- }
}
public BinaryExpression(final Expression left,
final Expression right,
final int operator) {
- super(operator, left.getSourceStart(), right.getSourceEnd());
+ super(operator, left.sourceStart, right.sourceEnd);
this.left = left;
this.right = right;
}
public ClassAccess(final Expression prefix,
final Expression suffix,
final int type) {
- super(prefix.getSourceStart(), suffix.getSourceEnd());
+ super(prefix.sourceStart, suffix.sourceEnd);
this.prefix = prefix;
this.suffix = suffix;
this.type = type;
public ConditionalExpression(final Expression condition,
final Expression valueIfTrue,
final Expression valueIfFalse) {
- super(-1, condition.getSourceStart(), valueIfFalse.getSourceEnd());
+ super(-1, condition.sourceStart, valueIfFalse.sourceEnd);
this.condition = condition;
this.valueIfTrue = valueIfTrue;
this.valueIfFalse = valueIfFalse;
package net.sourceforge.phpdt.internal.compiler.ast;
+import test.Token;
+
import java.util.List;
import java.util.ArrayList;
*/
public class ConstantIdentifier extends Expression {
- public char[] name;
+ public String name;
- public ConstantIdentifier(final char[] name,
+ public ConstantIdentifier(final String name,
final int sourceStart,
final int sourceEnd) {
super(sourceStart, sourceEnd);
this.name = name;
}
+ public ConstantIdentifier(final Token token) {
+ super(token.sourceStart,token.sourceEnd);
+ name = token.image;
+ }
+
/**
* Return the expression as String.
* @return the expression
*/
public String toStringExpression() {
- return new String(name);
+ return name;
}
/**
* @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 List getOutsideVariable() {
final ArrayList list = new ArrayList(1);
- list.add(new VariableUsage(defineName.toStringExpression(),getSourceStart()));//todo: someday : evaluate the defineName
+ list.add(new VariableUsage(defineName.toStringExpression(),sourceStart));//todo: someday : evaluate the defineName
return list;
}
public Expression[] expressions;
public EchoStatement (final Expression[] expressions, final int sourceStart) {
- super(sourceStart, expressions[expressions.length-1].getSourceEnd());
+ super(sourceStart, expressions[expressions.length-1].sourceEnd);
this.expressions = expressions;
}
package net.sourceforge.phpdt.internal.compiler.ast;
+import test.Token;
+
import java.util.List;
import java.util.ArrayList;
*/
public class FalseLiteral extends MagicLiteral {
- public static final char[] source = {'f', 'a', 'l', 's', 'e'};
-
- public FalseLiteral(final int sourceStart, final int sourceEnd) {
- super(sourceStart, sourceEnd);
+ public FalseLiteral(final Token token) {
+ super(token.sourceStart, token.sourceEnd);
}
/**
return "false";//$NON-NLS-1$
}
- public char[] source() {
- return source;
- }
-
public String toString() {
return "false";//$NON-NLS-1$
}
public FunctionCall(final Expression prefix,
final Expression[] args,
final int sourceEnd) {
- super(prefix.getSourceStart(), sourceEnd);
+ super(prefix.sourceStart, sourceEnd);
this.prefix = prefix;
this.args = args;
}
public AstNode[] nodes;
public HTMLBlock(final AstNode[] nodes) {
- super(nodes[0].getSourceStart(), nodes[nodes.length-1].getSourceEnd());
+ super(nodes[0].sourceStart, nodes[nodes.length-1].sourceEnd);
this.nodes = nodes;
}
final int keyword,
final Expression expression,
final int sourceStart) {
- super(sourceStart, expression.getSourceEnd());
+ super(sourceStart, expression.sourceEnd);
this.keyword = keyword;
this.expression = expression;
this.parent = parent;
- position = new Position(sourceStart, getSourceEnd());
+ position = new Position(sourceStart, sourceEnd);
}
public String keywordToString() {
* @return the variables from outside
*/
public List getOutsideVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
public List getModifiedVariable() {
final ArrayList list = new ArrayList();
for (int i = 0; i < vars.length; i++) {
- list.addAll(vars[i].getModifiedVariable());
+ list.addAll(vars[i].getUsedVariable());
}
if (expression != null) {
list.addAll(expression.getModifiedVariable());
super(sourceStart, sourceEnd);
}
- public abstract char[] source();
-
/**
* Get the variables from outside (parameters, globals ...)
* @return an empty list
*/
public List getOutsideVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return an empty list
*/
public List getModifiedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
/**
* @return an empty list
*/
public List getUsedVariable() {
- return new ArrayList();
+ return new ArrayList(1);
}
}
if (arguments != null) {
final Enumeration vars = arguments.keys();
while (vars.hasMoreElements()) {
- list.add(new VariableUsage((String) vars.nextElement(), getSourceStart()));
+ list.add(new VariableUsage((String) vars.nextElement(), sourceStart));
}
}
VariableUsage variableUsage = (VariableUsage) usedVars.get(i);
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(),
package net.sourceforge.phpdt.internal.compiler.ast;
+import test.Token;
+
/**
* @author Matthieu Casanova
*/
public class NullLiteral extends MagicLiteral {
- public static final char[] source = {'n' , 'u' , 'l' , 'l'};
-
- public NullLiteral(final int sourceStart, final int sourceEnd) {
- super(sourceStart, sourceEnd);
+ public NullLiteral(final Token token) {
+ super(token.sourceStart, token.sourceEnd);
}
/**
public String toStringExpression() {
return "null";
}
-
- public char[] source() {
- return source;
- }
}
package net.sourceforge.phpdt.internal.compiler.ast;
+import test.Token;
+
/**
- * Literal for numbers
+ * Literal for numbers.
* @author Matthieu Casanova
*/
public class NumberLiteral extends Literal {
- public char[] source;
+ public String source;
- public NumberLiteral(final char[] token,
- final int sourceStart,
- final int sourceEnd) {
- super(sourceStart, sourceEnd);
- source = token;
- }
-
- public char[] source() {
- return source;
+ public NumberLiteral(final Token token) {
+ super(token.sourceStart, token.sourceEnd);
+ source = token.image;
}
/**
* @return the expression
*/
public String toStringExpression() {
- return new String(source);
+ return source;
}
}
public class PostfixedUnaryExpression extends UnaryExpression {
public PostfixedUnaryExpression(final Expression expression, final int operator, final int sourceEnd) {
- super(expression, operator, expression.getSourceStart(), sourceEnd);
+ super(expression, operator, expression.sourceStart, sourceEnd);
}
public String toStringExpression() {
*/
public class PrefixedUnaryExpression extends UnaryExpression {
- public PrefixedUnaryExpression(final Expression expression, final int operator, final int sourceStart) {
- super(expression, operator, sourceStart, expression.getSourceEnd());
+ public PrefixedUnaryExpression(final Expression expression,
+ final int operator,
+ final int sourceStart) {
+ super(expression, operator, sourceStart, expression.sourceEnd);
}
public String toStringExpression() {
******************************************************************************/
package net.sourceforge.phpdt.internal.compiler.ast;
-import java.util.List;
-import java.util.ArrayList;
-
-//import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
-//import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
-//import net.sourceforge.phpdt.internal.compiler.impl.Constant;
-//import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
-//import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
+import test.Token;
public class StringLiteral extends Literal {
- char[] source;
+ String source;
- public StringLiteral(final char[] token, final int s) {
- super(s, s + token.length);
- source = token;
+ public StringLiteral(Token token) {
+ super(token.sourceStart,token.sourceEnd);
+ source = token.image;
}
/**
* @param e sourceend
* @deprecated
*/
- public StringLiteral(final char[] token, final int s, final int e) {
+ public StringLiteral(final String token, final int s, final int e) {
super(s, e);
source = token;
}
- public StringLiteral(final int s, final int e) {
- super(s, e);
- }
-
/**
- * source method comment.
+ * Create a new StringLiteral
+ * @param token the token
+ * @param s sourcestart
+ * @param e sourceend
+ * @deprecated
*/
- public char[] source() {
- return source;
+ public StringLiteral(final char[] token, final int s, final int e) {
+ this(new String(token),s, e);
}
- /**
- * Return the expression as String.
- * @return the expression
- */
- /* public String toStringExpression() {
- // handle some special char.....
- StringBuffer result = new StringBuffer("\""); //$NON-NLS-1$
- for (int i = 0; i < source.length; i++) {
- switch (source[i]) {
- case '\b':
- result.append("\\b"); //$NON-NLS-1$
- break;
- case '\t':
- result.append("\\t"); //$NON-NLS-1$
- break;
- case '\n':
- result.append("\\n"); //$NON-NLS-1$
- break;
- case '\f':
- result.append("\\f"); //$NON-NLS-1$
- break;
- case '\r':
- result.append("\\r"); //$NON-NLS-1$
- break;
- case '\"':
- result.append("\\\""); //$NON-NLS-1$
- break;
- case '\'':
- result.append("\\'"); //$NON-NLS-1$
- break;
- case '\\': //take care not to display the escape as a potential real char
- result.append("\\\\"); //$NON-NLS-1$
- break;
- default :
- result.append(source[i]);
- }
- }
- result.append("\""); //$NON-NLS-1$
- return result.toString();
- } */
-
+ public StringLiteral(final int s, final int e) {
+ super(s, e);
+ }
/**
* Return the expression as String.
* @return the expression
*/
public String toStringExpression() {
- return new String(source);
+ return source;
}
/**
* @deprecated - use field instead
*/
public int sourceEnd() {
- return getSourceEnd();
+ return sourceEnd;
}
/**
* @deprecated - use field instead
*/
public int sourceStart() {
- return getSourceStart();
+ return sourceStart;
}
}
package net.sourceforge.phpdt.internal.compiler.ast;
+import test.Token;
+
import java.util.List;
import java.util.ArrayList;
*/
public class TrueLiteral extends MagicLiteral {
- public static final char[] source = {'t', 'r', 'u', 'e'};
-
- public TrueLiteral(final int sourceStart, final int sourceEnd) {
- super(sourceStart, sourceEnd);
- }
-
- public char[] source() {
- return source;
+ public TrueLiteral(Token token) {
+ super(token.sourceStart, token.sourceEnd);
}
/**
public List getUsedVariable() {
final ArrayList list = new ArrayList(1);
if (name == null) {
- list.add(new VariableUsage(variable.getName(), getSourceStart()));
+ list.add(new VariableUsage(variable.getName(), sourceStart));
} else {
- list.add(new VariableUsage(name, getSourceStart()));
+ list.add(new VariableUsage(name, sourceStart));
}
return list;
}
final Expression initialization,
final int operator,
final int sourceStart) {
- super(sourceStart, initialization.getSourceEnd());
+ super(sourceStart, initialization.sourceEnd);
this.initialization = initialization;
this.variable = variable;
this.operator = operator;
this.parent = parent;
- position = new Position(sourceStart, getSourceEnd());
+ position = new Position(sourceStart, sourceEnd);
}
/**
final Expression initialization,
final int operator,
final int sourceStart) {
- super(sourceStart, initialization.getSourceEnd());
+ super(sourceStart, initialization.sourceEnd);
this.variable = variable;
this.initialization = initialization;
this.operator = operator;
*/
public VariableDeclaration(final AbstractVariable variable,
final int sourceStart) {
- super(sourceStart, variable.getSourceEnd());
+ super(sourceStart, variable.sourceEnd);
this.variable = variable;
}