+++ /dev/null
-package net.sourceforge.phpdt.internal.compiler.ast;
-
-/**
- * This class is my Class declaration for php.
- * It is similar to org.eclipse.jdt.internal.compiler.ast.TypeDeclaration
- * It directly extends AstNode because a class cannot appear anywhere in php
- * @author Matthieu Casanova
- */
-public class Class extends AstNode {
-
- /** The name of the class. */
- public char[] name;
- /** The superclass. */
- public char[] superclass;
- /** The fields of the class. */
- public VariableDeclaration[] fields;
-
- public int declarationSourceStart;
- public int declarationSourceEnd;
- public int bodyStart;
- public int bodyEnd;
- /** The methods of the class. */
- public MethodDeclaration[] methods;
- /** The constructor of the class. */
- public MethodDeclaration constructor;
-
- /**
- * Tell if the class has a constructor.
- * @return a boolean
- */
- public boolean hasConstructor() {
- return constructor != null;
- }
-
- /**
- * Return the class as String.
- * @param tab how many tabs before the class
- * @return the code of this class into String
- */
- public String toString(int tab) {
- return tabString(tab) + toStringHeader() + toStringBody(tab);
- }
-
- /**
- * 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) {
- final StringBuffer buff = new StringBuffer(" {");//$NON-NLS-1$
- if (fields != null) {
- for (int fieldI = 0; fieldI < fields.length; fieldI++) {
- if (fields[fieldI] != null) {
- buff.append("\n"); //$NON-NLS-1$
- buff.append(fields[fieldI].toString(tab + 1));
- buff.append(";");//$NON-NLS-1$
- }
- }
- }
- if (methods != null) {
- for (int i = 0; i < methods.length; i++) {
- if (methods[i] != null) {
- buff.append("\n");//$NON-NLS-1$
- buff.append(methods[i].toString(tab + 1));
- }
- }
- }
- buff.append("\n").append(tabString(tab)).append("}"); //$NON-NLS-2$ //$NON-NLS-1$
- return buff.toString();
- }
-
- /**
- * Return the header of the class as String.
- * @return the header of the class
- */
- public String toStringHeader() {
- final StringBuffer buff = new StringBuffer("class").append(name);//$NON-NLS-1$
- if (superclass != null) {
- buff.append(" extends "); //$NON-NLS-1$
- buff.append(superclass);
- }
- return buff.toString();
- }
-}