X-Git-Url: http://git.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 f556cc8..6be74d7 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 @@ -19,28 +19,28 @@ import test.PHPParserSuperclass; * A Method declaration. * @author Matthieu Casanova */ -public class MethodDeclaration extends Statement implements OutlineableWithChildren { +public final class MethodDeclaration extends Statement implements OutlineableWithChildren { /** The name of the method. */ - public String name; - public ArrayList arguments; + public final String name; + private final ArrayList arguments; public Statement[] statements; - public int bodyStart; - public int bodyEnd = -1; + private final int bodyStart; + private int bodyEnd = -1; /** Tell if the method is a class constructor. */ public boolean isConstructor; /** The parent object. */ private Object parent; /** The outlineable children (those will be in the node array too. */ - private ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList(); /** Tell if the method returns a reference. */ - public boolean reference; + private final boolean reference; - private Position position; + private final Position position; public MethodDeclaration(final Object parent, final String name, @@ -72,7 +72,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild return buff.toString(); } - public String toStringHeader() { + private String toStringHeader() { return "function " + toString(); } @@ -81,7 +81,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild * @param tab the number of tabs * @return the String containing the statements */ - public String toStringStatements(final int tab) { + private String toStringStatements(final int tab) { final StringBuffer buff = new StringBuffer(" {"); //$NON-NLS-1$ if (statements != null) { for (int i = 0; i < statements.length; i++) { @@ -132,7 +132,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild if (arguments != null) { for (int i = 0; i < arguments.size(); i++) { - VariableDeclaration o = (VariableDeclaration) arguments.get(i); + final VariableDeclaration o = (VariableDeclaration) arguments.get(i); buff.append(o.toStringExpression()); if (i != (arguments.size() - 1)) { buff.append(", "); //$NON-NLS-1$ @@ -152,19 +152,16 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } /** no outside variables. */ - public void getOutsideVariable(final List list) { - } + public void getOutsideVariable(final List list) {} - public void getModifiedVariable(final List list) { - } + public void getModifiedVariable(final List list) {} - public void getUsedVariable(final List list) { - } + public void getUsedVariable(final List list) {} /** * Get global variables (not parameters). */ - public void getGlobalVariable(final List list) { + private void getGlobalVariable(final List list) { if (statements != null) { for (int i = 0; i < statements.length; i++) { statements[i].getOutsideVariable(list); @@ -175,7 +172,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild private void getParameters(final List list) { if (arguments != null) { for (int i = 0; i < arguments.size(); i++) { - VariableDeclaration variable = (VariableDeclaration) arguments.get(i); + final VariableDeclaration variable = (VariableDeclaration) arguments.get(i); list.add(new VariableUsage(variable.name(), variable.sourceStart)); } } @@ -203,7 +200,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } } - private boolean isVariableDeclaredBefore(final List list, final VariableUsage var) { + private static boolean isVariableDeclaredBefore(final List list, final VariableUsage var) { final String name = var.getName(); final int pos = var.getStartOffset(); for (int i = 0; i < list.size(); i++) { @@ -228,7 +225,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild getGlobalVariable(globalsVars); final List modifiedVars = new ArrayList(); getAssignedVariableInCode(modifiedVars); - final List parameters = new ArrayList(); + final List parameters = new ArrayList(arguments.size()); getParameters(parameters); final List declaredVars = new ArrayList(globalsVars.size() + modifiedVars.size()); @@ -252,9 +249,9 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild * @param vars the used variable list * @param parameters the declared variable list */ - private void findUnusedParameters(final List vars, final List parameters) { + private static void findUnusedParameters(final List vars, final List parameters) { for (int i = 0; i < parameters.size(); i++) { - final VariableUsage param = ((VariableUsage) parameters.get(i)); + final VariableUsage param = (VariableUsage) parameters.get(i); if (!isVariableInList(param.getName(), vars)) { try { PHPParserSuperclass.setMarker( @@ -270,7 +267,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } } - private boolean isVariableInList(final String name, final List list) { + private static boolean isVariableInList(final String name, final List list) { for (int i = 0; i < list.size(); i++) { if (((VariableUsage) list.get(i)).getName().equals(name)) { return true; @@ -284,10 +281,10 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild * @param usedVars the used variable list * @param declaredVars the declared variable list */ - private void findUnknownUsedVars(final List usedVars, final List declaredVars) { + private static void findUnknownUsedVars(final List usedVars, final List declaredVars) { for (int i = 0; i < usedVars.size(); i++) { final VariableUsage variableUsage = (VariableUsage) usedVars.get(i); - if (variableUsage.getName().equals("this")) continue; // this is a special variable + if ("this".equals(variableUsage.getName())) continue; // this is a special variable if (!isVariableDeclaredBefore(declaredVars, variableUsage)) { try { PHPParserSuperclass.setMarker(