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;
28 /** The parent of the object. */
31 /** The outlineable children (those will be in the node array too. */
32 private ArrayList children = new ArrayList();
34 private Position position;
36 * Create the PHPDocument.
37 * @param parent the parent object (it should be null isn't it ?)
39 public PHPDocument(final Object parent,
43 position = new Position(1,name.length);
47 * Return the php document as String.
48 * @return a string representation of the object.
50 public String toString() {
51 final StringBuffer buff = new StringBuffer();
55 for (i = 0; i < nodes.length; i++) {
60 buff.append(node.toString(0));
61 if (node instanceof HTMLCode) {
62 buff.append("\n");//$NON-NLS-1$
64 buff.append(";\n");//$NON-NLS-1$
68 return buff.toString();
72 * Add an outlineable object.
73 * @param o the new outlineable
74 * @return does the addition worked ?
76 public boolean add(final Outlineable o) {
77 return children.add(o);
81 * Return the outlineable at the index.
82 * @param index the index
83 * @return an outlineable object
85 public Outlineable get(final int index) {
86 return (Outlineable) children.get(index);
90 * The number of outlineable children.
91 * @return the number of children that are outlineable
94 return children.size();
98 * This will return the image for the outline of the object.
101 public ImageDescriptor getImage() {
102 return PHPUiImages.DESC_CLASS;
106 * Get the parent of the object.
107 * @return the parent of the object
109 public Object getParent() {
113 public Position getPosition() {
117 public List getList() {