X-Git-Url: http://secure.phpeclipse.com 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 93b8758..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); } @@ -241,11 +245,21 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild //look for used variables that were not declared before + findUnknownUsedVars(usedVars, declaredVars); + } + + /** + * This method will add a warning on all used variables in a method that aren't declared before. + * @param usedVars the used variable list + * @param declaredVars the declared variable list + */ + 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 { - PHPParserSuperclass.setMarker("warning, usage of an unknown : " + variableUsage.getName(), + PHPParserSuperclass.setMarker("warning, usage of an unknown variable : " + variableUsage.getName(), variableUsage.getStartOffset(), variableUsage.getStartOffset() + variableUsage.getName().length(), PHPParserSuperclass.WARNING, @@ -254,7 +268,6 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild PHPeclipsePlugin.log(e); } } - } } }