From: kpouer Date: Sun, 10 Aug 2003 15:46:27 +0000 (+0000) Subject: many changes and fixes X-Git-Url: http://secure.phpeclipse.com?hp=f476951c21ad0e924129616117065d7c2204e7f5 many changes and fixes --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java index 92fcd24..8d2930a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayDeclarator.java @@ -35,7 +35,7 @@ public class ArrayDeclarator extends AbstractVariable { /** * 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(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java index 5bdc3c6..af9ed52 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java @@ -2,14 +2,12 @@ package net.sourceforge.phpdt.internal.compiler.ast; 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; /** @@ -21,9 +19,9 @@ 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; @@ -48,15 +46,15 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @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()); } /** @@ -65,15 +63,19 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @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); @@ -169,7 +171,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr } 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); @@ -190,7 +192,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @return the variables from outside */ public List getOutsideVariable() { - return new ArrayList(); + return new ArrayList(1); } /** @@ -198,7 +200,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @return the variables from we change value */ public List getModifiedVariable() { - return new ArrayList(); + return new ArrayList(1); } /** @@ -206,6 +208,6 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @return the variables used */ public List getUsedVariable() { - return new ArrayList(); + return new ArrayList(1); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java index c5f3e98..0122b26 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EchoStatement.java @@ -13,8 +13,8 @@ public class EchoStatement extends Statement { /** 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; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java index 71fc91e..61d4c8b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java @@ -77,7 +77,7 @@ public class FieldDeclaration extends Statement implements Outlineable { * @return the variables from outside */ public List getOutsideVariable() { - return new ArrayList(); + return new ArrayList(1); } /** @@ -85,7 +85,7 @@ public class FieldDeclaration extends Statement implements Outlineable { * @return the variables from we change value */ public List getModifiedVariable() { - return new ArrayList(); + return new ArrayList(1); } /** @@ -93,6 +93,6 @@ public class FieldDeclaration extends Statement implements Outlineable { * @return the variables used */ public List getUsedVariable() { - return new ArrayList(); + return new ArrayList(1); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java index 19fcbee..6e270c7 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FunctionCall.java @@ -10,7 +10,7 @@ import java.util.ArrayList; public class FunctionCall extends AbstractSuffixExpression { /** the function name. */ - public Expression prefix; + public Expression functionName; /** the arguments. */ public Expression[] args; @@ -19,7 +19,7 @@ public class FunctionCall extends AbstractSuffixExpression { final Expression[] args, final int sourceEnd) { super(prefix.sourceStart, sourceEnd); - this.prefix = prefix; + this.functionName = prefix; this.args = args; } @@ -28,7 +28,7 @@ public class FunctionCall extends AbstractSuffixExpression { * @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++) { @@ -71,7 +71,7 @@ public class FunctionCall extends AbstractSuffixExpression { * @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()); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java index ea7a95c..c9730ea 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/LabeledStatement.java @@ -7,11 +7,14 @@ import java.util.List; */ 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; @@ -23,7 +26,7 @@ public class LabeledStatement extends Statement { * @return a String */ public String toString() { - return new String(label) + statement.toString(); + return label + statement.toString(); } /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java index 663735a..1acab1d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java @@ -23,7 +23,7 @@ import test.PHPParserSuperclass; public class MethodDeclaration extends Statement implements OutlineableWithChildren { /** The name of the method. */ - public char[] name; + public String name; public Hashtable arguments; @@ -44,16 +44,20 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild 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); } @@ -252,9 +256,9 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild 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(), diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java index 443de28..c091d8b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Variable.java @@ -24,7 +24,9 @@ public class Variable extends AbstractVariable { * @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; } @@ -35,7 +37,9 @@ public class Variable extends AbstractVariable { * @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; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java index 6b9facd..8d08f65 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java @@ -35,6 +35,7 @@ public class VariableDeclaration extends Expression implements Outlineable { private Object parent; private boolean reference; + private Position position; private int operator; @@ -71,6 +72,7 @@ public class VariableDeclaration extends Expression implements Outlineable { super(sourceStart, sourceEnd); this.variable = variable; this.parent = parent; + position = new Position(sourceStart, sourceEnd); } public void setReference(final boolean reference) { @@ -213,7 +215,7 @@ public class VariableDeclaration extends Expression implements Outlineable { */ 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); }