X-Git-Url: http://secure.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 bbc9775..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 @@ -3,11 +3,11 @@ 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.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.Enumeration; +import java.util.List; /** @@ -19,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; @@ -38,20 +38,23 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr /** The outlineable children (those will be in the node array too. */ private ArrayList children = new ArrayList(); + private Position position; + /** * 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()); } /** @@ -59,31 +62,40 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr * @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()); } - 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); - children.add(method); + add(method); if (method.name.equals(name)) { constructor = method; } } - public void addVariable(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(final Outlineable o) { + return children.add(o); + } + /** * Tell if the class has a constructor. * @return a boolean @@ -97,27 +109,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) { + public 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)); } @@ -150,15 +162,52 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr return parent; } - public boolean add(Outlineable o) { - return children.add(o); - } - - public Outlineable get(int index) { + public Outlineable get(final int index) { return (Outlineable) children.get(index); } public int size() { return children.size(); } + + public String toString() { + final StringBuffer buff = new StringBuffer(name); + if (superclass != null) { + buff.append(":"); //$NON-NLS-1$ + buff.append(superclass); + } + return buff.toString(); + } + + public Position getPosition() { + return position; + } + + public List getList() { + return children; + } + + /** + * Get the variables from outside (parameters, globals ...) + * @return the variables from outside + */ + public List getOutsideVariable() { + return new ArrayList(1); + } + + /** + * get the modified variables. + * @return the variables from we change value + */ + public List getModifiedVariable() { + return new ArrayList(1); + } + + /** + * Get the variables used. + * @return the variables used + */ + public List getUsedVariable() { + return new ArrayList(1); + } }