1 package net.sourceforge.phpdt.internal.compiler.ast;
3 import java.util.ArrayList;
6 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
7 import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
8 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
10 import org.eclipse.jface.resource.ImageDescriptor;
11 import org.eclipse.jface.text.Position;
14 * It's a php document.
15 * This class is an outlineable object
16 * It will contains html and php
17 * @author Matthieu Casanova
19 public class PHPDocument implements OutlineableWithChildren {
23 * It will include html nodes or php nodes
25 public AstNode[] nodes;
29 /** The parent of the object. */
32 /** The outlineable children (those will be in the node array too. */
33 private ArrayList children = new ArrayList();
35 private Position position;
37 * Create the PHPDocument.
38 * @param parent the parent object (it should be null isn't it ?)
40 public PHPDocument(final Object parent,
44 position = new Position(1,name.length);
48 * Return the php document as String.
49 * @return a string representation of the object.
51 public String toString() {
52 final StringBuffer buff = new StringBuffer();
56 for (i = 0; i < nodes.length; i++) {
61 buff.append(node.toString(0));
62 if (node instanceof HTMLCode) {
63 buff.append("\n");//$NON-NLS-1$
65 buff.append(";\n");//$NON-NLS-1$
69 return buff.toString();
73 * Add an outlineable object.
74 * @param o the new outlineable
75 * @return does the addition worked ?
77 public boolean add(final Outlineable o) {
78 return children.add(o);
82 * Return the outlineable at the index.
83 * @param index the index
84 * @return an outlineable object
86 public Outlineable get(final int index) {
87 return (Outlineable) children.get(index);
91 * The number of outlineable children.
92 * @return the number of children that are outlineable
95 return children.size();
99 * This will return the image for the outline of the object.
102 public ImageDescriptor getImage() {
103 return PHPUiImages.DESC_CLASS;
107 * Get the parent of the object.
108 * @return the parent of the object
110 public Object getParent() {
114 public Position getPosition() {
118 public List getList() {