X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index aba9b11..8b59f42 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -8,7 +8,6 @@ import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.jface.preference.IPreferenceStore; import java.util.Hashtable; -import java.util.Enumeration; import java.util.ArrayList; import java.io.StringReader; import java.io.*; @@ -167,31 +166,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } } - /** - * Create markers according to the external parser output - */ - private static void createMarkers(final String output, final IFile file) throws CoreException { - // delete all markers - file.deleteMarkers(IMarker.PROBLEM, false, 0); - - int indx = 0; - int brIndx; - boolean flag = true; - while ((brIndx = output.indexOf("
", indx)) != -1) { - // newer php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 6; - flag = false; - } - if (flag) { - while ((brIndx = output.indexOf("
", indx)) != -1) { - // older php error output (tested with 4.2.3) - scanLine(output, file, indx, brIndx); - indx = brIndx + 4; - } - } - } - private static void scanLine(final String output, final IFile file, final int indx, @@ -281,6 +255,25 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition)); } + /** + * Create a new task. + */ + public static final void createNewTask() { + final int currentPosition = SimpleCharStream.getPosition(); + final String todo = SimpleCharStream.currentBuffer.substring(currentPosition+1, + SimpleCharStream.currentBuffer.indexOf("\n", + currentPosition)-1); + try { + setMarker(fileToParse, + "todo : " + todo, + SimpleCharStream.getBeginLine(), + TASK, + "Line "+SimpleCharStream.getBeginLine()); + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + private static final void parse() throws ParseException { phpFile(); } @@ -343,7 +336,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } PhpBlock(); } - jj_consume_token(0); + PHPParser.createNewHTMLCode(); } catch (TokenMgrError e) { PHPeclipsePlugin.log(e); errorStart = SimpleCharStream.getPosition(); @@ -638,10 +631,11 @@ 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: field = FieldDeclaration(); + classDeclaration.addField(field); break; default: jj_la1[8] = jj_gen; @@ -662,7 +656,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon variableDeclaration = VariableDeclarator(); arrayList.add(variableDeclaration); outlineInfo.addVariable(new String(variableDeclaration.name)); - currentSegment.add(variableDeclaration); label_4: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -677,7 +670,6 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon variableDeclaration = VariableDeclarator(); arrayList.add(variableDeclaration); outlineInfo.addVariable(new String(variableDeclaration.name)); - currentSegment.add(variableDeclaration); } try { jj_consume_token(SEMICOLON); @@ -738,13 +730,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon */ static final public String VariableDeclaratorId() throws ParseException { String expr; - Expression expression; + Expression expression = null; final StringBuffer buff = new StringBuffer(); final int pos = SimpleCharStream.getPosition(); ConstantIdentifier ex; try { expr = Variable(); - buff.append(expr); label_5: while (true) { if (jj_2_1(2)) { @@ -756,9 +747,11 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon pos, SimpleCharStream.getPosition()); expression = VariableSuffix(ex); - buff.append(expression.toStringExpression()); } - {if (true) return buff.toString();} + if (expression == null) { + {if (true) return expr;} + } + {if (true) return expression.toStringExpression();} } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; @@ -769,6 +762,10 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon throw new Error("Missing return statement in function"); } +/** + * Return a variablename without the $. + * @return a variable name + */ static final public String Variable() throws ParseException { final StringBuffer buff; Expression expression = null; @@ -799,7 +796,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; @@ -1022,6 +1019,7 @@ Expression expr,expr2; static final public MethodDeclaration MethodDeclaration() throws ParseException { final MethodDeclaration functionDeclaration; final Block block; + final OutlineableWithChildren seg = currentSegment; jj_consume_token(FUNCTION); try { functionDeclaration = MethodDeclarator(); @@ -1034,16 +1032,11 @@ Expression expr,expr2; errorEnd = SimpleCharStream.getPosition() + 1; {if (true) throw e;} } - if (currentSegment != null) { - currentSegment.add(functionDeclaration); - currentSegment = functionDeclaration; - } + currentSegment = functionDeclaration; block = Block(); - functionDeclaration.statements = block.statements; - if (currentSegment != null) { - currentSegment = (OutlineableWithChildren) currentSegment.getParent(); - } - {if (true) return functionDeclaration;} + functionDeclaration.statements = block.statements; + currentSegment = seg; + {if (true) return functionDeclaration;} throw new Error("Missing return statement in function"); } @@ -1078,11 +1071,11 @@ Expression expr,expr2; } formalParameters = FormalParameters(); {if (true) return new MethodDeclaration(currentSegment, - identifierChar, - formalParameters, - reference != null, - pos, - SimpleCharStream.getPosition());} + identifierChar, + formalParameters, + reference != null, + pos, + SimpleCharStream.getPosition());} throw new Error("Missing return statement in function"); } @@ -1100,7 +1093,7 @@ Expression expr,expr2; 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 DOLLAR: @@ -1134,7 +1127,7 @@ Expression expr,expr2; errorLevel = ERROR; errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; errorEnd = SimpleCharStream.getPosition() + 1; - {if (true) throw e;} + processParseException(e); } {if (true) return parameters;} throw new Error("Missing return statement in function"); @@ -1275,13 +1268,13 @@ Expression expr,expr2; */ static final public VarAssignation varAssignation() throws ParseException { String varName; - final Expression expression; + final Expression initializer; final int assignOperator; final int pos = SimpleCharStream.getPosition(); varName = VariableDeclaratorId(); assignOperator = AssignmentOperator(); try { - expression = Expression(); + initializer = Expression(); } catch (ParseException e) { if (errorMessage != null) { {if (true) throw e;} @@ -1293,7 +1286,7 @@ Expression expr,expr2; {if (true) throw e;} } {if (true) return new VarAssignation(varName.toCharArray(), - expression, + initializer, assignOperator, pos, SimpleCharStream.getPosition());} @@ -2693,7 +2686,7 @@ final ArrayList list = new ArrayList(); throw new ParseException(); } } catch (ParseException e) { - errorMessage = "End of file unexpected, '= 0) { @@ -6841,7 +6837,7 @@ final int startBlock, endBlock; } } } - for (int i = 0; i < 141; i++) { + for (int i = 0; i < 142; i++) { if (la1tokens[i]) { jj_expentry = new int[1]; jj_expentry[0] = i;