From: kpouer Date: Thu, 1 May 2003 13:16:05 +0000 (+0000) Subject: Two interfaces added for outlineable objects X-Git-Url: http://git.phpeclipse.com Two interfaces added for outlineable objects --- diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Outlineable.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Outlineable.java new file mode 100644 index 0000000..564209f --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Outlineable.java @@ -0,0 +1,18 @@ +package net.sourceforge.phpdt.internal.compiler.parser; + +import org.eclipse.jface.resource.ImageDescriptor; + +/** + * Here is an interface that object that can be in the outline view must implement. + * @author Matthieu Casanova + */ +public interface Outlineable { + + /** + * This will return the image for the outline of the object. + * @return an image + */ + ImageDescriptor getImage(); + + Object getParent(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/OutlineableWithChildren.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/OutlineableWithChildren.java new file mode 100644 index 0000000..430a136 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/OutlineableWithChildren.java @@ -0,0 +1,13 @@ +package net.sourceforge.phpdt.internal.compiler.parser; + +/** + * The interface that will describe an object that can have children + * @author Matthieu Casanova + */ +public interface OutlineableWithChildren extends Outlineable { + boolean add(Outlineable o); + + Outlineable get(int index); + + int size(); +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java index bc3c567..a36a277 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPOutlineInfo.java @@ -1,5 +1,7 @@ package net.sourceforge.phpdt.internal.compiler.parser; +import net.sourceforge.phpdt.internal.compiler.ast.PHPDocument; + import java.util.TreeSet; /** @@ -8,18 +10,23 @@ import java.util.TreeSet; */ public class PHPOutlineInfo { TreeSet fVariables; - PHPSegmentWithChildren fDeclarations; + OutlineableWithChildren fDeclarations; public PHPOutlineInfo(Object parent) { fVariables = new TreeSet(); fDeclarations = new PHPClassDeclaration(parent, "_root", 1); } + public PHPOutlineInfo(Object parent, OutlineableWithChildren phpDocument) { + fVariables = new TreeSet(); + fDeclarations = phpDocument; + } + public TreeSet getVariables() { return fVariables; } - public PHPSegmentWithChildren getDeclarations() { + public OutlineableWithChildren getDeclarations() { return fDeclarations; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java index 98efdfa..16da5e5 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegment.java @@ -1,13 +1,12 @@ package net.sourceforge.phpdt.internal.compiler.parser; -import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; /** * * @author khartlage */ -public abstract class PHPSegment { +public abstract class PHPSegment implements Outlineable { protected String name; private Position position; private Object parent; @@ -38,5 +37,4 @@ public abstract class PHPSegment { return parent; } - public abstract ImageDescriptor getImage(); }; \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java index 4b1cb81..172b90d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/PHPSegmentWithChildren.java @@ -7,7 +7,7 @@ import java.util.List; * An abstract PHPSegment that can have children. * @author khartlage, Matthieu Casanova */ -public abstract class PHPSegmentWithChildren extends PHPSegment { +public abstract class PHPSegmentWithChildren extends PHPSegment implements OutlineableWithChildren { private ArrayList children; /** @@ -31,7 +31,7 @@ public abstract class PHPSegmentWithChildren extends PHPSegment { * @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) { + public boolean add(Outlineable o) { return children.add(o); } @@ -43,8 +43,8 @@ public abstract class PHPSegmentWithChildren extends PHPSegment { * @throws java.lang.IndexOutOfBoundsException if index is out of range (index * < 0 || index >= size()). */ - public PHPSegment get(int index) { - return (PHPSegment) children.get(index); + public Outlineable get(int index) { + return (Outlineable) children.get(index); } /** diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index 11b48d9..e3d3672 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -152,7 +152,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { this.initializeScanner(); } /** - * Class Constructor. + * ClassDeclaration Constructor. * *@param s *@param sess Description of Parameter @@ -1418,7 +1418,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { private void parseDeclarations( PHPOutlineInfo outlineInfo, - PHPSegmentWithChildren current, + OutlineableWithChildren current, boolean goBack) { char[] ident; // PHPClassDeclaration current = (PHPClassDeclaration) stack.peek(); @@ -1976,7 +1976,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { if (token == TokenNameIdentifier) { getNextToken(); } else { - throwSyntaxError("Class name expected after keyword 'extends'."); + throwSyntaxError("ClassDeclaration name expected after keyword 'extends'."); } } } else { @@ -1984,7 +1984,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { throwSyntaxError( "Don't use keyword for class declaration [" + token + "]."); } - throwSyntaxError("Class name expected after keyword 'class'."); + throwSyntaxError("ClassDeclaration name expected after keyword 'class'."); } }