From 8ecc8d740cd70c3f3319e77cb39fbc4359631230 Mon Sep 17 00:00:00 2001 From: khartlage Date: Wed, 28 May 2003 15:49:17 +0000 Subject: [PATCH 01/16] fixed problem with TokenNameDOLLAR_LBRACE token in outlineinfo --- .../phpdt/internal/compiler/parser/Parser.java | 133 +++++--------------- 1 files changed, 30 insertions(+), 103 deletions(-) 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 e3d3672..8a5839f 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 @@ -185,12 +185,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { /** * Create marker for the parse error */ - private void setMarker( - String message, - int charStart, - int charEnd, - int errorLevel) - throws CoreException { + private void setMarker(String message, int charStart, int charEnd, int errorLevel) throws CoreException { setMarker(fileToParse, message, charStart, charEnd, errorLevel); } @@ -260,8 +255,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { int currentEndPosition = scanner.getCurrentTokenEndPosition(); int currentStartPosition = scanner.getCurrentTokenStartPosition(); - System.out.print( - currentStartPosition + "," + currentEndPosition + ": "); + System.out.print(currentStartPosition + "," + currentEndPosition + ": "); System.out.println(scanner.toStringAction(token)); } } catch (InvalidInputException e) { @@ -1252,10 +1246,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } if (token != TokenNameEOF) { if (token == TokenNameERROR) { - throwSyntaxError( - "Scanner error (Found unknown token: " - + scanner.toStringAction(token) - + ")"); + throwSyntaxError("Scanner error (Found unknown token: " + scanner.toStringAction(token) + ")"); } if (token == TokenNameRPAREN) { throwSyntaxError("Too many closing ')'; end-of-file not reached."); @@ -1285,11 +1276,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { throw err; } else { // setMarker(err.getMessage(), err.getLine(), ERROR); - setMarker( - err.getMessage(), - scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), - ERROR); + setMarker(err.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR); } // if an error occured, // try to find keywords 'class' or 'function' @@ -1331,10 +1318,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } if (token != TokenNameEOF) { if (token == TokenNameERROR) { - throwSyntaxError( - "Scanner error (Found unknown token: " - + scanner.toStringAction(token) - + ")"); + throwSyntaxError("Scanner error (Found unknown token: " + scanner.toStringAction(token) + ")"); } if (token == TokenNameRPAREN) { throwSyntaxError("Too many closing ')'; end-of-file not reached."); @@ -1361,11 +1345,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { return; } catch (SyntaxError sytaxErr1) { // setMarker(sytaxErr1.getMessage(), sytaxErr1.getLine(), ERROR); - setMarker( - sytaxErr1.getMessage(), - scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), - ERROR); + setMarker(sytaxErr1.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR); try { // if an error occured, // try to find keywords 'class' or 'function' @@ -1381,11 +1361,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } } catch (SyntaxError sytaxErr2) { // setMarker(sytaxErr2.getMessage(), sytaxErr2.getLine(), ERROR); - setMarker( - sytaxErr2.getMessage(), - scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), - ERROR); + setMarker(sytaxErr2.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR); return; } } @@ -1416,10 +1392,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { return outlineInfo; } - private void parseDeclarations( - PHPOutlineInfo outlineInfo, - OutlineableWithChildren current, - boolean goBack) { + private void parseDeclarations(PHPOutlineInfo outlineInfo, OutlineableWithChildren current, boolean goBack) { char[] ident; // PHPClassDeclaration current = (PHPClassDeclaration) stack.peek(); PHPSegmentWithChildren temp; @@ -1434,8 +1407,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { getNextToken(); } else if (token == TokenNamevar) { getNextToken(); - if (token == TokenNameVariable - && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_VAR)) { + if (token == TokenNameVariable && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_VAR)) { ident = scanner.getCurrentIdentifierSource(); //substring(1) added because PHPVarDeclaration doesn't need the $ anymore String variableName = new String(ident).substring(1); @@ -1462,10 +1434,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { scanner.getCurrentTokenStartPosition(), new String(ident))); break; case TokenNameDoubleLiteral : - current - .add(new PHPVarDeclaration( - current, - variableName + doubleNumber, + current.add(new PHPVarDeclaration(current, variableName + doubleNumber, // chIndx - ident.length, scanner.getCurrentTokenStartPosition(), new String(ident))); break; @@ -1506,8 +1475,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { if (token == TokenNameAND) { getNextToken(); } - if (token == TokenNameIdentifier - && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) { + if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_FUNC)) { ident = scanner.getCurrentIdentifierSource(); outlineInfo.addVariable(new String(ident)); temp = new PHPFunctionDeclaration(current, new String(ident), @@ -1519,8 +1487,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } } else if (token == TokenNameclass) { getNextToken(); - if (token == TokenNameIdentifier - && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_CLASS)) { + if (token == TokenNameIdentifier && store.getBoolean(PHPeclipsePlugin.PHP_OUTLINE_CLASS)) { ident = scanner.getCurrentIdentifierSource(); outlineInfo.addVariable(new String(ident)); temp = new PHPClassDeclaration(current, new String(ident), @@ -1531,15 +1498,13 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { getNextToken(); //skip tokens for classname, extends and others until we have the opening '{' - while (token != TokenNameLBRACE - && token != TokenNameEOF - && token != TokenNameERROR) { + while (token != TokenNameLBRACE && token != TokenNameEOF && token != TokenNameERROR) { getNextToken(); } parseDeclarations(outlineInfo, temp, true); // stack.pop(); } - } else if (token == TokenNameLBRACE) { + } else if ((token == TokenNameLBRACE) || (token == TokenNameDOLLAR_LBRACE)) { getNextToken(); counter++; } else if (token == TokenNameRBRACE) { @@ -1572,11 +1537,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } catch (SyntaxError sytaxErr) { try { // setMarker(sytaxErr.getMessage(), sytaxErr.getLine(), ERROR); - setMarker( - sytaxErr.getMessage(), - scanner.getCurrentTokenStartPosition(), - scanner.getCurrentTokenEndPosition(), - ERROR); + setMarker(sytaxErr.getMessage(), scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), ERROR); } catch (CoreException e) { } } @@ -1798,10 +1759,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { foreachStatement(); return; - } else if ( - token == TokenNamecontinue - || token == TokenNamebreak - || token == TokenNamereturn) { + } else if (token == TokenNamecontinue || token == TokenNamebreak || token == TokenNamereturn) { getNextToken(); if (token != TokenNameSEMICOLON) { expression(); @@ -1956,10 +1914,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { return; } else { if (token != TokenNameStopPHP && token != TokenNameEOF) { - throwSyntaxError( - "';' expected after expression (Found token: " - + scanner.toStringAction(token) - + ")"); + throwSyntaxError("';' expected after expression (Found token: " + scanner.toStringAction(token) + ")"); } getNextToken(); } @@ -1981,8 +1936,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } } else { if (token > TokenNameKEYWORD) { - throwSyntaxError( - "Don't use keyword for class declaration [" + token + "]."); + throwSyntaxError("Don't use keyword for class declaration [" + token + "]."); } throwSyntaxError("ClassDeclaration name expected after keyword 'class'."); } @@ -2077,8 +2031,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } } else { if (token > TokenNameKEYWORD) { - throwSyntaxError( - "Don't use keyword for function declaration [" + token + "]."); + throwSyntaxError("Don't use keyword for function declaration [" + token + "]."); } throwSyntaxError("Function name expected after keyword 'function'."); } @@ -2128,8 +2081,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { constant(); if (token == TokenNameCOLON) { getNextToken(); - if (token == TokenNamecase - || token == TokenNamedefault) { // empty case statement ? + if (token == TokenNamecase || token == TokenNamedefault) { // empty case statement ? continue; } statementList(); @@ -2141,9 +2093,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { // rowCount, // PHPParser.INFO); setMarker( - "':' expected after 'case' keyword (Found token: " - + scanner.toStringAction(token) - + ")", + "':' expected after 'case' keyword (Found token: " + scanner.toStringAction(token) + ")", scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), INFO); @@ -2153,10 +2103,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { } statementList(); } else { - throwSyntaxError( - "':' character after 'case' constant expected (Found token: " - + scanner.toStringAction(token) - + ")"); + throwSyntaxError("':' character after 'case' constant expected (Found token: " + scanner.toStringAction(token) + ")"); } } else { // TokenNamedefault getNextToken(); @@ -2531,10 +2478,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { getNextToken(); expression(); if (token != TokenNameRBRACE) { - throwSyntaxError( - "'}' expected after variable '" - + new String(ident) - + "' in variable-expression."); + throwSyntaxError("'}' expected after variable '" + new String(ident) + "' in variable-expression."); } getNextToken(); } else if (token == TokenNameLPAREN) { @@ -2542,10 +2486,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { if (token != TokenNameRPAREN) { expressionList(); if (token != TokenNameRPAREN) { - throwSyntaxError( - "')' expected after variable '" - + new String(ident) - + "' in postfix-expression."); + throwSyntaxError("')' expected after variable '" + new String(ident) + "' in postfix-expression."); } } getNextToken(); @@ -2675,9 +2616,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { // rowCount, // PHPParser.INFO); setMarker( - "Avoid using keyword '" - + new String(ident) - + "' as variable name.", + "Avoid using keyword '" + new String(ident) + "' as variable name.", scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(), INFO); @@ -2709,10 +2648,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { break; default : throwSyntaxError("Syntax error after '->' token."); - } while ( - token == TokenNameLBRACKET - || token == TokenNameLPAREN - || token == TokenNameLBRACE) { + } while (token == TokenNameLBRACKET || token == TokenNameLPAREN || token == TokenNameLBRACE) { if (token == TokenNameLBRACKET) { getNextToken(); expressionList(); @@ -2880,9 +2816,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { private void multiplicativeExpression() throws CoreException { do { assignExpression(); - if (token != TokenNameMULTIPLY - && token != TokenNameDIVIDE - && token != TokenNameREMAINDER) { + if (token != TokenNameMULTIPLY && token != TokenNameDIVIDE && token != TokenNameREMAINDER) { return; } getNextToken(); @@ -2922,10 +2856,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { private void relationalExpression() throws CoreException { do { shiftExpression(); - if (token != TokenNameLESS - && token != TokenNameGREATER - && token != TokenNameLESS_EQUAL - && token != TokenNameGREATER_EQUAL) { + if (token != TokenNameLESS && token != TokenNameGREATER && token != TokenNameLESS_EQUAL && token != TokenNameGREATER_EQUAL) { return; } getNextToken(); @@ -2935,8 +2866,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { private void identicalExpression() throws CoreException { do { relationalExpression(); - if (token != TokenNameEQUAL_EQUAL_EQUAL - && token != TokenNameNOT_EQUAL_EQUAL) { + if (token != TokenNameEQUAL_EQUAL_EQUAL && token != TokenNameNOT_EQUAL_EQUAL) { return; } getNextToken(); @@ -3150,10 +3080,7 @@ public class Parser extends PHPParserSuperclass implements ITerminalSymbols { if (token != TokenNameRPAREN) { expressionList(); if (token != TokenNameRPAREN) { - throwSyntaxError( - "')' expected after identifier '" - + new String(ident) - + "' in postfix-expression."); + throwSyntaxError("')' expected after identifier '" + new String(ident) + "' in postfix-expression."); } } getNextToken(); -- 1.7.1 From 9ca34f80d0a47652d7484bfd34dcb9d5ad482136 Mon Sep 17 00:00:00 2001 From: khartlage Date: Wed, 28 May 2003 22:31:09 +0000 Subject: [PATCH 02/16] added a php external tools launcher --- net.sourceforge.phpeclipse/plugin.xml | 10 +- .../internal/dialog/ExternalToolVariableForm.java | 2 +- .../phpdt/externaltools/variable/FileExpander.java | 34 ++ .../variable/LastPHPFileExpander.java | 34 -- .../externaltools/variable/LastPHPUrlExpander.java | 53 --- .../phpdt/externaltools/variable/UrlExpander.java | 51 +++ .../sourceforge/phpeclipse/views/PHPConsole.java | 412 +++++++++++--------- 7 files changed, 311 insertions(+), 285 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/FileExpander.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index c6dbf95..764b285 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -917,17 +917,17 @@ Temporarily replaced until errors can be ironed out... expanderClass="net.sourceforge.phpdt.externaltools.variable.WorkspaceExpander"> + expanderClass="net.sourceforge.phpdt.externaltools.variable.FileExpander"> + expanderClass="net.sourceforge.phpdt.externaltools.variable.UrlExpander"> diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java index 957ba84..e9965a9 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java @@ -32,7 +32,7 @@ import net.sourceforge.phpdt.externaltools.variable.IVariableComponent; * information. */ public class ExternalToolVariableForm { - private static final int VISIBLE_ITEM_COUNT = 6; + private static final int VISIBLE_ITEM_COUNT = 9; private String variableListLabelText; private ExternalToolVariable[] variables; diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/FileExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/FileExpander.java new file mode 100644 index 0000000..17779cb --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/FileExpander.java @@ -0,0 +1,34 @@ +package net.sourceforge.phpdt.externaltools.variable; + +import org.eclipse.core.runtime.IPath; + +/** + * Expands a variable into the last opened PHP file + *

+ * This class is not intended to be extended by clients. + *

+ */ +public class FileExpander extends ResourceExpander { //implements IVariableTextExpander { + + /** + * Create an instance + */ + public FileExpander() { + super(); + } + + /** + * Returns a string representation of the path to a file or directory + * for the given variable tag and value or null. + * + * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) + */ + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IPath path = getPath(varTag, varValue, context); + if (path != null) { + return path.toString(); + } + return ""; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java deleted file mode 100644 index 28c1f9b..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPFileExpander.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.sourceforge.phpdt.externaltools.variable; - -import org.eclipse.core.runtime.IPath; - -/** - * Expands a variable into the last opened PHP file - *

- * This class is not intended to be extended by clients. - *

- */ -public class LastPHPFileExpander extends ResourceExpander { //implements IVariableTextExpander { - - /** - * Create an instance - */ - public LastPHPFileExpander() { - super(); - } - - /** - * Returns a string representation of the path to a file or directory - * for the given variable tag and value or null. - * - * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) - */ - public String getText(String varTag, String varValue, ExpandVariableContext context) { - IPath path = getPath(varTag, varValue, context); - if (path != null) { - return path.toString(); - } - return null; - } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java deleted file mode 100644 index 0ee13f2..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/LastPHPUrlExpander.java +++ /dev/null @@ -1,53 +0,0 @@ -package net.sourceforge.phpdt.externaltools.variable; - -import net.sourceforge.phpeclipse.PHPeclipsePlugin; - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.jface.preference.IPreferenceStore; - -/** - * Expands a variable into the last opened PHP file - *

- * This class is not intended to be extended by clients. - *

- */ -public class LastPHPUrlExpander extends ResourceExpander { //implements IVariableTextExpander { - - /** - * Create an instance - */ - public LastPHPUrlExpander() { - super(); - } - - /** - * Returns a string representation of the path to a file or directory - * for the given variable tag and value or null. - * - * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) - */ - public String getText(String varTag, String varValue, ExpandVariableContext context) { - IPath path = getPath(varTag, varValue, context); - if (path != null) { - IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - String localhostURL = path.toString(); - String lowerCaseFileName = localhostURL.toLowerCase(); - // fileName = "http://localhost"+fileName.replaceAll("c:", ""); - String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); - documentRoot = documentRoot.replace('\\', '/'); - documentRoot = documentRoot.toLowerCase(); - - if (lowerCaseFileName.startsWith(documentRoot)) { - localhostURL = localhostURL.substring(documentRoot.length()); - } else { - return localhostURL; - } - - return store.getString(PHPeclipsePlugin.LOCALHOST_PREF) + localhostURL.replaceAll(documentRoot, ""); - - } - return null; - } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java new file mode 100644 index 0000000..737d557 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/externaltools/variable/UrlExpander.java @@ -0,0 +1,51 @@ +package net.sourceforge.phpdt.externaltools.variable; + +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.preference.IPreferenceStore; + +/** + * Expands a variable into the last opened PHP file + *

+ * This class is not intended to be extended by clients. + *

+ */ +public class UrlExpander extends ResourceExpander { //implements IVariableTextExpander { + + /** + * Create an instance + */ + public UrlExpander() { + super(); + } + + /** + * Returns a string representation of the path to a file or directory + * for the given variable tag and value or null. + * + * @see IVariableTextExpander#getText(String, String, ExpandVariableContext) + */ + public String getText(String varTag, String varValue, ExpandVariableContext context) { + IPath path = getPath(varTag, varValue, context); + if (path != null) { + IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String localhostURL = path.toString(); + String lowerCaseFileName = localhostURL.toLowerCase(); + // fileName = "http://localhost"+fileName.replaceAll("c:", ""); + String documentRoot = store.getString(PHPeclipsePlugin.DOCUMENTROOT_PREF); + documentRoot = documentRoot.replace('\\', '/'); + documentRoot = documentRoot.toLowerCase(); + + if (lowerCaseFileName.startsWith(documentRoot)) { + localhostURL = localhostURL.substring(documentRoot.length()); + localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL; + System.out.println(localhostURL); + // localhostURL = store.getString(PHPeclipsePlugin.LOCALHOST_PREF)+ localhostURL;// + localhostURL.replaceAll(documentRoot, ""); + } + return localhostURL; + } + return ""; + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/PHPConsole.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/PHPConsole.java index e3408c8..638ca71 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/PHPConsole.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/views/PHPConsole.java @@ -12,18 +12,15 @@ Contributors: Klaus Hartlage - www.eclipseproject.de **********************************************************************/ -import java.io.File; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; -import java.io.StreamTokenizer; -import java.io.StringReader; -import java.util.ArrayList; +import java.io.InputStreamReader; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import net.sourceforge.phpeclipse.actions.PHPActionMessages; -import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.jface.action.Action; @@ -32,32 +29,23 @@ import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.action.IToolBarManager; import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.action.Separator; -import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.Document; import org.eclipse.jface.text.TextViewer; import org.eclipse.swt.SWT; import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Menu; import org.eclipse.ui.IActionBars; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IFileEditorInput; import org.eclipse.ui.IWorkbenchActionConstants; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.part.ViewPart; -import org.eclipse.ui.texteditor.ITextEditor; /** * The PHPConsole is used to display the output if you start MySQL/Apache @@ -71,7 +59,10 @@ public class PHPConsole extends ViewPart { private TextViewer fViewer = null; private Document fDocument = null; private StyledText fStyledText; - private Combo fCommandCombo; + // private Combo fCommandCombo; +// private ProcessOutputWriter consoleOut; +// private ProcessOutputWriter consoleErr; + // private Action goAction; private Action cutAction = new Action() { @@ -110,22 +101,22 @@ public class PHPConsole extends ViewPart { * @see ViewPart#createPartControl */ public void createPartControl(Composite parent) { - Composite container = new Composite(parent, SWT.NULL); - // control = container; - GridLayout layout = new GridLayout(); - layout.marginWidth = 0; - layout.marginHeight = 0; - layout.verticalSpacing = 0; - container.setLayout(layout); - Composite navContainer = new Composite(container, SWT.NONE); - layout = new GridLayout(); - layout.numColumns = 2; - layout.marginHeight = 1; - navContainer.setLayout(layout); - createCommandBar(navContainer); - navContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - fViewer = new TextViewer(container, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); +// Composite container = new Composite(parent, SWT.NULL); +// // control = container; +// GridLayout layout = new GridLayout(); +// layout.marginWidth = 0; +// layout.marginHeight = 0; +// layout.verticalSpacing = 0; +// container.setLayout(layout); +// Composite navContainer = new Composite(container, SWT.NONE); +// layout = new GridLayout(); +// layout.numColumns = 2; +// layout.marginHeight = 1; +// navContainer.setLayout(layout); +// createCommandBar(navContainer); +// navContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + fViewer = new TextViewer(parent, SWT.WRAP | SWT.V_SCROLL | SWT.H_SCROLL); GridData viewerData = new GridData(GridData.FILL_BOTH); fViewer.getControl().setLayoutData(viewerData); fViewer.setEditable(false); @@ -150,164 +141,164 @@ public class PHPConsole extends ViewPart { // hookDoubleClickAction(); contributeToActionBars(); - appendOutputText("This is the PHP console.\n"); - appendOutputText("Type: \"php $f\" to run the current editor file.\n"); + // appendOutputText("This is the PHP console.\n"); + // appendOutputText("Type: \"php $f\" to run the current editor file.\n"); } private void createCommandBar(Composite parent) { - Label addressLabel = new Label(parent, SWT.NONE); - addressLabel.setText("Command:"); - - fCommandCombo = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER); - fCommandCombo.addModifyListener(new ModifyListener() { - public void modifyText(ModifyEvent e) { - String text = fCommandCombo.getText(); - // goAction.setEnabled(text.length() > 0); - } - }); - fCommandCombo.addSelectionListener(new SelectionListener() { - public void widgetSelected(SelectionEvent e) { - String text = fCommandCombo.getItem(fCommandCombo.getSelectionIndex()); - if (text.length() > 0) { - fCommandCombo.setText(text); - // executeCommand(text); - } - } - public void widgetDefaultSelected(SelectionEvent e) { - executeCommand(fCommandCombo.getText()); - } - }); +// Label addressLabel = new Label(parent, SWT.NONE); +// addressLabel.setText("Command:"); + + // fCommandCombo = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER); + // fCommandCombo.addModifyListener(new ModifyListener() { + // public void modifyText(ModifyEvent e) { + // String text = fCommandCombo.getText(); + // // goAction.setEnabled(text.length() > 0); + // } + // }); + // fCommandCombo.addSelectionListener(new SelectionListener() { + // public void widgetSelected(SelectionEvent e) { + // String text = fCommandCombo.getItem(fCommandCombo.getSelectionIndex()); + // if (text.length() > 0) { + // fCommandCombo.setText(text); + // // executeCommand(text); + // } + // } + // public void widgetDefaultSelected(SelectionEvent e) { + // executeCommand(fCommandCombo.getText()); + // } + // }); GridData gd = new GridData(GridData.FILL_HORIZONTAL); - fCommandCombo.setLayoutData(gd); - // ToolBar toolbar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL); - // toolBarManager = new ToolBarManager(toolbar); - // makeActions(); - // IToolBarManager localBar = - // getViewSite().getActionBars().getToolBarManager(); - // localBar.add(backwardAction); - // localBar.add(forwardAction); - } - - private void executeCommand(String command) { - command.trim(); - if (command.equals("")) { - fCommandCombo.forceFocus(); - return; - } - execute(command); - - fCommandCombo.forceFocus(); - // add to Combo history - String[] items = fCommandCombo.getItems(); - int loc = -1; - String normURL = command; - for (int i = 0; i < items.length; i++) { - String normItem = items[i]; - if (normURL.equals(normItem)) { - // match - loc = i; - break; - } - } - if (loc != -1) { - fCommandCombo.remove(loc); - } - fCommandCombo.add(command, 0); - if (fCommandCombo.getItemCount() > COMMAND_COMBO_SIZE) { - fCommandCombo.remove(fCommandCombo.getItemCount() - 1); - } - fCommandCombo.getParent().layout(true); + // fCommandCombo.setLayoutData(gd); } - private void execute(String command) { - ArrayList args = new ArrayList(); - - command = command.replace('\\', '§'); - - StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(command)); - tokenizer.resetSyntax(); - - tokenizer.whitespaceChars(0, ' '); - tokenizer.wordChars('!', 255); - - tokenizer.quoteChar('"'); - tokenizer.quoteChar('\''); - - int token; - try { - while ((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) { - if (token == StreamTokenizer.TT_WORD) { - args.add(tokenizer.sval); - } - } - } catch (IOException e) { - // - } - String arg = ""; - // replace variables in arguments - - IFile file = getFile(); - if (file != null) { - String fileLocation = file.getLocation().toString(); - for (int i = 0; i < args.size(); i++) { - arg = args.get(i).toString(); - if (arg.equals("$f")) { - //current php editor file - if (File.separatorChar == '\\') { - fileLocation = fileLocation.replace('/', '\\'); - } - args.set(i, fileLocation); - } - } - } - - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - - String arg0 = ""; - String temp; - StringBuffer commandBuffer = new StringBuffer(1024); - // Program.launch(command); - if (args.size() > 0) { - arg0 = (String) args.get(0); - arg0 = arg0.replace('§', '\\'); - args.remove(0); - if (arg0.equals("php")) { - temp = store.getString(PHPeclipsePlugin.PHP_RUN_PREF); - if (temp != null) { - arg0 = temp; - } - } - commandBuffer.append(arg0 + " "); - } - String[] stringArgs = new String[args.size()]; - for (int i = 0; i < args.size(); i++) { - arg = (String) args.get(i); - arg = arg.replace('§', '\\'); - stringArgs[i] = arg; - commandBuffer.append(arg + " "); - } - commandBuffer.append("\n"); - - try { - command = commandBuffer.toString(); - write(command); - Runtime runtime = Runtime.getRuntime(); - - // runs the command - Process process = runtime.exec(command); - - //process.waitFor(); - InputStream in = process.getInputStream(); - String output = getStringFromStream(in); - write(output); - in.close(); -// } catch (InterruptedException e) { -// write(e.toString()); - } catch (IOException e) { - write(e.toString()); - } - } + // private void executeCommand(String command) { + // command.trim(); + // if (command.equals("")) { + // fCommandCombo.forceFocus(); + // return; + // } + // execute(command); + // + // fCommandCombo.forceFocus(); + // // add to Combo history + // String[] items = fCommandCombo.getItems(); + // int loc = -1; + // String normURL = command; + // for (int i = 0; i < items.length; i++) { + // String normItem = items[i]; + // if (normURL.equals(normItem)) { + // // match + // loc = i; + // break; + // } + // } + // if (loc != -1) { + // fCommandCombo.remove(loc); + // } + // fCommandCombo.add(command, 0); + // if (fCommandCombo.getItemCount() > COMMAND_COMBO_SIZE) { + // fCommandCombo.remove(fCommandCombo.getItemCount() - 1); + // } + // fCommandCombo.getParent().layout(true); + // } + + // private void execute(String command) { + // + // ArrayList args = new ArrayList(); + // + // command = command.replace('\\', '§'); + // + // StreamTokenizer tokenizer = new StreamTokenizer(new StringReader(command)); + // tokenizer.resetSyntax(); + // + // tokenizer.whitespaceChars(0, ' '); + // tokenizer.wordChars('!', 255); + // + // tokenizer.quoteChar('"'); + // tokenizer.quoteChar('\''); + // + // int token; + // try { + // while ((token = tokenizer.nextToken()) != StreamTokenizer.TT_EOF) { + // if (token == StreamTokenizer.TT_WORD) { + // args.add(tokenizer.sval); + // } + // } + // } catch (IOException e) { + // // + // } + // String arg = ""; + // // replace variables in arguments + // + //// IFile file = getFile(); + // IFile file = PHPeclipsePlugin.getDefault().getLastEditorFile(); + // if (file != null) { + // String fileLocation = file.getLocation().toString(); + // for (int i = 0; i < args.size(); i++) { + // arg = args.get(i).toString(); + // if (arg.equals("$f")) { + // //current php editor file + // if (File.separatorChar == '\\') { + // fileLocation = fileLocation.replace('/', '\\'); + // } + // args.set(i, fileLocation); + // } + // } + // } + // + // final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + // + // String arg0 = ""; + // String temp; + // StringBuffer commandBuffer = new StringBuffer(1024); + // // Program.launch(command); + // if (args.size() > 0) { + // arg0 = (String) args.get(0); + // arg0 = arg0.replace('§', '\\'); + // args.remove(0); + // if (arg0.equals("php")) { + // temp = store.getString(PHPeclipsePlugin.PHP_RUN_PREF); + // if (temp != null) { + // arg0 = temp; + // } + // } + // commandBuffer.append(arg0 + " "); + // } + // String[] stringArgs = new String[args.size()]; + // for (int i = 0; i < args.size(); i++) { + // arg = (String) args.get(i); + // arg = arg.replace('§', '\\'); + // stringArgs[i] = arg; + // commandBuffer.append(arg + " "); + // } + // commandBuffer.append("\n"); + // + // try { + // command = commandBuffer.toString(); + // write(command+"\n"); + // Runtime runtime = Runtime.getRuntime(); + // + // // runs the command + // Process process = runtime.exec(command); + // + // consoleOut = new ProcessOutputWriter(process.getInputStream()); + // consoleOut.start(); + // consoleErr = new ProcessOutputWriter(process.getErrorStream()); + // consoleErr.start(); + // + // //process.waitFor(); + //// InputStream in = process.getInputStream(); + //// String output = getStringFromStream(in); + //// write(output); + //// in.close(); + //// } catch (InterruptedException e) { + //// write(e.toString()); + // } catch (IOException e) { + // write(e.toString()); + // } + // } private void hookContextMenu() { MenuManager menuMgr = new MenuManager("#PopupMenu"); @@ -352,7 +343,7 @@ public class PHPConsole extends ViewPart { * @see ViewPart#setFocus */ public void setFocus() { - fCommandCombo.forceFocus(); + // fCommandCombo.forceFocus(); } /** @@ -426,18 +417,55 @@ public class PHPConsole extends ViewPart { /** * Finds the file that's currently opened in the PHP Text Editor */ - protected IFile getFile() { - ITextEditor editor = PHPeclipsePlugin.getDefault().getTextEditor(); + // protected IFile getFile() { + // ITextEditor editor = PHPeclipsePlugin.getDefault().getLastEditorFile(); + // + // IEditorInput editorInput = null; + // if (editor != null) { + // editorInput = editor.getEditorInput(); + // } + // + // if (editorInput instanceof IFileEditorInput) + // return ((IFileEditorInput) editorInput).getFile(); + // + // // if nothing was found, which should never happen + // return null; + // } + + class ProcessOutputWriter extends Thread { + boolean fStreamClosed; + InputStream fInputStream; + + ProcessOutputWriter(InputStream inputStream) { + fInputStream = inputStream; + fStreamClosed = false; + } - IEditorInput editorInput = null; - if (editor != null) { - editorInput = editor.getEditorInput(); + public void closeStream() { + fStreamClosed = true; + try { + fInputStream.close(); + } catch (IOException io) { + } } - if (editorInput instanceof IFileEditorInput) - return ((IFileEditorInput) editorInput).getFile(); + public void run() { + try { + BufferedReader in = new BufferedReader(new InputStreamReader(fInputStream)); - // if nothing was found, which should never happen - return null; + String line; + while ((line = in.readLine()) != null) { + write(line); + } + in.close(); + } catch (Exception e) { + e.printStackTrace(System.out); + if (!fStreamClosed) { + // write("\nPHP Console Exception: "+ e.toString() ); + } + } finally { + } + } } + } -- 1.7.1 From 97b3569dc3699d0171b80abdb51511bf64d4f4f6 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sat, 31 May 2003 13:50:30 +0000 Subject: [PATCH 03/16] Use abstraction of PHPOutlinePage --- .../phpeditor/AbstractContentOutlinePage.java | 51 ++++++++++++++++++++ .../phpeditor/PHPContentOutlinePage.java | 51 +++++-------------- .../phpeclipse/phpeditor/PHPEditor.java | 7 +-- .../phpeditor/php/PHPCompletionProcessor.java | 15 ++++-- 4 files changed, 76 insertions(+), 48 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/AbstractContentOutlinePage.java diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/AbstractContentOutlinePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/AbstractContentOutlinePage.java new file mode 100644 index 0000000..726536a --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/AbstractContentOutlinePage.java @@ -0,0 +1,51 @@ +package net.sourceforge.phpeclipse.phpeditor; + +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ + +import org.eclipse.jface.viewers.TreeViewer; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.views.contentoutline.ContentOutlinePage; + +/** + * An abstraction of a content outline page + */ +public abstract class AbstractContentOutlinePage extends ContentOutlinePage { + + protected Object fInput; + /** + * Sets the input of the outline page + */ + public void setInput(Object input) { + fInput = input; + update(); + } + + /** + * Updates the outline page. + */ + public void update() { + TreeViewer viewer = getTreeViewer(); + + if (viewer != null) { + Control control = viewer.getControl(); + if (control != null && !control.isDisposed()) { + control.setRedraw(false); + viewer.setInput(fInput); + viewer.expandAll(); + control.setRedraw(true); + } + } + } + + +} 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 78afe4e..1544023 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -18,7 +18,11 @@ import java.util.Comparator; import java.util.List; import java.util.TreeSet; -import net.sourceforge.phpdt.internal.compiler.parser.*; +import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; +import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; +import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo; +import net.sourceforge.phpdt.internal.compiler.parser.PHPSegment; +import net.sourceforge.phpdt.internal.compiler.parser.PHPSegmentWithChildren; import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; import net.sourceforge.phpeclipse.PHPeclipsePlugin; @@ -36,18 +40,17 @@ import org.eclipse.jface.viewers.TreeViewer; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditor; -import org.eclipse.ui.views.contentoutline.ContentOutlinePage; -import test.PHPParserSuperclass; + import test.PHPParserManager; +import test.PHPParserSuperclass; /** * A content outline page which always represents the functions of the * connected PHPEditor. */ -public class PHPContentOutlinePage extends ContentOutlinePage { +public class PHPContentOutlinePage extends AbstractContentOutlinePage { private static final String ERROR = "error"; //$NON-NLS-1$ private static final String WARNING = "warning"; //$NON-NLS-1$ @@ -230,18 +233,17 @@ public class PHPContentOutlinePage extends ContentOutlinePage { } } - protected Object fInput; protected IDocumentProvider fDocumentProvider; protected ITextEditor fTextEditor; protected PHPEditor fEditor; - protected ContentProvider contentProvider; + protected ContentProvider fContentProvider; /** * Creates a content outline page using the given provider and the given editor. */ public PHPContentOutlinePage(IDocumentProvider provider, ITextEditor editor) { super(); - contentProvider = null; + fContentProvider = null; fDocumentProvider = provider; fTextEditor = editor; if (editor instanceof PHPEditor) @@ -257,8 +259,8 @@ public class PHPContentOutlinePage extends ContentOutlinePage { TreeViewer viewer = getTreeViewer(); - contentProvider = new ContentProvider(); - viewer.setContentProvider(contentProvider); + fContentProvider = new ContentProvider(); + viewer.setContentProvider(fContentProvider); viewer.setLabelProvider(new OutlineLabelProvider()); viewer.addSelectionChangedListener(this); @@ -288,35 +290,10 @@ public class PHPContentOutlinePage extends ContentOutlinePage { } } } - - /** - * Sets the input of the outline page - */ - public void setInput(Object input) { - fInput = input; - update(); - } - - /** - * Updates the outline page. - */ - public void update() { - TreeViewer viewer = getTreeViewer(); - - if (viewer != null) { - Control control = viewer.getControl(); - if (control != null && !control.isDisposed()) { - control.setRedraw(false); - viewer.setInput(fInput); - viewer.expandAll(); - control.setRedraw(true); - } - } - } public Object[] getVariables() { - if (contentProvider != null) { - return contentProvider.getVariables(); + if (fContentProvider != null) { + return fContentProvider.getVariables(); } return null; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java index 701ebf9..b61c156 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java @@ -65,9 +65,6 @@ import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IViewPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.PartInitException; import org.eclipse.ui.actions.ActionContext; import org.eclipse.ui.actions.ActionGroup; import org.eclipse.ui.texteditor.ContentAssistAction; @@ -92,7 +89,7 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide // protected PHPActionGroup fActionGroups; /** The outline page */ - private PHPContentOutlinePage fOutlinePage; + private AbstractContentOutlinePage fOutlinePage; // protected PHPSyntaxParserThread fValidationThread = null; @@ -216,7 +213,7 @@ public class PHPEditor extends StatusTextEditor implements IViewPartInputProvide return fActionGroups; } - public PHPContentOutlinePage getfOutlinePage() { + public AbstractContentOutlinePage getfOutlinePage() { return fOutlinePage; } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java index 64fcaff..dee6cca 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java @@ -23,6 +23,7 @@ import net.sourceforge.phpdt.internal.ui.text.template.BuiltInEngine; import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine; import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine; import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.phpeditor.AbstractContentOutlinePage; import net.sourceforge.phpeclipse.phpeditor.PHPContentOutlinePage; import net.sourceforge.phpeclipse.phpeditor.PHPEditor; @@ -249,7 +250,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { fComparator = new PHPCompletionProposalComparator(); } - + /** * Tells this processor to order the proposals alphabetically. * @@ -258,7 +259,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { public void orderProposalsAlphabetically(boolean order) { fComparator.setOrderAlphabetically(order); } - + /** * Sets this processor's set of characters triggering the activation of the * completion proposal computation. @@ -266,7 +267,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { * @param activationSet the activation set */ public void setCompletionProposalAutoActivationCharacters(char[] activationSet) { - fProposalAutoActivationSet= activationSet; + fProposalAutoActivationSet = activationSet; } /* (non-Javadoc) * Method declared on IContentAssistProcessor @@ -308,13 +309,15 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { if (offset > 0) { PHPEditor editor = null; - PHPContentOutlinePage outlinePage = null; + AbstractContentOutlinePage outlinePage = null; IEditorPart targetEditor = PHPeclipsePlugin.getActiveWorkbenchWindow().getActivePage().getActiveEditor(); if (targetEditor != null && (targetEditor instanceof PHPEditor)) { editor = (PHPEditor) targetEditor; outlinePage = editor.getfOutlinePage(); - identifiers = outlinePage.getVariables(); + if (outlinePage instanceof PHPContentOutlinePage) { + identifiers = ((PHPContentOutlinePage) outlinePage).getVariables(); + } } } @@ -463,7 +466,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor { */ public char[] getCompletionProposalAutoActivationCharacters() { return fProposalAutoActivationSet; -// return null; // new char[] { '$' }; + // return null; // new char[] { '$' }; } /* (non-Javadoc) -- 1.7.1 From 03ff1d926f2509231ebafbc97f2237a5ccce8b09 Mon Sep 17 00:00:00 2001 From: kpouer Date: Mon, 2 Jun 2003 15:58:15 +0000 Subject: [PATCH 04/16] bugfixes --- .../phpdt/internal/compiler/ast/Break.java | 2 +- .../phpdt/internal/compiler/ast/Case.java | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java index e7ef3ee..08b273b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Break.java @@ -12,7 +12,7 @@ public class Break extends BranchStatement { public String toString(int tab) { String s = tabString(tab); - if (expression == null) { + if (expression != null) { return s + "break " + expression.toString();//$NON-NLS-1$ } return s + "break";//$NON-NLS-1$ diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java index da70a1e..a66d3f1 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Case.java @@ -27,9 +27,11 @@ public class Case extends AbstractCase { buff.append("case "); buff.append(value.toStringExpression()); buff.append(" :\n"); - for (int i = 0; i < statements.length; i++) { - Statement statement = statements[i]; - buff.append(statement.toString(tab + 1)); + if (statements != null) { + for (int i = 0; i < statements.length; i++) { + Statement statement = statements[i]; + buff.append(statement.toString(tab + 1)); + } } return buff.toString(); } -- 1.7.1 From f0dee08ab9bb7e4fffcac08d459a470b564dc6ab Mon Sep 17 00:00:00 2001 From: kpouer Date: Thu, 5 Jun 2003 22:29:34 +0000 Subject: [PATCH 05/16] *** empty log message *** --- .../internal/compiler/ast/CastExpression.java | 2 +- .../internal/compiler/ast/ClassDeclaration.java | 8 +- .../internal/compiler/ast/FieldDeclaration.java | 22 +- .../internal/compiler/ast/InclusionStatement.java | 6 + .../internal/compiler/ast/MethodDeclaration.java | 21 +- .../phpdt/internal/compiler/ast/PHPDocument.java | 14 +- .../internal/compiler/ast/VariableDeclaration.java | 4 +- .../internal/compiler/parser/PHPOutlineInfo.java | 2 +- net.sourceforge.phpeclipse/src/test/PHPParser.java | 456 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 266 ++++++------ 10 files changed, 420 insertions(+), 381 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java index ec518ac..9c7da62 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/CastExpression.java @@ -33,7 +33,7 @@ public class CastExpression extends Expression { * @return the expression */ public String toStringExpression() { - final StringBuffer buff = new StringBuffer('('); + final StringBuffer buff = new StringBuffer("("); buff.append(type.toStringExpression()); buff.append(") "); buff.append(expression.toStringExpression()); 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 bbc9775..91378a0 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 @@ -7,7 +7,6 @@ import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.resource.ImageDescriptor; import java.util.ArrayList; -import java.util.Enumeration; /** @@ -70,7 +69,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr public void addMethod(MethodDeclaration method) { methods.add(method); - children.add(method); + add(method); if (method.name.equals(name)) { constructor = method; } @@ -159,6 +158,11 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr } public int size() { + PHPeclipsePlugin.log(1,"class size : "+children.size()); return children.size(); } + + public String toString() { + return toStringHeader(); + } } 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 c64ba6b..c8647f9 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 @@ -1,5 +1,9 @@ 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; + /** * A Field declaration. * This is a variable declaration for a php class @@ -8,20 +12,22 @@ package net.sourceforge.phpdt.internal.compiler.ast; * var $toto,$tata; * @author Matthieu Casanova */ -public class FieldDeclaration extends Statement { +public class FieldDeclaration extends Statement implements Outlineable { /** The variables. */ public VariableDeclaration[] vars; + private Object parent; /** * Create a new field. * @param vars the array of variables. * @param sourceStart the starting offset * @param sourceEnd the ending offset */ - public FieldDeclaration(VariableDeclaration[] vars, int sourceStart, int sourceEnd) { + public FieldDeclaration(VariableDeclaration[] vars, int sourceStart, int sourceEnd, Object parent) { super(sourceStart, sourceEnd); this.vars = vars; + this.parent = parent; } /** @@ -41,4 +47,16 @@ public class FieldDeclaration extends Statement { } return buff.toString(); } + + /** + * Get the image of a variable. + * @return the image that represents a php variable + */ + public ImageDescriptor getImage() { + return PHPUiImages.DESC_VAR; + } + + public Object getParent() { + return parent; + } } 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 9f03579..0f18233 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 @@ -51,6 +51,12 @@ public class InclusionStatement extends Statement implements Outlineable { */ public String toString(int tab) { final StringBuffer buffer = new StringBuffer(tabString(tab)); + buffer.append(toString()); + return buffer.toString(); + } + + public String toString() { + final StringBuffer buffer = new StringBuffer(); if (silent) { buffer.append('@'); } 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 af701a8..d0ac842 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 @@ -1,6 +1,5 @@ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.ast.Block; import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; @@ -26,10 +25,13 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild public int bodyEnd = -1; /** Tell if the method is a class constructor. */ public boolean isConstructor; + + /** The parent object. */ private Object parent; /** The outlineable children (those will be in the node array too. */ private ArrayList children = new ArrayList(); + /** Tell if the method returns a reference. */ public boolean reference; public MethodDeclaration(Object parent, @@ -52,6 +54,13 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild */ public String toString(int tab) { StringBuffer buff = new StringBuffer(tabString(tab)); + buff.append(toStringHeader()); + buff.append(toStringStatements(tab + 1)); + return buff.toString(); + } + + public String toStringHeader() { + StringBuffer buff = new StringBuffer(); buff.append("function ");//$NON-NLS-1$ if (reference) { buff.append('&');//$NON-NLS-1$ @@ -71,8 +80,6 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } } buff.append(")"); //$NON-NLS-1$ - - buff.append(toStringStatements(tab + 1)); return buff.toString(); } @@ -103,6 +110,10 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild return PHPUiImages.DESC_FUN; } + public void setParent(Object parent) { + this.parent = parent; + } + public Object getParent() { return parent; } @@ -118,4 +129,8 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild public int size() { return children.size(); } + + public String toString() { + return toStringHeader(); + } } 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 41200ae..fa460f5 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 @@ -42,13 +42,15 @@ public class PHPDocument implements OutlineableWithChildren { public String toString() { final StringBuffer buff = new StringBuffer(); AstNode node; - int i; - for (i = 0; i < nodes.length; i++) { - node = nodes[i]; - if (node == null) { - break; + if (nodes != null) { + int i; + for (i = 0; i < nodes.length; i++) { + node = nodes[i]; + if (node == null) { + break; + } + buff.append(node.toString(0)); } - buff.append(node.toString(0)); } return buff.toString(); } 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 2839776..17a6e39 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 @@ -1,7 +1,5 @@ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.ast.Expression; -import net.sourceforge.phpdt.internal.compiler.ast.AbstractVariableDeclaration; import net.sourceforge.phpdt.internal.compiler.parser.Outlineable; import net.sourceforge.phpdt.internal.ui.PHPUiImages; import org.eclipse.jface.resource.ImageDescriptor; @@ -82,7 +80,7 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements if (reference) { buff = new StringBuffer("&$"); //$NON-NLS-1$ } else { - buff = new StringBuffer('$');//$NON-NLS-1$ + buff = new StringBuffer("$");//$NON-NLS-1$ } buff.append(name); if (initialization != null) { 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 a36a277..95bd22b 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 @@ -30,7 +30,7 @@ public class PHPOutlineInfo { return fDeclarations; } - public boolean add(PHPFunctionDeclaration o) { + public boolean add(OutlineableWithChildren o) { return fDeclarations.add(o); } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 1573506..261d359 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -39,7 +39,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ static PHPOutlineInfo outlineInfo; - public static MethodDeclaration currentFunction; private static boolean assigning; /** The error level of the current ParseException. */ @@ -103,7 +102,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon public final PHPOutlineInfo parseInfo(final Object parent, final String s) { currentSegment = new PHPDocument(parent); - outlineInfo = new PHPOutlineInfo(parent); + outlineInfo = new PHPOutlineInfo(parent, currentSegment); final StringReader stream = new StringReader(s); if (jj_input_stream == null) { jj_input_stream = new SimpleCharStream(stream, 1, 1); @@ -115,7 +114,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon phpDocument = new PHPDocument(null); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - PHPeclipsePlugin.log(1,phpDocument.toString()); } catch (ParseException e) { processParseException(e); } @@ -131,7 +129,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon if (errorMessage == null) { PHPeclipsePlugin.log(e); errorMessage = "this exception wasn't handled by the parser please tell us how to reproduce it"; - errorStart = jj_input_stream.getPosition(); + errorStart = SimpleCharStream.getPosition(); errorEnd = errorStart + 1; } setMarker(e); @@ -359,7 +357,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon * or */ static final public void PhpBlock() throws ParseException { - final int start = jj_input_stream.getPosition(); + final int start = SimpleCharStream.getPosition(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PHPECHOSTART: phpEchoBlock(); @@ -421,7 +419,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon setMarker(fileToParse, "You should use '' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -539,13 +537,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon final int pos; jj_consume_token(CLASS); try { - pos = jj_input_stream.getPosition(); + pos = SimpleCharStream.getPosition(); className = jj_consume_token(IDENTIFIER); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -556,8 +554,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -630,6 +628,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case FUNCTION: method = MethodDeclaration(); + method.setParent(classDeclaration); classDeclaration.addMethod(method); break; case VAR: @@ -685,14 +684,15 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon arrayList.toArray(list); {if (true) return new FieldDeclaration(list, pos, - SimpleCharStream.getPosition());} + SimpleCharStream.getPosition(), + currentSegment);} throw new Error("Missing return statement in function"); } static final public VariableDeclaration VariableDeclarator() throws ParseException { final String varName; Expression initializer = null; - final int pos = jj_input_stream.getPosition(); + final int pos = SimpleCharStream.getPosition(); varName = VariableDeclaratorId(); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ASSIGN: @@ -702,8 +702,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "Literal expression expected in variable initializer"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } break; @@ -715,7 +715,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon {if (true) return new VariableDeclaration(currentSegment, varName.toCharArray(), pos, - jj_input_stream.getPosition());} + SimpleCharStream.getPosition());} } {if (true) return new VariableDeclaration(currentSegment, varName.toCharArray(), @@ -754,8 +754,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } throw new Error("Missing return statement in function"); @@ -811,9 +811,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_consume_token(LBRACE); expression = Expression(); jj_consume_token(RBRACE); - buff = new StringBuffer('{'); + buff = new StringBuffer("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); {if (true) return buff.toString();} break; case IDENTIFIER: @@ -1018,18 +1018,16 @@ Expression expr,expr2; if (errorMessage != null) {if (true) throw e;} errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } if (currentSegment != null) { currentSegment.add(functionDeclaration); currentSegment = functionDeclaration; } - currentFunction = functionDeclaration; block = Block(); functionDeclaration.statements = block.statements; - currentFunction = null; if (currentSegment != null) { currentSegment = (OutlineableWithChildren) currentSegment.getParent(); } @@ -1078,8 +1076,8 @@ Expression expr,expr2; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1112,8 +1110,8 @@ Expression expr,expr2; } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return parameters;} @@ -1277,8 +1275,8 @@ Expression expr,expr2; } errorMessage = "expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new VarAssignation(varName.toCharArray(), @@ -1582,8 +1580,8 @@ Expression expr,expr2; } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } expr = new BinaryExpression(expr,expr2,operator); @@ -1724,8 +1722,8 @@ Expression expr,expr2; if (errorMessage != null) {if (true) throw e;} errorMessage = "unexpected token '"+e.currentToken.next.image+"'"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } label_18: @@ -1960,8 +1958,8 @@ final int operator; } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return expr;} @@ -2236,8 +2234,8 @@ final int pos = SimpleCharStream.getPosition(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new ClassAccess(prefix, @@ -2327,8 +2325,8 @@ final int pos = SimpleCharStream.getPosition(); } catch (ParseException e) { errorMessage = "']' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());} @@ -2419,8 +2417,8 @@ Expression[] args = null; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return new FunctionCall(func,args,SimpleCharStream.getPosition());} @@ -2454,8 +2452,8 @@ final ArrayList list = new ArrayList(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } } @@ -2479,8 +2477,8 @@ final ArrayList list = new ArrayList(); if (e.currentToken.next.kind != 4) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } } @@ -2511,8 +2509,8 @@ final ArrayList list = new ArrayList(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } {if (true) return statement;} @@ -2684,8 +2682,8 @@ final ArrayList list = new ArrayList(); } catch (ParseException e) { errorMessage = "End of file unexpected, '' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -691,13 +689,13 @@ ClassDeclaration ClassDeclaration() : { try { - {pos = jj_input_stream.getPosition();} + {pos = SimpleCharStream.getPosition();} className = } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } [ @@ -707,8 +705,8 @@ ClassDeclaration ClassDeclaration() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ] @@ -768,7 +766,8 @@ void ClassBodyDeclaration(ClassDeclaration classDeclaration) : FieldDeclaration field; } { - method = MethodDeclaration() {classDeclaration.addMethod(method);} + method = MethodDeclaration() {method.setParent(classDeclaration); + classDeclaration.addMethod(method);} | field = FieldDeclaration() {classDeclaration.addVariable(field);} } @@ -806,14 +805,15 @@ FieldDeclaration FieldDeclaration() : arrayList.toArray(list); return new FieldDeclaration(list, pos, - SimpleCharStream.getPosition());} + SimpleCharStream.getPosition(), + currentSegment);} } VariableDeclaration VariableDeclarator() : { final String varName; Expression initializer = null; - final int pos = jj_input_stream.getPosition(); + final int pos = SimpleCharStream.getPosition(); } { varName = VariableDeclaratorId() @@ -824,8 +824,8 @@ VariableDeclaration VariableDeclarator() : } catch (ParseException e) { errorMessage = "Literal expression expected in variable initializer"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ] @@ -834,7 +834,7 @@ VariableDeclaration VariableDeclarator() : return new VariableDeclaration(currentSegment, varName.toCharArray(), pos, - jj_input_stream.getPosition()); + SimpleCharStream.getPosition()); } return new VariableDeclaration(currentSegment, varName.toCharArray(), @@ -869,8 +869,8 @@ String VariableDeclaratorId() : } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -908,9 +908,9 @@ String VariableName(): } { expression = Expression() - {buff = new StringBuffer('{'); + {buff = new StringBuffer("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); return buff.toString();} | token = [ expression = Expression() ] @@ -1016,8 +1016,8 @@ MethodDeclaration MethodDeclaration() : if (errorMessage != null) throw e; errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } { @@ -1025,12 +1025,10 @@ MethodDeclaration MethodDeclaration() : currentSegment.add(functionDeclaration); currentSegment = functionDeclaration; } - currentFunction = functionDeclaration; } block = Block() { functionDeclaration.statements = block.statements; - currentFunction = null; if (currentSegment != null) { currentSegment = (OutlineableWithChildren) currentSegment.getParent(); } @@ -1076,8 +1074,8 @@ Hashtable FormalParameters() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', '(' expected after function identifier"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } [ var = FormalParameter() @@ -1092,8 +1090,8 @@ Hashtable FormalParameters() : } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return parameters;} @@ -1183,8 +1181,8 @@ VarAssignation varAssignation() : } errorMessage = "expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new VarAssignation(varName.toCharArray(), @@ -1335,8 +1333,8 @@ Expression EqualityExpression() : } errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } { @@ -1409,8 +1407,8 @@ Expression MultiplicativeExpression() : if (errorMessage != null) throw e; errorMessage = "unexpected token '"+e.currentToken.next.image+"'"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ( @@ -1503,8 +1501,8 @@ Expression UnaryExpressionNotPlusMinus() : } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return expr;} @@ -1654,8 +1652,8 @@ AbstractSuffixExpression VariableSuffix(Expression prefix) : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function call or field access expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new ClassAccess(prefix, @@ -1668,8 +1666,8 @@ AbstractSuffixExpression VariableSuffix(Expression prefix) : } catch (ParseException e) { errorMessage = "']' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new ArrayDeclarator(prefix,expression,SimpleCharStream.getPosition());} @@ -1706,8 +1704,8 @@ Expression[] args = null; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new FunctionCall(func,args,SimpleCharStream.getPosition());} @@ -1733,8 +1731,8 @@ final ArrayList list = new ArrayList(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. An expression expected after a comma in argument list"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } )* @@ -1761,8 +1759,8 @@ Statement StatementNoBreak() : if (e.currentToken.next.kind != 4) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -1777,8 +1775,8 @@ Statement StatementNoBreak() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return statement;} @@ -1828,8 +1826,8 @@ HTMLBlock htmlBlock() : } catch (ParseException e) { errorMessage = "End of file unexpected, ' expression = Expression() @@ -1980,8 +1978,8 @@ EchoStatement EchoStatement() : if (e.currentToken.next.kind != 4) { errorMessage = "';' expected after 'echo' statement"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -1989,7 +1987,7 @@ EchoStatement EchoStatement() : GlobalStatement GlobalStatement() : { - final int pos = jj_input_stream.getPosition(); + final int pos = SimpleCharStream.getPosition(); String expr; ArrayList vars = new ArrayList(); GlobalStatement global; @@ -2016,8 +2014,8 @@ GlobalStatement GlobalStatement() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2042,8 +2040,8 @@ StaticStatement StaticStatement() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. a ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2078,8 +2076,8 @@ Block Block() : } catch (ParseException e) { errorMessage = "'{' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ( statement = BlockStatement() {list.add(statement);} @@ -2089,8 +2087,8 @@ Block Block() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.image +"', '}' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } { @@ -2150,7 +2148,7 @@ VariableDeclaration LocalVariableDeclarator() : return new VariableDeclaration(currentSegment, varName.toCharArray(), pos, - jj_input_stream.getPosition()); + SimpleCharStream.getPosition()); } return new VariableDeclaration(currentSegment, varName.toCharArray(), @@ -2203,8 +2201,8 @@ SwitchStatement SwitchStatement() : } catch (ParseException e) { errorMessage = "'(' expected after 'switch'"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2215,8 +2213,8 @@ SwitchStatement SwitchStatement() : } errorMessage = "expression expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2224,8 +2222,8 @@ SwitchStatement SwitchStatement() : } catch (ParseException e) { errorMessage = "')' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } (cases = switchStatementBrace() | cases = switchStatementColon(pos, pos + 6)) @@ -2249,8 +2247,8 @@ AbstractCase[] switchStatementBrace() : } catch (ParseException e) { errorMessage = "'}' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2282,8 +2280,8 @@ AbstractCase[] switchStatementColon(final int start, final int end) : } catch (ParseException e) { errorMessage = "'endswitch' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2295,8 +2293,8 @@ AbstractCase[] switchStatementColon(final int start, final int end) : } catch (ParseException e) { errorMessage = "';' expected after 'endswitch' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2340,8 +2338,8 @@ Expression SwitchLabel() : if (errorMessage != null) throw e; errorMessage = "expression expected after 'case' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2350,8 +2348,8 @@ Expression SwitchLabel() : } catch (ParseException e) { errorMessage = "':' expected after case expression"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } | @@ -2362,8 +2360,8 @@ Expression SwitchLabel() : } catch (ParseException e) { errorMessage = "':' expected after 'default' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2380,8 +2378,8 @@ Break BreakStatement() : } catch (ParseException e) { errorMessage = "';' expected after 'break' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new Break(expression, start, SimpleCharStream.getPosition());} @@ -2389,7 +2387,7 @@ Break BreakStatement() : IfStatement IfStatement() : { - final int pos = jj_input_stream.getPosition(); + final int pos = SimpleCharStream.getPosition(); Expression condition; IfStatement ifStatement; } @@ -2409,7 +2407,7 @@ Expression Condition(final String keyword) : } catch (ParseException e) { errorMessage = "'(' expected after " + keyword + " keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length(); + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length(); errorEnd = errorStart +1; processParseException(e); } @@ -2420,8 +2418,8 @@ Expression Condition(final String keyword) : } catch (ParseException e) { errorMessage = "')' expected after " + keyword + " keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2463,8 +2461,8 @@ IfStatement IfStatement0(Expression condition, final int start,final int end) : } catch (ParseException e) { errorMessage = "'endif' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2472,8 +2470,8 @@ IfStatement IfStatement0(Expression condition, final int start,final int end) : } catch (ParseException e) { errorMessage = "';' expected after 'endif' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } { @@ -2513,8 +2511,8 @@ IfStatement IfStatement0(Expression condition, final int start,final int end) : } errorMessage = "unexpected token '"+e.currentToken.next.image+"', a statement was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ] @@ -2612,8 +2610,8 @@ Statement WhileStatement0(final int start, final int end) : } catch (ParseException e) { errorMessage = "'endwhile' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2625,8 +2623,8 @@ Statement WhileStatement0(final int start, final int end) : } catch (ParseException e) { errorMessage = "';' expected after 'endwhile' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } | @@ -2648,8 +2646,8 @@ DoStatement DoStatement() : } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2668,8 +2666,8 @@ ForeachStatement ForeachStatement() : } catch (ParseException e) { errorMessage = "'(' expected after 'foreach' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2677,8 +2675,8 @@ ForeachStatement ForeachStatement() : } catch (ParseException e) { errorMessage = "variable expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2686,8 +2684,8 @@ ForeachStatement ForeachStatement() : } catch (ParseException e) { errorMessage = "'as' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2695,8 +2693,8 @@ ForeachStatement ForeachStatement() : } catch (ParseException e) { errorMessage = "variable expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2704,8 +2702,8 @@ ForeachStatement ForeachStatement() : } catch (ParseException e) { errorMessage = "')' expected after 'foreach' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2714,8 +2712,8 @@ ForeachStatement ForeachStatement() : if (errorMessage != null) throw e; errorMessage = "statement expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } {return new ForeachStatement(expression, @@ -2744,8 +2742,8 @@ final int startBlock, endBlock; } catch (ParseException e) { errorMessage = "'(' expected after 'for' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } [ initializations = ForInit() ] @@ -2776,8 +2774,8 @@ final int startBlock, endBlock; } catch (ParseException e) { errorMessage = "'endfor' expected"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } try { @@ -2789,8 +2787,8 @@ final int startBlock, endBlock; } catch (ParseException e) { errorMessage = "';' expected after 'endfor' keyword"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } ) @@ -2836,8 +2834,8 @@ Continue ContinueStatement() : } catch (ParseException e) { errorMessage = "';' expected after 'continue' statement"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } @@ -2855,8 +2853,8 @@ ReturnStatement ReturnStatement() : } catch (ParseException e) { errorMessage = "';' expected after 'return' statement"; errorLevel = ERROR; - errorStart = jj_input_stream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = jj_input_stream.getPosition() + 1; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; throw e; } } \ No newline at end of file -- 1.7.1 From 40b9a3dcdde67b29099fd3efa4ae504a0e3dc9f7 Mon Sep 17 00:00:00 2001 From: kpouer Date: Fri, 6 Jun 2003 12:39:26 +0000 Subject: [PATCH 06/16] *** 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 From 0788423caeeb84fe07c1615feef278527e9b3c44 Mon Sep 17 00:00:00 2001 From: kpouer Date: Sun, 8 Jun 2003 00:07:25 +0000 Subject: [PATCH 07/16] *** empty log message *** --- .../internal/compiler/ast/ClassDeclaration.java | 13 +++++- .../internal/compiler/ast/MethodDeclaration.java | 48 +++++++++++--------- .../phpdt/internal/compiler/ast/PHPDocument.java | 14 +++++- .../internal/compiler/ast/VariableDeclaration.java | 4 ++ .../compiler/parser/OutlineableWithChildren.java | 6 ++- .../phpeditor/PHPContentOutlinePage.java | 17 +++---- net.sourceforge.phpeclipse/src/test/PHPParser.java | 7 +-- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 10 ++-- 8 files changed, 73 insertions(+), 46 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 18f52c1..fccd134 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 @@ -8,6 +8,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; import java.util.ArrayList; +import java.util.List; /** @@ -68,6 +69,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr super(sourceStart, sourceEnd); this.parent = parent; this.name = name; + position = new Position(sourceStart, name.length); } public void addMethod(MethodDeclaration method) { @@ -166,10 +168,19 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr } public String toString() { - return toStringHeader(); + final StringBuffer buff = new StringBuffer(new String(name));//$NON-NLS-1$ + if (superclass != null) { + buff.append(":"); //$NON-NLS-1$ + buff.append(superclass); + } + return buff.toString(); } public Position getPosition() { return position; } + + public List getList() { + return children; + } } 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 e08010d..5c3a64e 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 @@ -9,6 +9,7 @@ import org.eclipse.jface.text.Position; import java.util.Hashtable; import java.util.Enumeration; import java.util.ArrayList; +import java.util.List; /** * A Method declaration. @@ -64,27 +65,7 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } public String toStringHeader() { - StringBuffer buff = new StringBuffer(); - buff.append("function ");//$NON-NLS-1$ - if (reference) { - buff.append('&');//$NON-NLS-1$ - } - buff.append(name).append("(");//$NON-NLS-1$ - - if (arguments != null) { - Enumeration values = arguments.elements(); - int i = 0; - while (values.hasMoreElements()) { - VariableDeclaration o = (VariableDeclaration) values.nextElement(); - buff.append(o.toStringExpression()); - if (i != (arguments.size() - 1)) { - buff.append(", "); //$NON-NLS-1$ - } - i++; - } - } - buff.append(")"); //$NON-NLS-1$ - return buff.toString(); + return "function " + toString(); } /** @@ -135,10 +116,33 @@ public class MethodDeclaration extends Statement implements OutlineableWithChild } public String toString() { - return toStringHeader(); + StringBuffer buff = new StringBuffer(); + if (reference) { + buff.append("&");//$NON-NLS-1$ + } + buff.append(name).append("(");//$NON-NLS-1$ + + if (arguments != null) { + Enumeration values = arguments.elements(); + int i = 0; + while (values.hasMoreElements()) { + VariableDeclaration o = (VariableDeclaration) values.nextElement(); + buff.append(o.toStringExpression()); + if (i != (arguments.size() - 1)) { + buff.append(", "); //$NON-NLS-1$ + } + i++; + } + } + buff.append(")"); //$NON-NLS-1$ + return buff.toString(); } public Position getPosition() { return position; } + + public List getList() { + return children; + } } 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 b2f523d..249daaf 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 @@ -7,6 +7,7 @@ import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.text.Position; import java.util.ArrayList; +import java.util.List; /** * It's a php document. @@ -22,18 +23,22 @@ public class PHPDocument implements OutlineableWithChildren { */ public AstNode[] nodes; + public char[] name; /** The parent of the object. */ public Object parent; /** The outlineable children (those will be in the node array too. */ private ArrayList children = new ArrayList(); + private Position position; /** * Create the PHPDocument. * @param parent the parent object (it should be null isn't it ?) */ - public PHPDocument(Object parent) { + public PHPDocument(Object parent, char[] name) { this.parent = parent; + this.name = name; + position = new Position(1,name.length); } /** @@ -99,7 +104,10 @@ public class PHPDocument implements OutlineableWithChildren { } public Position getPosition() { - //todo : check this - return null; + return position; + } + + public List getList() { + return children; } } \ 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 6d01007..5a709fd 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 @@ -96,6 +96,10 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements return parent; } + public String toString() { + return toStringExpression(); + } + /** * Get the image of a variable. * @return the image that represents a php variable 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 index 430a136..c7bfd79 100644 --- 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 @@ -1,7 +1,9 @@ package net.sourceforge.phpdt.internal.compiler.parser; +import java.util.List; + /** - * The interface that will describe an object that can have children + * The interface that will describe an object that can have children. * @author Matthieu Casanova */ public interface OutlineableWithChildren extends Outlineable { @@ -10,4 +12,6 @@ public interface OutlineableWithChildren extends Outlineable { Outlineable get(int index); int size(); + + List getList(); } 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 ca2b95a..b091a43 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPContentOutlinePage.java @@ -27,10 +27,7 @@ import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; import net.sourceforge.phpeclipse.PHPeclipsePlugin; import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.text.BadPositionCategoryException; -import org.eclipse.jface.text.DefaultPositionUpdater; -import org.eclipse.jface.text.IDocument; -import org.eclipse.jface.text.IPositionUpdater; +import org.eclipse.jface.text.*; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.jface.viewers.ITreeContentProvider; @@ -56,10 +53,10 @@ public class PHPContentOutlinePage extends AbstractContentOutlinePage { protected static class SegmentComparator implements Comparator { public int compare(Object o1, Object o2) { - if (o1 instanceof PHPSegmentWithChildren && !(o2 instanceof PHPSegmentWithChildren)) { + if (o1 instanceof OutlineableWithChildren && !(o2 instanceof OutlineableWithChildren)) { return 1; } - if (o2 instanceof PHPSegmentWithChildren && !(o1 instanceof PHPSegmentWithChildren)) { + if (o2 instanceof OutlineableWithChildren && !(o1 instanceof OutlineableWithChildren)) { return -1; } return ((Outlineable) o1).toString().compareToIgnoreCase(((Outlineable) o2).toString()); @@ -184,8 +181,8 @@ public class PHPContentOutlinePage extends AbstractContentOutlinePage { * @see ITreeContentProvider#hasChildren(Object) */ public boolean hasChildren(Object element) { - if (element instanceof PHPSegmentWithChildren) { - return !((PHPSegmentWithChildren) element).getList().isEmpty(); + if (element instanceof OutlineableWithChildren) { + return !((OutlineableWithChildren) element).getList().isEmpty(); } return element == fInput; } @@ -206,8 +203,8 @@ public class PHPContentOutlinePage extends AbstractContentOutlinePage { public Object[] getChildren(Object element) { if (element == fInput) return fContent.toArray(); - if (element instanceof PHPSegmentWithChildren) - return ((PHPSegmentWithChildren) element).getList().toArray(); + if (element instanceof OutlineableWithChildren) + return ((OutlineableWithChildren) element).getList().toArray(); return new Object[0]; } }; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index a25a5b4..4440696 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -101,7 +101,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - currentSegment = new PHPDocument(parent); + phpDocument = new PHPDocument(parent,"_root".toCharArray()); + currentSegment = phpDocument; outlineInfo = new PHPOutlineInfo(parent, currentSegment); final StringReader stream = new StringReader(s); if (jj_input_stream == null) { @@ -111,9 +112,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon init(); try { parse(); - phpDocument = new PHPDocument(null); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); + phpDocument.toString(); } catch (ParseException e) { processParseException(e); } @@ -629,11 +630,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon case FUNCTION: method = MethodDeclaration(); method.setParent(classDeclaration); - classDeclaration.addMethod(method); break; case VAR: field = FieldDeclaration(); - classDeclaration.addVariable(field); break; default: jj_la1[8] = jj_gen; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index baab0b4..e9930a3 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -122,7 +122,8 @@ public final class PHPParser extends PHPParserSuperclass { } public final PHPOutlineInfo parseInfo(final Object parent, final String s) { - currentSegment = new PHPDocument(parent); + phpDocument = new PHPDocument(parent,"_root".toCharArray()); + currentSegment = phpDocument; outlineInfo = new PHPOutlineInfo(parent, currentSegment); final StringReader stream = new StringReader(s); if (jj_input_stream == null) { @@ -132,9 +133,9 @@ public final class PHPParser extends PHPParserSuperclass { init(); try { parse(); - phpDocument = new PHPDocument(null); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); + phpDocument.toString(); } catch (ParseException e) { processParseException(e); } @@ -766,9 +767,8 @@ void ClassBodyDeclaration(ClassDeclaration classDeclaration) : FieldDeclaration field; } { - method = MethodDeclaration() {method.setParent(classDeclaration); - classDeclaration.addMethod(method);} -| field = FieldDeclaration() {classDeclaration.addVariable(field);} + method = MethodDeclaration() {method.setParent(classDeclaration);} +| field = FieldDeclaration() } /** -- 1.7.1 From b0934fe62a884119c2fb5a4db475a9671a298ff4 Mon Sep 17 00:00:00 2001 From: kpouer Date: Sun, 8 Jun 2003 14:16:13 +0000 Subject: [PATCH 08/16] *** empty log message *** --- .../internal/compiler/ast/ArrayInitializer.java | 7 +++---- .../internal/compiler/ast/VarAssignation.java | 4 ++-- net.sourceforge.phpeclipse/src/test/PHPParser.java | 12 ++++++------ net.sourceforge.phpeclipse/src/test/PHPParser.jj | 12 ++++++------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java index 3d9cb87..0979b23 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ArrayInitializer.java @@ -22,13 +22,12 @@ public class ArrayInitializer extends Expression { final StringBuffer buff = new StringBuffer("array("); for (int i = 0; i < vars.length; i++) { ArrayVariableDeclaration var = vars[i]; - if (var != null) { - buff.append(var.toStringExpression()); - } if (i != 0) { - buff.append(','); + buff.append(","); } + buff.append(var.toStringExpression()); } + buff.append(")"); return buff.toString(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java index cd32d4b..dc08043 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VarAssignation.java @@ -74,9 +74,9 @@ public class VarAssignation extends Expression { public String toStringExpression() { final StringBuffer buff = new StringBuffer(); buff.append(variable); - buff.append(' '); + buff.append(" "); buff.append(operatorToString()); - buff.append(' '); + buff.append(" "); buff.append(expression.toStringExpression()); return buff.toString(); } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 4440696..d83a9ce 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -114,7 +114,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon parse(); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - phpDocument.toString(); + PHPeclipsePlugin.log(1,phpDocument.toString()); } catch (ParseException e) { processParseException(e); } @@ -782,9 +782,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon {if (true) return token.image.substring(1);} } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); {if (true) return buff.toString();} break; case DOLLAR: @@ -831,15 +831,15 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon {if (true) return token.image;} } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); {if (true) return buff.toString();} break; case DOLLAR: jj_consume_token(DOLLAR); expr = VariableName(); - buff = new StringBuffer('$'); + buff = new StringBuffer("$"); buff.append(expr); {if (true) return buff.toString();} break; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index e9930a3..915c49c 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -135,7 +135,7 @@ public final class PHPParser extends PHPParserSuperclass { parse(); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - phpDocument.toString(); + PHPeclipsePlugin.log(1,phpDocument.toString()); } catch (ParseException e) { processParseException(e); } @@ -889,9 +889,9 @@ String Variable(): return token.image.substring(1); } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); return buff.toString(); } | @@ -919,15 +919,15 @@ String VariableName(): return token.image; } buff = new StringBuffer(token.image); - buff.append('{'); + buff.append("{"); buff.append(expression.toStringExpression()); - buff.append('}'); + buff.append("}"); return buff.toString(); } | expr = VariableName() { - buff = new StringBuffer('$'); + buff = new StringBuffer("$"); buff.append(expr); return buff.toString(); } -- 1.7.1 From aa2153d3566a0eff8917c74bdc0f150024bbddd7 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 8 Jun 2003 17:25:21 +0000 Subject: [PATCH 09/16] Fixed "textEditor==null" bug --- .../phpeclipse/phpeditor/PHPActionContributor.java | 38 +++++++++++--------- 1 files changed, 21 insertions(+), 17 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java index 5a35c88..66656e2 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPActionContributor.java @@ -178,30 +178,34 @@ public class PHPActionContributor extends BasicTextEditorActionContributor { ActionGroup group = cuEditor.getActionGroup(); if (group != null) group.fillActionBars(bars); - } + } // fTogglePresentation.setEditor(editor); // fTogglePresentation.update(); - IFile file = null; - IEditorInput editorInput = textEditor.getEditorInput(); + if (textEditor != null) { - if (editorInput instanceof IFileEditorInput) { - file = ((IFileEditorInput) editorInput).getFile(); - } + IFile file = null; + IEditorInput editorInput = textEditor.getEditorInput(); + + if (editorInput instanceof IFileEditorInput) { + file = ((IFileEditorInput) editorInput).getFile(); + } - PHPeclipsePlugin.getDefault().setLastEditorFile(file); - fParserAction.setEditor(textEditor); - fParserAction.update(); - if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) { - fShowExternalPreviewAction.setEditor(textEditor); - fShowExternalPreviewAction.update(); - IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) { - IAction a = ShowExternalPreviewAction.getInstance(); - if (a != null) - a.run(); + PHPeclipsePlugin.getDefault().setLastEditorFile(file); + fParserAction.setEditor(textEditor); + fParserAction.update(); + if (SWT.getPlatform().equals("win32") && textEditor instanceof AbstractTextEditor) { + fShowExternalPreviewAction.setEditor(textEditor); + fShowExternalPreviewAction.update(); + IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + if (store.getBoolean(PHPeclipsePlugin.SHOW_EXTERNAL_PREVIEW_PREF)) { + IAction a = ShowExternalPreviewAction.getInstance(); + if (a != null) + a.run(); + } } } + } /* -- 1.7.1 From 288c76afcf6fad37bd1f4db5a36797e092f22fe1 Mon Sep 17 00:00:00 2001 From: khartlage Date: Sun, 8 Jun 2003 17:29:06 +0000 Subject: [PATCH 10/16] Set DEBUG=false; Set DEBUG=true only for developer tests --- .../phpeditor/php/PHPPartitionScanner.java | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java index c4715e0..072f30b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java @@ -6,7 +6,7 @@ * Created on 05.03.2003 * * @author Stefan Langer (musk) - * @version $Revision: 1.17 $ + * @version $Revision: 1.18 $ */ package net.sourceforge.phpeclipse.phpeditor.php; @@ -20,7 +20,7 @@ import org.eclipse.jface.text.rules.*; */ public class PHPPartitionScanner implements IPartitionTokenScanner { - private static final boolean DEBUG = true; + private static final boolean DEBUG = false; private boolean fInString = false; private boolean fInDoubString = false; private IDocument fDocument = null; -- 1.7.1 From 9c312d6217537424b56f4cb4496c16e3f2e903fd Mon Sep 17 00:00:00 2001 From: kpouer Date: Mon, 9 Jun 2003 22:09:25 +0000 Subject: [PATCH 11/16] *** empty log message *** --- .../internal/compiler/ast/ClassDeclaration.java | 12 +- net.sourceforge.phpeclipse/src/test/PHPParser.java | 107 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 15 ++- 3 files changed, 70 insertions(+), 64 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 fccd134..9c5bf07 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 @@ -72,7 +72,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr position = new Position(sourceStart, name.length); } - public void addMethod(MethodDeclaration method) { + public void add(MethodDeclaration method) { methods.add(method); add(method); if (method.name.equals(name)) { @@ -80,7 +80,7 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr } } - public void addVariable(FieldDeclaration var) { + public void add(FieldDeclaration var) { for (int i = 0; i < var.vars.length; i++) { VariableDeclaration c = var.vars[i]; children.add(c); @@ -88,6 +88,10 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr fields.add(var); } + public boolean add(Outlineable o) { + return children.add(o); + } + /** * Tell if the class has a constructor. * @return a boolean @@ -154,10 +158,6 @@ public class ClassDeclaration extends Statement implements OutlineableWithChildr return parent; } - public boolean add(Outlineable o) { - return children.add(o); - } - public Outlineable get(int index) { return (Outlineable) children.get(index); } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index d83a9ce..1f9b39e 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -677,7 +677,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } list = new VariableDeclaration[arrayList.size()]; arrayList.toArray(list); @@ -2685,10 +2685,11 @@ final ArrayList list = new ArrayList(); errorEnd = SimpleCharStream.getPosition(); {if (true) throw e;} } - nbNodes = nodePtr-startIndex - 1; + nbNodes = nodePtr - startIndex; blockNodes = new AstNode[nbNodes]; System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes); - {if (true) return new HTMLBlock(nodes);} + nodePtr = startIndex; + {if (true) return new HTMLBlock(blockNodes);} throw new Error("Missing return statement in function"); } @@ -3156,6 +3157,7 @@ final ArrayList list = new ArrayList(); case SEMICOLON: case DOLLAR_ID: statement = Statement(); + if (phpDocument == currentSegment) pushOnAstNodes(statement); {if (true) return statement;} break; case CLASS: @@ -3164,6 +3166,7 @@ final ArrayList list = new ArrayList(); break; case FUNCTION: statement = MethodDeclaration(); + if (phpDocument == currentSegment) pushOnAstNodes(statement); {if (true) return statement;} break; default: @@ -5045,12 +5048,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_80() { - if (jj_scan_token(FLOAT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_85() { if (jj_scan_token(LIST)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5073,6 +5070,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_80() { + if (jj_scan_token(FLOAT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_167() { if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5381,6 +5384,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_87() { + if (jj_scan_token(ASSIGN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_140() { Token xsp; xsp = jj_scanpos; @@ -5397,14 +5408,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_87() { - if (jj_scan_token(ASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_134() { if (jj_3R_139()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5474,6 +5477,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_57() { + if (jj_3R_50()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_87()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_197() { if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5486,16 +5499,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_57() { - if (jj_3R_50()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_87()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_138() { if (jj_scan_token(RUNSIGNEDSHIFT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5943,6 +5946,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_46() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(COLON)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_98() { if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5953,18 +5964,16 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_46() { - if (jj_scan_token(IDENTIFIER)) return true; + static final private boolean jj_3R_114() { + if (jj_scan_token(BIT_OR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(COLON)) return true; + if (jj_3R_113()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_114() { - if (jj_scan_token(BIT_OR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_113()) return true; + static final private boolean jj_3_8() { + if (jj_3R_47()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -6001,12 +6010,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3_8() { - if (jj_3R_47()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_110() { if (jj_scan_token(DOT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6415,12 +6418,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_179() { - if (jj_3R_188()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_101() { if (jj_scan_token(ASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6429,6 +6426,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_179() { + if (jj_3R_188()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_42() { if (jj_3R_50()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6547,6 +6550,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_99() { + if (jj_3R_50()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_168() { if (jj_3R_166()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6557,12 +6566,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_99() { - if (jj_3R_50()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 915c49c..a28acb9 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -635,7 +635,7 @@ void PhpBlock() : { phpEchoBlock() | - [ + [ | {try { setMarker(fileToParse, @@ -798,7 +798,7 @@ FieldDeclaration FieldDeclaration() : errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); } {list = new VariableDeclaration[arrayList.size()]; @@ -1831,10 +1831,11 @@ HTMLBlock htmlBlock() : throw e; } { - nbNodes = nodePtr-startIndex - 1; + nbNodes = nodePtr - startIndex; blockNodes = new AstNode[nbNodes]; System.arraycopy(nodes,startIndex,blockNodes,0,nbNodes); - return new HTMLBlock(nodes);} + nodePtr = startIndex; + return new HTMLBlock(blockNodes);} } /** @@ -2102,9 +2103,11 @@ Statement BlockStatement() : final Statement statement; } { - statement = Statement() {return statement;} + statement = Statement() {if (phpDocument == currentSegment) pushOnAstNodes(statement); + return statement;} | statement = ClassDeclaration() {return statement;} -| statement = MethodDeclaration() {return statement;} +| statement = MethodDeclaration() {if (phpDocument == currentSegment) pushOnAstNodes(statement); + return statement;} } /** -- 1.7.1 From 754ecc42fa03b3c2e514a4b0630a723deaf25d77 Mon Sep 17 00:00:00 2001 From: kpouer Date: Tue, 10 Jun 2003 16:58:56 +0000 Subject: [PATCH 12/16] *** empty log message *** --- .../phpdt/internal/compiler/ast/Continue.java | 6 +- .../phpdt/internal/compiler/ast/ElseIf.java | 3 + .../phpdt/internal/compiler/ast/IfStatement.java | 4 +- .../phpdt/internal/compiler/ast/PHPDocument.java | 1 + .../internal/compiler/ast/ReturnStatement.java | 5 +- net.sourceforge.phpeclipse/src/test/PHPParser.java | 539 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 48 +- 7 files changed, 307 insertions(+), 299 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java index a1ca200..c862a2f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Continue.java @@ -1,7 +1,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** - * A break statement. + * A continue statement. * @author Matthieu Casanova */ public class Continue extends BranchStatement { @@ -13,8 +13,8 @@ public class Continue extends BranchStatement { public String toString(int tab) { String s = tabString(tab); if (expression == null) { - return s + "continue " + expression.toString();//$NON-NLS-1$ + return s + "continue";//$NON-NLS-1$ } - return s + "continue";//$NON-NLS-1$ + return s + "continue " + expression.toString();//$NON-NLS-1$ } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java index d2fac29..a6aff20 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ElseIf.java @@ -1,12 +1,15 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** + * An elseif statement. * @author Matthieu Casanova */ public class ElseIf extends Statement { + /** The condition. */ public Expression condition; + /** The statements. */ public Statement[] statements; public ElseIf(Expression condition, Statement[] statements, int sourceStart, int sourceEnd) { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java index e1682c9..f847463 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java @@ -41,10 +41,12 @@ public class IfStatement extends Statement { final StringBuffer buff = new StringBuffer(tabString(tab)); buff.append("if ("); buff.append(condition.toStringExpression()).append(") "); + buff.append("\n"); + buff.append(statement.toString(tab+1)); for (int i = 0; i < elseifs.length; i++) { ElseIf elseif = elseifs[i]; buff.append(elseif.toString(tab+1)); - buff.append('\n'); + buff.append("\n"); } if (els != null) { buff.append(els.toString(tab+1)); 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 249daaf..93e1b40 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 @@ -56,6 +56,7 @@ public class PHPDocument implements OutlineableWithChildren { break; } buff.append(node.toString(0)); + buff.append("\n"); } } return buff.toString(); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java index ea695e4..85d1867 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/ReturnStatement.java @@ -1,6 +1,7 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** + * A return statement. * @author Matthieu Casanova */ public class ReturnStatement extends Statement { @@ -15,8 +16,8 @@ public class ReturnStatement extends Statement { public String toString(int tab) { final String s = tabString(tab); if (expression == null) { - return s + "return " + expression.toStringExpression(); + return s + "return";//$NON-NLS-1$ } - return s + "return"; + return s + "return " + expression.toStringExpression();//$NON-NLS-1$ } } diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 1f9b39e..84c63af 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -114,7 +114,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon parse(); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - PHPeclipsePlugin.log(1,phpDocument.toString()); + if (PHPeclipsePlugin.DEBUG) { + PHPeclipsePlugin.log(1,phpDocument.toString()); + } } catch (ParseException e) { processParseException(e); } @@ -1146,56 +1148,47 @@ Expression expr,expr2; case STRING: jj_consume_token(STRING); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.STRING, - pos,pos-6);} + {if (true) return new ConstantIdentifier(Types.STRING,pos,pos-6);} break; case BOOL: jj_consume_token(BOOL); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.BOOL, - pos,pos-4);} + {if (true) return new ConstantIdentifier(Types.BOOL,pos,pos-4);} break; case BOOLEAN: jj_consume_token(BOOLEAN); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.BOOLEAN, - pos,pos-7);} + {if (true) return new ConstantIdentifier(Types.BOOLEAN,pos,pos-7);} break; case REAL: jj_consume_token(REAL); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.REAL, - pos,pos-4);} + {if (true) return new ConstantIdentifier(Types.REAL,pos,pos-4);} break; case DOUBLE: jj_consume_token(DOUBLE); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.DOUBLE, - pos,pos-5);} + {if (true) return new ConstantIdentifier(Types.DOUBLE,pos,pos-5);} break; case FLOAT: jj_consume_token(FLOAT); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.FLOAT, - pos,pos-5);} + {if (true) return new ConstantIdentifier(Types.FLOAT,pos,pos-5);} break; case INT: jj_consume_token(INT); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.INT, - pos,pos-3);} + {if (true) return new ConstantIdentifier(Types.INT,pos,pos-3);} break; case INTEGER: jj_consume_token(INTEGER); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.INTEGER, - pos,pos-7);} + {if (true) return new ConstantIdentifier(Types.INTEGER,pos,pos-7);} break; case OBJECT: jj_consume_token(OBJECT); pos = SimpleCharStream.getPosition(); - {if (true) return new ConstantIdentifier(Types.OBJECT, - pos,pos-6);} + {if (true) return new ConstantIdentifier(Types.OBJECT,pos,pos-6);} break; default: jj_la1[25] = jj_gen; @@ -2473,7 +2466,7 @@ final ArrayList list = new ArrayList(); try { jj_consume_token(SEMICOLON); } catch (ParseException e) { - if (e.currentToken.next.kind != 4) { + if (e.currentToken.next.kind != PHPParserConstants.PHPEND) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; @@ -2867,9 +2860,6 @@ final ArrayList list = new ArrayList(); } try { jj_consume_token(SEMICOLON); - Expression[] exprs = new Expression[expressions.size()]; - expressions.toArray(exprs); - {if (true) return new EchoStatement(exprs,pos);} } catch (ParseException e) { if (e.currentToken.next.kind != 4) { errorMessage = "';' expected after 'echo' statement"; @@ -2879,6 +2869,9 @@ final ArrayList list = new ArrayList(); {if (true) throw e;} } } + Expression[] exprs = new Expression[expressions.size()]; + expressions.toArray(exprs); + {if (true) return new EchoStatement(exprs,pos);} throw new Error("Missing return statement in function"); } @@ -3156,9 +3149,17 @@ final ArrayList list = new ArrayList(); case LBRACE: case SEMICOLON: case DOLLAR_ID: - statement = Statement(); + try { + statement = Statement(); if (phpDocument == currentSegment) pushOnAstNodes(statement); {if (true) return statement;} + } catch (ParseException e) { + errorMessage = "statement expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + {if (true) throw e;} + } break; case CLASS: statement = ClassDeclaration(); @@ -5012,6 +5013,39 @@ final int startBlock, endBlock; return retval; } + static final private boolean jj_3R_193() { + if (jj_scan_token(INCR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_185() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_193()) { + jj_scanpos = xsp; + if (jj_3R_194()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_99() { + if (jj_3R_50()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_168() { + if (jj_3R_166()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_185()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_83() { if (jj_scan_token(OBJECT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5024,20 +5058,32 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_81() { + if (jj_scan_token(INT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_44() { if (jj_scan_token(ARRAY)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } + static final private boolean jj_3R_80() { + if (jj_scan_token(FLOAT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_184() { if (jj_scan_token(ARRAY)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_81() { - if (jj_scan_token(INT)) return true; + static final private boolean jj_3R_79() { + if (jj_scan_token(DOUBLE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5070,8 +5116,8 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_80() { - if (jj_scan_token(FLOAT)) return true; + static final private boolean jj_3R_78() { + if (jj_scan_token(REAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5093,55 +5139,20 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_79() { - if (jj_scan_token(DOUBLE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_43() { - if (jj_3R_52()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_78() { - if (jj_scan_token(REAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_77() { if (jj_scan_token(BOOLEAN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_84() { - if (jj_scan_token(PRINT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_76() { if (jj_scan_token(BOOL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3_4() { - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_43()) { - jj_scanpos = xsp; - if (jj_3R_44()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; + static final private boolean jj_3R_43() { + if (jj_3R_52()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5184,6 +5195,29 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_84() { + if (jj_scan_token(PRINT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3_4() { + if (jj_scan_token(LPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_43()) { + jj_scanpos = xsp; + if (jj_3R_44()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_165() { if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5366,6 +5400,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_87() { + if (jj_scan_token(ASSIGN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_147() { if (jj_scan_token(REMAINDER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5384,14 +5426,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_87() { - if (jj_scan_token(ASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_140() { Token xsp; xsp = jj_scanpos; @@ -5420,12 +5454,26 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_198() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_142() { if (jj_scan_token(MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } + static final private boolean jj_3_2() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_141() { if (jj_scan_token(PLUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5445,62 +5493,71 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_128() { - if (jj_3R_134()) return true; + static final private boolean jj_3R_197() { + if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; while (true) { xsp = jj_scanpos; - if (jj_3R_135()) { jj_scanpos = xsp; break; } + if (jj_3_2()) { jj_scanpos = xsp; break; } if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } return false; } - static final private boolean jj_3R_198() { - if (jj_scan_token(COMMA)) return true; + static final private boolean jj_3R_57() { + if (jj_3R_50()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_87()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3_7() { - if (jj_3R_46()) return true; + static final private boolean jj_3R_128() { + if (jj_3R_134()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_135()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } return false; } - static final private boolean jj_3_2() { - if (jj_scan_token(COMMA)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_41()) return true; + static final private boolean jj_3_7() { + if (jj_3R_46()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_57() { - if (jj_3R_50()) return true; + static final private boolean jj_3R_192() { + if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; - if (jj_3R_87()) jj_scanpos = xsp; + if (jj_3R_197()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + xsp = jj_scanpos; + if (jj_3R_198()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_197() { - if (jj_3R_41()) return true; + static final private boolean jj_3R_138() { + if (jj_scan_token(RUNSIGNEDSHIFT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } return false; } - static final private boolean jj_3R_138() { - if (jj_scan_token(RUNSIGNEDSHIFT)) return true; + static final private boolean jj_3R_58() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_57()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5533,6 +5590,18 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_47() { + if (jj_3R_57()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3R_58()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_121() { if (jj_3R_128()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5553,38 +5622,21 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_192() { - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_197()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - xsp = jj_scanpos; - if (jj_3R_198()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_58() { - if (jj_scan_token(COMMA)) return true; + static final private boolean jj_3R_201() { + if (jj_scan_token(ARRAYASSIGN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_57()) return true; + if (jj_3R_45()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_47() { - if (jj_3R_57()) return true; + static final private boolean jj_3R_41() { + if (jj_3R_45()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3R_58()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } + xsp = jj_scanpos; + if (jj_3R_201()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5594,14 +5646,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_201() { - if (jj_scan_token(ARRAYASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_132() { if (jj_scan_token(LE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5614,16 +5658,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_41() { - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_201()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_130() { if (jj_scan_token(LT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5681,6 +5715,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_108() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_127() { if (jj_scan_token(TRIPLEEQUAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5705,6 +5749,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_91() { + if (jj_scan_token(DOLLAR_ID)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_124() { if (jj_scan_token(DIF)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5739,18 +5789,16 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_108() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; + static final private boolean jj_3R_93() { + if (jj_3R_52()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_93() { - if (jj_3R_52()) return true; + static final private boolean jj_3R_90() { + if (jj_scan_token(DOLLAR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5779,20 +5827,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_91() { - if (jj_scan_token(DOLLAR_ID)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_90() { - if (jj_scan_token(DOLLAR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_59()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_118() { if (jj_scan_token(BIT_AND)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5807,6 +5841,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_89() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_108()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_176() { if (jj_scan_token(FALSE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5837,19 +5881,46 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_88() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_59() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_88()) { + jj_scanpos = xsp; + if (jj_3R_89()) { + jj_scanpos = xsp; + if (jj_3R_90()) { + jj_scanpos = xsp; + if (jj_3R_91()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_173() { if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_89() { - if (jj_scan_token(IDENTIFIER)) return true; + static final private boolean jj_3R_98() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_108()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5890,33 +5961,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_88() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_59() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_88()) { - jj_scanpos = xsp; - if (jj_3R_89()) { - jj_scanpos = xsp; - if (jj_3R_90()) { - jj_scanpos = xsp; - if (jj_3R_91()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_113() { if (jj_3R_115()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5946,28 +5990,18 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_46() { - if (jj_scan_token(IDENTIFIER)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(COLON)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_98() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; + static final private boolean jj_3R_95() { + if (jj_scan_token(DOLLAR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; + if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_114() { - if (jj_scan_token(BIT_OR)) return true; + static final private boolean jj_3R_46() { + if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_113()) return true; + if (jj_scan_token(COLON)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5978,10 +6012,10 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_95() { - if (jj_scan_token(DOLLAR)) return true; + static final private boolean jj_3R_114() { + if (jj_scan_token(BIT_OR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_59()) return true; + if (jj_3R_113()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -6010,14 +6044,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_110() { - if (jj_scan_token(DOT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_109()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_94() { if (jj_scan_token(DOLLAR_ID)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6039,6 +6065,14 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_110() { + if (jj_scan_token(DOT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_109()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_104() { if (jj_3R_109()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6082,6 +6116,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3_1() { + if (jj_3R_40()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_196() { if (jj_3R_40()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6142,9 +6182,15 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3_1() { - if (jj_3R_40()) return true; + static final private boolean jj_3R_50() { + if (jj_3R_61()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_1()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } return false; } @@ -6183,18 +6229,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_50() { - if (jj_3R_61()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_1()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - static final private boolean jj_3R_103() { Token xsp; xsp = jj_scanpos; @@ -6533,39 +6567,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_193() { - if (jj_scan_token(INCR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_185() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_193()) { - jj_scanpos = xsp; - if (jj_3R_194()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_99() { - if (jj_3R_50()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_168() { - if (jj_3R_166()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_185()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index a28acb9..ac77fff 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -135,7 +135,9 @@ public final class PHPParser extends PHPParserSuperclass { parse(); phpDocument.nodes = new AstNode[nodes.length]; System.arraycopy(nodes,0,phpDocument.nodes,0,nodes.length); - PHPeclipsePlugin.log(1,phpDocument.toString()); + if (PHPeclipsePlugin.DEBUG) { + PHPeclipsePlugin.log(1,phpDocument.toString()); + } } catch (ParseException e) { processParseException(e); } @@ -1119,32 +1121,23 @@ ConstantIdentifier Type() : {final int pos;} { {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.STRING, - pos,pos-6);} + return new ConstantIdentifier(Types.STRING,pos,pos-6);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.BOOL, - pos,pos-4);} + return new ConstantIdentifier(Types.BOOL,pos,pos-4);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.BOOLEAN, - pos,pos-7);} + return new ConstantIdentifier(Types.BOOLEAN,pos,pos-7);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.REAL, - pos,pos-4);} + return new ConstantIdentifier(Types.REAL,pos,pos-4);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.DOUBLE, - pos,pos-5);} + return new ConstantIdentifier(Types.DOUBLE,pos,pos-5);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.FLOAT, - pos,pos-5);} + return new ConstantIdentifier(Types.FLOAT,pos,pos-5);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.INT, - pos,pos-3);} + return new ConstantIdentifier(Types.INT,pos,pos-3);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.INTEGER, - pos,pos-7);} + return new ConstantIdentifier(Types.INTEGER,pos,pos-7);} | {pos = SimpleCharStream.getPosition(); - return new ConstantIdentifier(Types.OBJECT, - pos,pos-6);} + return new ConstantIdentifier(Types.OBJECT,pos,pos-6);} } Expression Expression() : @@ -1756,7 +1749,7 @@ Statement StatementNoBreak() : try { } catch (ParseException e) { - if (e.currentToken.next.kind != 4) { + if (e.currentToken.next.kind != PHPParserConstants.PHPEND) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. A ';' was expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; @@ -1971,10 +1964,6 @@ EchoStatement EchoStatement() : )* try { - { - Expression[] exprs = new Expression[expressions.size()]; - expressions.toArray(exprs); - return new EchoStatement(exprs,pos);} } catch (ParseException e) { if (e.currentToken.next.kind != 4) { errorMessage = "';' expected after 'echo' statement"; @@ -1984,6 +1973,9 @@ EchoStatement EchoStatement() : throw e; } } + {Expression[] exprs = new Expression[expressions.size()]; + expressions.toArray(exprs); + return new EchoStatement(exprs,pos);} } GlobalStatement GlobalStatement() : @@ -2103,8 +2095,16 @@ Statement BlockStatement() : final Statement statement; } { + try { statement = Statement() {if (phpDocument == currentSegment) pushOnAstNodes(statement); return statement;} + } catch (ParseException e) { + errorMessage = "statement expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + throw e; + } | statement = ClassDeclaration() {return statement;} | statement = MethodDeclaration() {if (phpDocument == currentSegment) pushOnAstNodes(statement); return statement;} -- 1.7.1 From d34742a335464b92dd8152115eb6710304c3852a Mon Sep 17 00:00:00 2001 From: kpouer Date: Wed, 11 Jun 2003 16:33:33 +0000 Subject: [PATCH 13/16] *** empty log message *** --- .../phpdt/internal/compiler/ast/PHPDocument.java | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) 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 93e1b40..e2d2fc5 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 @@ -56,7 +56,7 @@ public class PHPDocument implements OutlineableWithChildren { break; } buff.append(node.toString(0)); - buff.append("\n"); + buff.append(";\n"); } } return buff.toString(); -- 1.7.1 From 2807e2bacbb7193c0e56d7e240c4556346b86dfe Mon Sep 17 00:00:00 2001 From: kpouer Date: Thu, 12 Jun 2003 16:01:14 +0000 Subject: [PATCH 14/16] *** empty log message *** --- net.sourceforge.phpeclipse/src/test/PHPParser.java | 587 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 42 +- 2 files changed, 332 insertions(+), 297 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index 84c63af..b5b0024 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -49,6 +49,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static int errorStart = -1; private static int errorEnd = -1; private static PHPDocument phpDocument; + + private static final char[] SYNTAX_ERROR_CHAR = {'s','y','n','t','a','x',' ','e','r','r','o','r'}; /** * The point where html starts. * It will be used by the token manager to create HTMLCode objects @@ -447,7 +449,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } break; default: @@ -538,43 +540,48 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon final Token className; Token superclassName = null; final int pos; + char[] classNameImage = SYNTAX_ERROR_CHAR; + char[] superclassNameImage = null; jj_consume_token(CLASS); + pos = SimpleCharStream.getPosition(); try { - pos = SimpleCharStream.getPosition(); className = jj_consume_token(IDENTIFIER); + classNameImage = className.image.toCharArray(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case EXTENDS: jj_consume_token(EXTENDS); try { superclassName = jj_consume_token(IDENTIFIER); + superclassNameImage = superclassName .image.toCharArray(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); + superclassNameImage = SYNTAX_ERROR_CHAR; } break; default: jj_la1[6] = jj_gen; ; } - if (superclassName == null) { + if (superclassNameImage == null) { classDeclaration = new ClassDeclaration(currentSegment, - className.image.toCharArray(), + classNameImage, pos, 0); } else { classDeclaration = new ClassDeclaration(currentSegment, - className.image.toCharArray(), - superclassName.image.toCharArray(), + classNameImage, + superclassNameImage, pos, 0); } @@ -1046,6 +1053,7 @@ Expression expr,expr2; Token reference = null; final Hashtable formalParameters; final int pos = SimpleCharStream.getPosition(); + char[] identifierChar = SYNTAX_ERROR_CHAR; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case BIT_AND: reference = jj_consume_token(BIT_AND); @@ -1054,10 +1062,19 @@ Expression expr,expr2; jj_la1[21] = jj_gen; ; } - identifier = jj_consume_token(IDENTIFIER); + try { + identifier = jj_consume_token(IDENTIFIER); + identifierChar = identifier.image.toCharArray(); + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + processParseException(e); + } formalParameters = FormalParameters(); {if (true) return new MethodDeclaration(currentSegment, - identifier.image.toCharArray(), + identifierChar, formalParameters, reference != null, pos, @@ -3774,14 +3791,14 @@ final ArrayList list = new ArrayList(); condition = Expression(); try { jj_consume_token(RPAREN); - {if (true) return condition;} } catch (ParseException e) { errorMessage = "')' expected after " + keyword + " keyword"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } + {if (true) return condition;} throw new Error("Missing return statement in function"); } @@ -5013,132 +5030,6 @@ final int startBlock, endBlock; return retval; } - static final private boolean jj_3R_193() { - if (jj_scan_token(INCR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_185() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_193()) { - jj_scanpos = xsp; - if (jj_3R_194()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_99() { - if (jj_3R_50()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_168() { - if (jj_3R_166()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_185()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_83() { - if (jj_scan_token(OBJECT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_82() { - if (jj_scan_token(INTEGER)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_81() { - if (jj_scan_token(INT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_44() { - if (jj_scan_token(ARRAY)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_80() { - if (jj_scan_token(FLOAT)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_184() { - if (jj_scan_token(ARRAY)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_79() { - if (jj_scan_token(DOUBLE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_183() { - if (jj_3R_52()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_85() { - if (jj_scan_token(LIST)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_99()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - while (true) { - xsp = jj_scanpos; - if (jj_3R_100()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - if (jj_scan_token(RPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - xsp = jj_scanpos; - if (jj_3R_101()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_78() { - if (jj_scan_token(REAL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_167() { - if (jj_scan_token(LPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_183()) { - jj_scanpos = xsp; - if (jj_3R_184()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_139()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_77() { if (jj_scan_token(BOOLEAN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5454,26 +5345,12 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_198() { - if (jj_scan_token(COMMA)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_142() { if (jj_scan_token(MINUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3_2() { - if (jj_scan_token(COMMA)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_141() { if (jj_scan_token(PLUS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5493,18 +5370,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_197() { - if (jj_3R_41()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_2()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } - return false; - } - static final private boolean jj_3R_57() { if (jj_3R_50()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5533,21 +5398,32 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_192() { - if (jj_scan_token(LPAREN)) return true; + static final private boolean jj_3R_198() { + if (jj_scan_token(COMMA)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_197()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - xsp = jj_scanpos; - if (jj_3R_198()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RPAREN)) return true; + return false; + } + + static final private boolean jj_3_2() { + if (jj_scan_token(COMMA)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_41()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } + static final private boolean jj_3R_197() { + if (jj_3R_41()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_2()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_138() { if (jj_scan_token(RUNSIGNEDSHIFT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5622,21 +5498,18 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_201() { - if (jj_scan_token(ARRAYASSIGN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_41() { - if (jj_3R_45()) return true; + static final private boolean jj_3R_192() { + if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; Token xsp; xsp = jj_scanpos; - if (jj_3R_201()) jj_scanpos = xsp; + if (jj_3R_197()) jj_scanpos = xsp; else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + xsp = jj_scanpos; + if (jj_3R_198()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5658,12 +5531,30 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_201() { + if (jj_scan_token(ARRAYASSIGN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_130() { if (jj_scan_token(LT)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } + static final private boolean jj_3R_41() { + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_201()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_122() { Token xsp; xsp = jj_scanpos; @@ -5715,16 +5606,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_108() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_127() { if (jj_scan_token(TRIPLEEQUAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5749,12 +5630,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_91() { - if (jj_scan_token(DOLLAR_ID)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_124() { if (jj_scan_token(DIF)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5795,14 +5670,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_90() { - if (jj_scan_token(DOLLAR)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_59()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_117() { if (jj_3R_119()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5815,6 +5682,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_108() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_199() { if (jj_scan_token(LPAREN)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5827,6 +5704,12 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_91() { + if (jj_scan_token(DOLLAR_ID)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_118() { if (jj_scan_token(BIT_AND)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5841,13 +5724,11 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_89() { - if (jj_scan_token(IDENTIFIER)) return true; + static final private boolean jj_3R_90() { + if (jj_scan_token(DOLLAR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_108()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -5881,49 +5762,12 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_88() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_59() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_88()) { - jj_scanpos = xsp; - if (jj_3R_89()) { - jj_scanpos = xsp; - if (jj_3R_90()) { - jj_scanpos = xsp; - if (jj_3R_91()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_173() { if (jj_scan_token(FLOATING_POINT_LITERAL)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_98() { - if (jj_scan_token(LBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_45()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_scan_token(RBRACE)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_169() { Token xsp; xsp = jj_scanpos; @@ -5953,6 +5797,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_89() { + if (jj_scan_token(IDENTIFIER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_108()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_116() { if (jj_scan_token(XOR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5990,14 +5844,33 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_95() { - if (jj_scan_token(DOLLAR)) return true; + static final private boolean jj_3R_88() { + if (jj_scan_token(LBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_59()) return true; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } + static final private boolean jj_3R_59() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_88()) { + jj_scanpos = xsp; + if (jj_3R_89()) { + jj_scanpos = xsp; + if (jj_3R_90()) { + jj_scanpos = xsp; + if (jj_3R_91()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_46() { if (jj_scan_token(IDENTIFIER)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6012,6 +5885,16 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_98() { + if (jj_scan_token(LBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_45()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RBRACE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_114() { if (jj_scan_token(BIT_OR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6044,24 +5927,11 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_94() { - if (jj_scan_token(DOLLAR_ID)) return true; + static final private boolean jj_3R_95() { + if (jj_scan_token(DOLLAR)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_98()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_61() { - Token xsp; - xsp = jj_scanpos; - if (jj_3R_94()) { - jj_scanpos = xsp; - if (jj_3R_95()) return true; + if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } @@ -6085,6 +5955,27 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_94() { + if (jj_scan_token(DOLLAR_ID)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_98()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_61() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_94()) { + jj_scanpos = xsp; + if (jj_3R_95()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static final private boolean jj_3R_48() { if (jj_scan_token(CLASSACCESS)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6116,12 +6007,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3_1() { - if (jj_3R_40()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_196() { if (jj_3R_40()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6182,15 +6067,9 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_50() { - if (jj_3R_61()) return true; + static final private boolean jj_3_1() { + if (jj_3R_40()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_1()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } return false; } @@ -6229,6 +6108,18 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_50() { + if (jj_3R_61()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_1()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_103() { Token xsp; xsp = jj_scanpos; @@ -6567,6 +6458,132 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_193() { + if (jj_scan_token(INCR)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_185() { + Token xsp; + xsp = jj_scanpos; + if (jj_3R_193()) { + jj_scanpos = xsp; + if (jj_3R_194()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_99() { + if (jj_3R_50()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_168() { + if (jj_3R_166()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_185()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_83() { + if (jj_scan_token(OBJECT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_82() { + if (jj_scan_token(INTEGER)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_81() { + if (jj_scan_token(INT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_44() { + if (jj_scan_token(ARRAY)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_80() { + if (jj_scan_token(FLOAT)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_184() { + if (jj_scan_token(ARRAY)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_79() { + if (jj_scan_token(DOUBLE)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_183() { + if (jj_3R_52()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_85() { + if (jj_scan_token(LIST)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(LPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_99()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + while (true) { + xsp = jj_scanpos; + if (jj_3R_100()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + xsp = jj_scanpos; + if (jj_3R_101()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_78() { + if (jj_scan_token(REAL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_167() { + if (jj_scan_token(LPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_183()) { + jj_scanpos = xsp; + if (jj_3R_184()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_scan_token(RPAREN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_139()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index ac77fff..cb90b27 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -70,6 +70,8 @@ public final class PHPParser extends PHPParserSuperclass { private static int errorStart = -1; private static int errorEnd = -1; private static PHPDocument phpDocument; + + private static final char[] SYNTAX_ERROR_CHAR = {'s','y','n','t','a','x',' ','e','r','r','o','r'}; /** * The point where html starts. * It will be used by the token manager to create HTMLCode objects @@ -658,7 +660,7 @@ void PhpBlock() : errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); } } @@ -688,41 +690,46 @@ ClassDeclaration ClassDeclaration() : final Token className; Token superclassName = null; final int pos; + char[] classNameImage = SYNTAX_ERROR_CHAR; + char[] superclassNameImage = null; } { + {pos = SimpleCharStream.getPosition();} try { - {pos = SimpleCharStream.getPosition();} className = + {classNameImage = className.image.toCharArray();} } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); } [ try { superclassName = + {superclassNameImage = superclassName .image.toCharArray();} } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); + superclassNameImage = SYNTAX_ERROR_CHAR; } ] { - if (superclassName == null) { + if (superclassNameImage == null) { classDeclaration = new ClassDeclaration(currentSegment, - className.image.toCharArray(), + classNameImage, pos, 0); } else { classDeclaration = new ClassDeclaration(currentSegment, - className.image.toCharArray(), - superclassName.image.toCharArray(), + classNameImage, + superclassNameImage, pos, 0); } @@ -1049,12 +1056,23 @@ MethodDeclaration MethodDeclarator() : Token reference = null; final Hashtable formalParameters; final int pos = SimpleCharStream.getPosition(); + char[] identifierChar = SYNTAX_ERROR_CHAR; } { - [reference = ] identifier = + [reference = ] + try { + identifier = + {identifierChar = identifier.image.toCharArray();} + } catch (ParseException e) { + errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', function identifier expected"; + errorLevel = ERROR; + errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; + errorEnd = SimpleCharStream.getPosition() + 1; + processParseException(e); + } formalParameters = FormalParameters() {return new MethodDeclaration(currentSegment, - identifier.image.toCharArray(), + identifierChar, formalParameters, reference != null, pos, @@ -2417,14 +2435,14 @@ Expression Condition(final String keyword) : condition = Expression() try { - {return condition;} } catch (ParseException e) { errorMessage = "')' expected after " + keyword + " keyword"; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - throw e; + processParseException(e); } + {return condition;} } IfStatement IfStatement0(Expression condition, final int start,final int end) : -- 1.7.1 From 161cdbbdc82c4cce12d1fe7a135809b6bbee999d Mon Sep 17 00:00:00 2001 From: kpouer Date: Thu, 12 Jun 2003 22:35:32 +0000 Subject: [PATCH 15/16] *** empty log message *** --- .../phpdt/internal/compiler/ast/Block.java | 31 +++---------------- .../phpdt/internal/compiler/ast/IfStatement.java | 5 +++ net.sourceforge.phpeclipse/src/test/PHPParser.java | 8 ++-- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 8 ++-- 4 files changed, 18 insertions(+), 34 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java index 7050649..ce9fd59 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java @@ -1,8 +1,5 @@ package net.sourceforge.phpdt.internal.compiler.ast; -import net.sourceforge.phpdt.internal.compiler.ast.AstNode; - - /** * A Block is * { @@ -33,31 +30,13 @@ public class Block extends Statement { public String toString(int tab) { final String s = AstNode.tabString(tab); final StringBuffer buff = new StringBuffer(s); - if (this.statements == null) { - buff.append("{\n"); //$NON-NLS-1$ - buff.append(s); - buff.append("}"); //$NON-NLS-1$ - return s; - } buff.append("{\n"); //$NON-NLS-1$ - buff.append(this.toStringStatements(tab)); - buff.append(s); - buff.append("}"); //$NON-NLS-1$ - return s; - } - - public String toStringStatements(int tab) { - if (this.statements == null) - return ""; //$NON-NLS-1$ - StringBuffer buffer = new StringBuffer(); - for (int i = 0; i < statements.length; i++) { - buffer.append(statements[i].toString(tab + 1)); - if (statements[i] instanceof Block) { - buffer.append("\n"); //$NON-NLS-1$ - } else { - buffer.append(";\n"); //$NON-NLS-1$ + if (this.statements == null) { + for (int i = 0; i < statements.length; i++) { + buff.append(statements[i].toString(tab+1)).append(";\n");//$NON-NLS-1$ } } - return buffer.toString(); + buff.append("}\n"); //$NON-NLS-1$ + return buff.toString(); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java index f847463..aebef7b 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/IfStatement.java @@ -1,6 +1,11 @@ package net.sourceforge.phpdt.internal.compiler.ast; /** + * This is a if statement. + * if (condition) + * statement + * (elseif statement)* + * else statement * @author Matthieu Casanova */ public class IfStatement extends Statement { diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index b5b0024..f0ea36f 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -3983,10 +3983,10 @@ final ArrayList list = new ArrayList(); stmts.toArray(statementsArray); {if (true) return new IfStatement(condition, new Block(statementsArray,pos,endStatements), - elseIfs, - elseStatement, - pos, - SimpleCharStream.getPosition());} + elseIfs, + elseStatement, + pos, + SimpleCharStream.getPosition());} } break; case PHPEND: diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index cb90b27..28764a7 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -2510,10 +2510,10 @@ IfStatement IfStatement0(Expression condition, final int start,final int end) : stmts.toArray(statementsArray); return new IfStatement(condition, new Block(statementsArray,pos,endStatements), - elseIfs, - elseStatement, - pos, - SimpleCharStream.getPosition()); + elseIfs, + elseStatement, + pos, + SimpleCharStream.getPosition()); } } -- 1.7.1 From 5ed725ccd02fe7c02eb8e00de61344a7c1b8d21d Mon Sep 17 00:00:00 2001 From: kpouer Date: Fri, 13 Jun 2003 15:52:38 +0000 Subject: [PATCH 16/16] *** empty log message *** --- .../phpdt/internal/compiler/ast/Block.java | 6 + net.sourceforge.phpeclipse/src/test/PHPParser.java | 110 ++++++++++---------- net.sourceforge.phpeclipse/src/test/PHPParser.jj | 14 ++- 3 files changed, 72 insertions(+), 58 deletions(-) diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java index ce9fd59..145fb87 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/Block.java @@ -27,6 +27,11 @@ public class Block extends Statement { return statements == null; } + /** + * Return the block as String. + * @param tab how many tabs + * @return the string representation of the block + */ public String toString(int tab) { final String s = AstNode.tabString(tab); final StringBuffer buff = new StringBuffer(s); @@ -34,6 +39,7 @@ public class Block extends Statement { if (this.statements == null) { for (int i = 0; i < statements.length; i++) { buff.append(statements[i].toString(tab+1)).append(";\n");//$NON-NLS-1$ + buff.append(statements[i].getClass().getName()).append(";\n");//$NON-NLS-1$ } } buff.append("}\n"); //$NON-NLS-1$ diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index f0ea36f..aba9b11 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -39,8 +39,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ static PHPOutlineInfo outlineInfo; - private static boolean assigning; - /** The error level of the current ParseException. */ private static int errorLevel = ERROR; /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */ @@ -363,9 +361,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ static final public void PhpBlock() throws ParseException { final int start = SimpleCharStream.getPosition(); + final PHPEchoBlock phpEchoBlock; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case PHPECHOSTART: - phpEchoBlock(); + phpEchoBlock = phpEchoBlock(); + pushOnAstNodes(phpEchoBlock); break; case PHPSTARTSHORT: case PHPSTARTLONG: @@ -559,7 +559,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_consume_token(EXTENDS); try { superclassName = jj_consume_token(IDENTIFIER); - superclassNameImage = superclassName .image.toCharArray(); + superclassNameImage = superclassName.image.toCharArray(); } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; @@ -787,7 +787,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon jj_la1[11] = jj_gen; ; } - if (expression == null && !assigning) { + if (expression == null) { {if (true) return token.image.substring(1);} } buff = new StringBuffer(token.image); @@ -809,6 +809,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } +/** + * A Variable name (without the $) + * @return a variable name String + */ static final public String VariableName() throws ParseException { final StringBuffer buff; String expr = null; @@ -5030,24 +5034,6 @@ final int startBlock, endBlock; return retval; } - static final private boolean jj_3R_77() { - if (jj_scan_token(BOOLEAN)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_76() { - if (jj_scan_token(BOOL)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - - static final private boolean jj_3R_43() { - if (jj_3R_52()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_75() { if (jj_scan_token(STRING)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -5955,41 +5941,41 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_94() { - if (jj_scan_token(DOLLAR_ID)) return true; + static final private boolean jj_3R_48() { + if (jj_scan_token(CLASSACCESS)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + if (jj_3R_59()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - xsp = jj_scanpos; - if (jj_3R_98()) jj_scanpos = xsp; - else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_61() { + static final private boolean jj_3R_40() { Token xsp; xsp = jj_scanpos; - if (jj_3R_94()) { + if (jj_3R_48()) { jj_scanpos = xsp; - if (jj_3R_95()) return true; + if (jj_3R_49()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_48() { - if (jj_scan_token(CLASSACCESS)) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - if (jj_3R_59()) return true; + static final private boolean jj_3R_94() { + if (jj_scan_token(DOLLAR_ID)) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + xsp = jj_scanpos; + if (jj_3R_98()) jj_scanpos = xsp; + else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; } - static final private boolean jj_3R_40() { + static final private boolean jj_3R_61() { Token xsp; xsp = jj_scanpos; - if (jj_3R_48()) { + if (jj_3R_94()) { jj_scanpos = xsp; - if (jj_3R_49()) return true; + if (jj_3R_95()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; } else if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; return false; @@ -6067,12 +6053,6 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3_1() { - if (jj_3R_40()) return true; - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - return false; - } - static final private boolean jj_3R_187() { if (jj_3R_50()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6108,15 +6088,9 @@ final int startBlock, endBlock; return false; } - static final private boolean jj_3R_50() { - if (jj_3R_61()) return true; + static final private boolean jj_3_1() { + if (jj_3R_40()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - Token xsp; - while (true) { - xsp = jj_scanpos; - if (jj_3_1()) { jj_scanpos = xsp; break; } - if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; - } return false; } @@ -6133,6 +6107,18 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_50() { + if (jj_3R_61()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + Token xsp; + while (true) { + xsp = jj_scanpos; + if (jj_3_1()) { jj_scanpos = xsp; break; } + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + } + return false; + } + static final private boolean jj_3R_96() { if (jj_3R_102()) return true; if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; @@ -6584,6 +6570,24 @@ final int startBlock, endBlock; return false; } + static final private boolean jj_3R_77() { + if (jj_scan_token(BOOLEAN)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_76() { + if (jj_scan_token(BOOL)) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + + static final private boolean jj_3R_43() { + if (jj_3R_52()) return true; + if (jj_la == 0 && jj_scanpos == jj_lastpos) return false; + return false; + } + static private boolean jj_initialized_once = false; static public PHPParserTokenManager token_source; static SimpleCharStream jj_input_stream; diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.jj b/net.sourceforge.phpeclipse/src/test/PHPParser.jj index 28764a7..2b4a1e9 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.jj +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.jj @@ -60,8 +60,6 @@ public final class PHPParser extends PHPParserSuperclass { private static final String PARSE_WARNING_STRING = "Warning"; //$NON-NLS-1$ static PHPOutlineInfo outlineInfo; - private static boolean assigning; - /** The error level of the current ParseException. */ private static int errorLevel = ERROR; /** The message of the current ParseException. If it's null it's because the parse exception wasn't handled */ @@ -635,9 +633,11 @@ void phpFile() : void PhpBlock() : { final int start = SimpleCharStream.getPosition(); + final PHPEchoBlock phpEchoBlock; } { - phpEchoBlock() + phpEchoBlock = phpEchoBlock() + {pushOnAstNodes(phpEchoBlock);} | [ | @@ -710,7 +710,7 @@ ClassDeclaration ClassDeclaration() : try { superclassName = - {superclassNameImage = superclassName .image.toCharArray();} + {superclassNameImage = superclassName.image.toCharArray();} } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', identifier expected"; errorLevel = ERROR; @@ -894,7 +894,7 @@ String Variable(): { token = [ expression = Expression() ] { - if (expression == null && !assigning) { + if (expression == null) { return token.image.substring(1); } buff = new StringBuffer(token.image); @@ -908,6 +908,10 @@ String Variable(): {return "$" + expr;} } +/** + * A Variable name (without the $) + * @return a variable name String + */ String VariableName(): { final StringBuffer buff; -- 1.7.1