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();
47 for (i = 0; i < nodes.length; i++) {
52 buff.append(node.toString(0));
55 return buff.toString();
59 * Add an outlineable object.
60 * @param o the new outlineable
61 * @return does the addition worked ?
63 public boolean add(Outlineable o) {
64 return children.add(o);
68 * Return the outlineable at the index.
69 * @param index the index
70 * @return an outlineable object
72 public Outlineable get(int index) {
73 return (Outlineable) children.get(index);
77 * The number of outlineable children.
78 * @return the number of children that are outlineable
81 return children.size();
85 * This will return the image for the outline of the object.
88 public ImageDescriptor getImage() {
89 return PHPUiImages.DESC_CLASS;
93 * Get the parent of the object.
94 * @return the parent of the object
96 public Object getParent() {