X-Git-Url: http://git.phpeclipse.com 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 62420f4..adb4332 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 @@ -1,15 +1,15 @@ package net.sourceforge.phpdt.internal.compiler.ast; +import java.util.ArrayList; +import java.util.List; + import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; import net.sourceforge.phpdt.internal.ui.PHPUiImages; -import net.sourceforge.phpeclipse.PHPeclipsePlugin; + import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; -import java.util.ArrayList; -import java.util.List; - /** * This class is my ClassDeclaration declaration for php. @@ -17,12 +17,12 @@ import java.util.List; * It directly extends AstNode because a class cannot appear anywhere in php * @author Matthieu Casanova */ -public class ClassDeclaration extends Statement implements OutlineableWithChildren { +public final class ClassDeclaration extends Statement implements OutlineableWithChildren { /** The name of the class. */ - public char[] name; + private final String name; /** The superclass. */ - public char[] superclass; + private String superclass; public int declarationSourceStart; public int declarationSourceEnd; @@ -31,48 +31,53 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr /** The methods of the class. */ private final ArrayList methods = new ArrayList(); /** The constructor of the class. */ - public MethodDeclaration constructor; + private MethodDeclaration constructor; /** The fields of the class. */ - private ArrayList fields = new ArrayList(); + private final ArrayList fields = new ArrayList(); - private Object parent; + private final Object parent; /** The outlineable children (those will be in the node array too. */ - private ArrayList children = new ArrayList(); + private final ArrayList children = new ArrayList(); + + private final Position position; - private Position position; /** - * Create a class giving starting and ending offset + * Create a class giving starting and ending offset. * @param sourceStart starting offset * @param sourceEnd ending offset */ - public ClassDeclaration(Object parent, - char[] name, - char[] superclass, - int sourceStart, - int sourceEnd) { + public ClassDeclaration(final Object parent, + 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()); } /** - * Create a class giving starting and ending offset + * Create a class giving starting and ending offset. * @param sourceStart starting offset * @param sourceEnd ending offset */ - public ClassDeclaration(Object parent, - char[] name, - int sourceStart, - int sourceEnd) { + public ClassDeclaration(final Object parent, + 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()); } - public void addMethod(MethodDeclaration method) { + /** + * Add a method to the class. + * @param method the method declaration + */ + public void addMethod(final MethodDeclaration method) { methods.add(method); add(method); if (method.name.equals(name)) { @@ -80,15 +85,15 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr } } - public void addField(FieldDeclaration var) { + public void addField(final FieldDeclaration var) { for (int i = 0; i < var.vars.length; i++) { - VariableDeclaration c = var.vars[i]; + final VariableDeclaration c = var.vars[i]; children.add(c); } fields.add(var); } - public boolean add(Outlineable o) { + public boolean add(final Outlineable o) { return children.add(o); } @@ -105,27 +110,27 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @param tab how many tabs before the class * @return the code of this class into String */ - public String toString(int tab) { + public String toString(final int tab) { return tabString(tab) + toStringHeader() + toStringBody(tab); } /** - * Return the body of the class as String + * Return the body of the class as String. * @param tab how many tabs before the body of the class * @return the body as String */ - public String toStringBody(int tab) { + private String toStringBody(final int tab) { final StringBuffer buff = new StringBuffer(" {");//$NON-NLS-1$ if (fields != null) { for (int i = 0; i < fields.size(); i++) { - FieldDeclaration field = (FieldDeclaration) fields.get(i); + final FieldDeclaration field = (FieldDeclaration) fields.get(i); buff.append("\n"); //$NON-NLS-1$ buff.append(field.toString(tab + 1)); buff.append(";");//$NON-NLS-1$ } } for (int i = 0; i < methods.size(); i++) { - MethodDeclaration o = (MethodDeclaration) methods.get(i); + final MethodDeclaration o = (MethodDeclaration) methods.get(i); buff.append("\n");//$NON-NLS-1$ buff.append(o.toString(tab + 1)); } @@ -137,7 +142,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * Return the header of the class as String. * @return the header of the class */ - public String toStringHeader() { + private String toStringHeader() { final StringBuffer buff = new StringBuffer("class ").append(name);//$NON-NLS-1$ if (superclass != null) { buff.append(" extends "); //$NON-NLS-1$ @@ -158,17 +163,16 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr return parent; } - public Outlineable get(int index) { + public Outlineable get(final int index) { return (Outlineable) children.get(index); } public int size() { - PHPeclipsePlugin.log(1,"class size : "+children.size()); return children.size(); } public String toString() { - final StringBuffer buff = new StringBuffer(new String(name));//$NON-NLS-1$ + final StringBuffer buff = new StringBuffer(name); if (superclass != null) { buff.append(":"); //$NON-NLS-1$ buff.append(superclass); @@ -183,4 +187,25 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr public List getList() { return children; } + + /** + * Get the variables from outside (parameters, globals ...) + * + * @param list the list where we will put variables + */ + public void getOutsideVariable(final List list) {} + + /** + * get the modified variables. + * + * @param list the list where we will put variables + */ + public void getModifiedVariable(final List list) {} + + /** + * Get the variables used. + * + * @param list the list where we will put variables + */ + public void getUsedVariable(final List list) {} }