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;
7 import org.eclipse.jface.text.Position;
9 import java.util.ArrayList;
12 * It's a php document.
13 * This class is an outlineable object
14 * It will contains html and php
15 * @author Matthieu Casanova
17 public class PHPDocument implements OutlineableWithChildren {
21 * It will include html nodes or php nodes
23 public AstNode[] nodes;
25 /** The parent of the object. */
28 /** The outlineable children (those will be in the node array too. */
29 private ArrayList children = new ArrayList();
32 * Create the PHPDocument.
33 * @param parent the parent object (it should be null isn't it ?)
35 public PHPDocument(Object parent) {
40 * Return the php document as String.
41 * @return a string representation of the object.
43 public String toString() {
44 final StringBuffer buff = new StringBuffer();
48 for (i = 0; i < nodes.length; i++) {
53 buff.append(node.toString(0));
56 return buff.toString();
60 * Add an outlineable object.
61 * @param o the new outlineable
62 * @return does the addition worked ?
64 public boolean add(Outlineable o) {
65 return children.add(o);
69 * Return the outlineable at the index.
70 * @param index the index
71 * @return an outlineable object
73 public Outlineable get(int index) {
74 return (Outlineable) children.get(index);
78 * The number of outlineable children.
79 * @return the number of children that are outlineable
82 return children.size();
86 * This will return the image for the outline of the object.
89 public ImageDescriptor getImage() {
90 return PHPUiImages.DESC_CLASS;
94 * Get the parent of the object.
95 * @return the parent of the object
97 public Object getParent() {
101 public Position getPosition() {