From 40b9a3dcdde67b29099fd3efa4ae504a0e3dc9f7 Mon Sep 17 00:00:00 2001 From: kpouer Date: Fri, 6 Jun 2003 12:39:26 +0000 Subject: [PATCH] *** empty log message *** --- .../internal/compiler/ast/ClassDeclaration.java | 7 ++++++ .../internal/compiler/ast/EmptyStatement.java | 2 +- .../internal/compiler/ast/FieldDeclaration.java | 7 ++++++ .../internal/compiler/ast/GlobalStatement.java | 8 +++++++ .../internal/compiler/ast/InclusionStatement.java | 7 ++++++ .../internal/compiler/ast/MethodDeclaration.java | 8 +++++++ .../phpdt/internal/compiler/ast/PHPDocument.java | 6 +++++ .../internal/compiler/ast/VariableDeclaration.java | 22 ++++++++++++------- .../internal/compiler/parser/Outlineable.java | 3 ++ .../phpeditor/PHPContentOutlinePage.java | 2 +- net.sourceforge.phpeclipse/src/test/PHPParser.java | 6 ++-- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 6 ++-- 12 files changed, 68 insertions(+), 16 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java index 91378a0..18f52c1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ClassDeclaration.java @@ -5,6 +5,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; import java.util.ArrayList; @@ -37,6 +38,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr /** The outlineable children (those will be in the node array too. */ private ArrayList children = new ArrayList(); + private Position position; /** * Create a class giving starting and ending offset * @param sourceStart starting offset @@ -51,6 +53,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr this.parent = parent; this.name = name; this.superclass = superclass; + position = new Position(sourceStart, name.length); } /** @@ -165,4 +168,8 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr public String toString() { return toStringHeader(); } + + public Position getPosition() { + return position; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java index 1bb0236..780c841 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/EmptyStatement.java @@ -1,7 +1,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** - * An empty statement + * An empty statement. * @author Matthieu Casanova */ public class EmptyStatement extends Statement { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java index c8647f9..69b3616 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/FieldDeclaration.java @@ -3,6 +3,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; /** * A Field declaration. @@ -18,6 +19,7 @@ public class FieldDeclaration extends Statement implements Outlineable { public VariableDeclaration[] vars; private Object parent; + private Position position; /** * Create a new field. * @param vars the array of variables. @@ -28,6 +30,7 @@ public class FieldDeclaration extends Statement implements Outlineable { super(sourceStart, sourceEnd); this.vars = vars; this.parent = parent; + position = new Position(sourceStart, sourceEnd); } /** @@ -59,4 +62,8 @@ public class FieldDeclaration extends Statement implements Outlineable { public Object getParent() { return parent; } + + public Position getPosition() { + return position; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java index 8d17144..6bb61fe 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/GlobalStatement.java @@ -3,6 +3,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; /** * A GlobalStatement statement in php. @@ -15,10 +16,13 @@ public class GlobalStatement extends Statement implements Outlineable { private Object parent; + private Position position; + public GlobalStatement(Object parent, String[] variables, int sourceStart, int sourceEnd) { super(sourceStart, sourceEnd); this.variables = variables; this.parent = parent; + position = new Position(sourceStart, sourceEnd); } public String toString() { @@ -47,4 +51,8 @@ public class GlobalStatement extends Statement implements Outlineable { public Object getParent() { return parent; } + + public Position getPosition() { + return position; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java index 0f18233..3a403a2 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/InclusionStatement.java @@ -3,6 +3,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; /** * @author Matthieu Casanova @@ -20,6 +21,7 @@ public class InclusionStatement extends Statement implements Outlineable { private Object parent; + private Position position; public InclusionStatement(Object parent, int keyword, Expression expression, @@ -28,6 +30,7 @@ public class InclusionStatement extends Statement implements Outlineable { this.keyword = keyword; this.expression = expression; this.parent = parent; + position = new Position(sourceStart, sourceEnd); } public String keywordToString() { @@ -77,4 +80,8 @@ public class InclusionStatement extends Statement implements Outlineable { public Object getParent() { return parent; } + + public Position getPosition() { + return position; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java index d0ac842..e08010d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/MethodDeclaration.java @@ -4,6 +4,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; import java.util.Hashtable; import java.util.Enumeration; @@ -34,6 +35,8 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild /** Tell if the method returns a reference. */ public boolean reference; + private Position position; + public MethodDeclaration(Object parent, char[] name, Hashtable arguments, @@ -45,6 +48,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild this.arguments = arguments; this.parent = parent; this.reference = reference; + position = new Position(sourceStart, sourceEnd); } /** @@ -133,4 +137,8 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild public String toString() { return toStringHeader(); } + + public Position getPosition() { + return position; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java index fa460f5..b2f523d 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/PHPDocument.java @@ -4,6 +4,7 @@ import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; import java.util.ArrayList; @@ -96,4 +97,9 @@ public class PHPDocument implements OutlineableWithChildren { public Object getParent() { return parent; } + + public Position getPosition() { + //todo : check this + return null; + } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java index 17a6e39..6d01007 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java @@ -3,6 +3,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; /** * A variable declaration. @@ -15,7 +16,7 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements private Object parent; private boolean reference; - + private Position position; /** * Create a variable. * @param initialization the initialization @@ -29,6 +30,7 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements super(name, sourceStart, initialization.sourceEnd); this.initialization = initialization; this.parent = parent; + position = new Position(sourceStart, sourceEnd); } /** @@ -94,11 +96,15 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements return parent; } - /** - * Get the image of a variable. - * @return the image that represents a php variable - */ - public ImageDescriptor getImage() { - return PHPUiImages.DESC_VAR; - } + /** + * Get the image of a variable. + * @return the image that represents a php variable + */ + public ImageDescriptor getImage() { + return PHPUiImages.DESC_VAR; + } + + public Position getPosition() { + return position; + } } 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 index 564209f..90a5527 100644 --- 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 @@ -1,6 +1,7 @@ package net.sourceforge.phpdt.internal.compiler.parser; import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.text.Position; /** * Here is an interface that object that can be in the outline view must implement. @@ -15,4 +16,6 @@ public interface Outlineable { ImageDescriptor getImage(); Object getParent(); + + Position getPosition(); } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java index 1544023..ca2b95a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -280,7 +280,7 @@ public class PHPContentOutlinePage extends AbstractContentOutlinePage { if (selection.isEmpty()) fTextEditor.resetHighlightRange(); else { - PHPSegment segment = (PHPSegment) ((IStructuredSelection) selection).getFirstElement(); + Outlineable segment = (Outlineable) ((IStructuredSelection) selection).getFirstElement(); int start = segment.getPosition().getOffset(); int length = segment.getPosition().getLength(); try { diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 261d359..a25a5b4 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -145,8 +145,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon if (errorStart == -1) { setMarker(fileToParse, errorMessage, - jj_input_stream.tokenBegin, - jj_input_stream.tokenBegin + e.currentToken.image.length(), + SimpleCharStream.tokenBegin, + SimpleCharStream.tokenBegin + e.currentToken.image.length(), errorLevel, "Line " + e.currentToken.beginLine); } else { @@ -791,7 +791,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case DOLLAR: jj_consume_token(DOLLAR); expr = VariableName(); - {if (true) return expr;} + {if (true) return "$" + expr;} break; default: jj_la1[12] = jj_gen; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 34f35cc..baab0b4 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -166,8 +166,8 @@ public final class PHPParser extends PHPParserSuperclass { if (errorStart == -1) { setMarker(fileToParse, errorMessage, - jj_input_stream.tokenBegin, - jj_input_stream.tokenBegin + e.currentToken.image.length(), + SimpleCharStream.tokenBegin, + SimpleCharStream.tokenBegin + e.currentToken.image.length(), errorLevel, "Line " + e.currentToken.beginLine); } else { @@ -896,7 +896,7 @@ String Variable(): } | expr = VariableName() - {return expr;} + {return "$" + expr;} } String VariableName(): -- 1.7.1