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;
10 import java.util.List;
13 * It's a php document.
14 * This class is an outlineable object
15 * It will contains html and php
16 * @author Matthieu Casanova
18 public class PHPDocument implements OutlineableWithChildren {
22 * It will include html nodes or php nodes
24 public AstNode[] nodes;
27 /** The parent of the object. */
30 /** The outlineable children (those will be in the node array too. */
31 private ArrayList children = new ArrayList();
33 private Position position;
35 * Create the PHPDocument.
36 * @param parent the parent object (it should be null isn't it ?)
38 public PHPDocument(Object parent, char[] name) {
41 position = new Position(1,name.length);
45 * Return the php document as String.
46 * @return a string representation of the object.
48 public String toString() {
49 final StringBuffer buff = new StringBuffer();
53 for (i = 0; i < nodes.length; i++) {
58 buff.append(node.toString(0));
61 return buff.toString();
65 * Add an outlineable object.
66 * @param o the new outlineable
67 * @return does the addition worked ?
69 public boolean add(Outlineable o) {
70 return children.add(o);
74 * Return the outlineable at the index.
75 * @param index the index
76 * @return an outlineable object
78 public Outlineable get(int index) {
79 return (Outlineable) children.get(index);
83 * The number of outlineable children.
84 * @return the number of children that are outlineable
87 return children.size();
91 * This will return the image for the outline of the object.
94 public ImageDescriptor getImage() {
95 return PHPUiImages.DESC_CLASS;
99 * Get the parent of the object.
100 * @return the parent of the object
102 public Object getParent() {
106 public Position getPosition() {
110 public List getList() {