From 6b0cae39d06ba87756a93ae9e68f75f25863ee6c Mon Sep 17 00:00:00 2001 From: kpouer Date: Sat, 25 Jan 2003 15:50:47 +0000 Subject: [PATCH] An abstract PHPSegment that describe a segment that can have children. It's the parent class of PHPClassDeclaration and PHPFunctionDeclaration (since a function can have an inner function or require for example) --- .../phpparser/PHPSegmentWithChildren.java | 58 ++++++++++++++++++++ 1 files changed, 58 insertions(+), 0 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegmentWithChildren.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegmentWithChildren.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegmentWithChildren.java new file mode 100644 index 0000000..a7b4526 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPSegmentWithChildren.java @@ -0,0 +1,58 @@ +package net.sourceforge.phpeclipse.phpeditor.phpparser; + +import java.util.List; +import java.util.ArrayList; + +/** + * An abstract PHPSegment that can have children. + * @author khartlage, Matthieu Casanova + */ +public abstract class PHPSegmentWithChildren extends PHPSegment { + private ArrayList children; + + /** + * Create a PHPSegment that can have children (class or functions). + * @param parent the parent object (it should be a php class) + * @param name the name of the function + * @param index where the function is in the file + */ + public PHPSegmentWithChildren(Object parent, String name, int index) { + super(parent, name, index); + children = new ArrayList(); + } + + public List getList( ) { + return children; + } + + /** + * Appends the specified PHPSegment declaration + * + * @param o function declaration to be appended to this list. + * @return true (as per the general contract of Collection.add). + */ + public boolean add(PHPSegment o) { + return children.add(o); + } + + /** + * Returns the PHPSegment declaration at the specified position in this list. + * + * @param index index of function declaration to return. + * @return the function declaration at the specified position in this list. + * @throws java.lang.IndexOutOfBoundsException if index is out of range (index + * < 0 || index >= size()). + */ + public PHPSegment get(int index) { + return (PHPSegment) children.get(index); + } + + /** + * Returns the number of declarations in this list. + * + * @return the number of declarations in this list. + */ + public int size() { + return children.size(); + } +} -- 1.7.1