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 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, '