From 34d208cbb2b05bf3756c04d42a265eeb5ffebb05 Mon Sep 17 00:00:00 2001 From: kpouer Date: Sat, 25 Jan 2003 15:55:11 +0000 Subject: [PATCH 1/1] Now PHPFunctionDeclaration can have children, and require are shown in the outline. I wrote something to get the expression in a field of the class, but it's not perfect so it would be better to change it (I didn't understood everything in PHPParser#expression() --- .../phpeclipse/phpeditor/phpparser/PHPParser.java | 29 +++++++++++++++++--- 1 files changed, 25 insertions(+), 4 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java index 110dd8f..81d8579 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpparser/PHPParser.java @@ -61,7 +61,11 @@ public class PHPParser extends PHPKeywords { Long longNumber; Double doubleNumber; - String stringValue; + private String stringValue; + + /** Contains the current expression. */ + private StringBuffer expression; + private boolean phpMode; final static int TT_EOF = 0; @@ -1767,9 +1771,9 @@ public class PHPParser extends PHPKeywords { return outlineInfo; } - private void parseDeclarations(PHPOutlineInfo outlineInfo, PHPClassDeclaration current, boolean goBack) { + private void parseDeclarations(PHPOutlineInfo outlineInfo, PHPSegmentWithChildren current, boolean goBack) { // PHPClassDeclaration current = (PHPClassDeclaration) stack.peek(); - PHPClassDeclaration temp; + PHPSegmentWithChildren temp; int counter = 0; String oldIdentifier; IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); @@ -1813,8 +1817,10 @@ public class PHPParser extends PHPKeywords { } if (token == TT_IDENTIFIER && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) { outlineInfo.addVariable(identifier); - current.add(new PHPFunctionDeclaration(current, identifier, chIndx - identifier.length())); + temp = new PHPFunctionDeclaration(current, identifier, chIndx - identifier.length()); + current.add(temp); getNextToken(); + parseDeclarations(outlineInfo, temp, true); } } else if (token == TT_class) { getNextToken(); @@ -1824,6 +1830,8 @@ public class PHPParser extends PHPKeywords { current.add(temp); // stack.push(temp); getNextToken(); + + //skip tokens for classname, extends and others until we have the opening '{' while (token != TT_LISTOPEN && token != TT_EOF && token != TT_UNDEFINED) { getNextToken(); } @@ -1839,6 +1847,11 @@ public class PHPParser extends PHPKeywords { if (counter == 0 && goBack) { return; } + } else if (token == TT_require || token == TT_require_once || token == TT_include || token == TT_include_once) { + expression(); + outlineInfo.addVariable(identifier); + current.add(new PHPReqIncDeclaration(current, identifier, chIndx - identifier.length(),expression.toString())); + getNextToken(); } else { getNextToken(); } @@ -2671,6 +2684,14 @@ public class PHPParser extends PHPKeywords { } private void expression() throws CoreException { + //todo: find a better way to get the expression + expression = new StringBuffer(); + for (int i = chIndx;i