1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
4 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
5 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
6 import org.eclipse.jface.resource.ImageDescriptor;
8 import java.util.ArrayList;
11 * It's a php document.
12 * This class is an outlineable object
13 * It will contains html and php
14 * @author Matthieu Casanova
16 public class PHPDocument implements OutlineableWithChildren {
20 * It will include html nodes or php nodes
22 public AstNode[] nodes;
24 /** The parent of the object. */
27 /** The outlineable children (those will be in the node array too. */
28 private ArrayList children = new ArrayList();
31 * Create the PHPDocument.
32 * @param parent the parent object (it should be null isn't it ?)
34 public PHPDocument(Object parent) {
39 * Return the php document as String.
40 * @return a string representation of the object.
42 public String toString() {
43 final StringBuffer buff = new StringBuffer();
46 for (i = 0; i < nodes.length; i++) {
51 buff.append(node.toString(0));
53 return buff.toString();
57 * Add an outlineable object.
58 * @param o the new outlineable
59 * @return does the addition worked ?
61 public boolean add(Outlineable o) {
62 return children.add(o);
66 * Return the outlineable at the index.
67 * @param index the index
68 * @return an outlineable object
70 public Outlineable get(int index) {
71 return (Outlineable) children.get(index);
75 * The number of outlineable children.
76 * @return the number of children that are outlineable
79 return children.size();
83 * This will return the image for the outline of the object.
86 public ImageDescriptor getImage() {
87 return PHPUiImages.DESC_CLASS;
91 * Get the parent of the object.
92 * @return the parent of the object
94 public Object getParent() {