X-Git-Url: http://git.phpeclipse.com diff --git a/net.sourceforge.phpeclipse/src/test/PHPParser.java b/net.sourceforge.phpeclipse/src/test/PHPParser.java index d559705..301d62c 100644 --- a/net.sourceforge.phpeclipse/src/test/PHPParser.java +++ b/net.sourceforge.phpeclipse/src/test/PHPParser.java @@ -209,14 +209,14 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon e.currentToken.sourceStart, e.currentToken.sourceEnd, errorLevel, - "Line " + e.currentToken.beginLine+", "+e.currentToken.sourceStart+":"+e.currentToken.sourceEnd); + "Line " + e.currentToken.beginLine+", "+e.currentToken.sourceStart+':'+e.currentToken.sourceEnd); } else { setMarker(fileToParse, errorMessage, errorStart, errorEnd, errorLevel, - "Line " + e.currentToken.beginLine+", "+errorStart+":"+errorEnd); + "Line " + e.currentToken.beginLine+", "+errorStart+':'+errorEnd); errorStart = -1; errorEnd = -1; } @@ -312,9 +312,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon currentPosition > SimpleCharStream.currentBuffer.length()) { return; } - final char[] chars = SimpleCharStream.currentBuffer.substring(htmlStart, - currentPosition).toCharArray(); - pushOnAstNodes(new HTMLCode(chars, htmlStart,currentPosition)); + final String html = SimpleCharStream.currentBuffer.substring(htmlStart, currentPosition); + pushOnAstNodes(new HTMLCode(html, htmlStart,currentPosition)); } /** Create a new task. */ @@ -518,8 +517,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon } catch (ParseException e) { errorMessage = "'?>' expected"; errorLevel = ERROR; - errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = SimpleCharStream.getPosition() + 1; + errorStart = e.currentToken.sourceStart; + errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); } break; @@ -686,8 +685,8 @@ Token token; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image + "'. '{' expected"; errorLevel = ERROR; - errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = SimpleCharStream.getPosition() + 1; + errorStart = e.currentToken.sourceStart; + errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); } label_3: @@ -709,8 +708,8 @@ Token token; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"'. 'var', 'function' or '}' expected"; errorLevel = ERROR; - errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = SimpleCharStream.getPosition() + 1; + errorStart = e.currentToken.sourceStart; + errorEnd = e.currentToken.sourceEnd; processParseExceptionDebug(e); {if (true) return PHPParser.token.sourceEnd;} } @@ -754,7 +753,6 @@ Token token; token = jj_consume_token(VAR); variableDeclaration = VariableDeclaratorNoSuffix(); arrayList.add(variableDeclaration); - outlineInfo.addVariable(variableDeclaration.name()); pos = variableDeclaration.sourceEnd; label_4: while (true) { @@ -917,8 +915,8 @@ Token token; } catch (ParseException e) { errorMessage = "'$' expected for variable identifier"; errorLevel = ERROR; - errorStart = SimpleCharStream.getPosition() - e.currentToken.next.image.length() + 1; - errorEnd = SimpleCharStream.getPosition() + 1; + errorStart = e.currentToken.sourceStart; + errorEnd = e.currentToken.sourceEnd; {if (true) throw e;} } throw new Error("Missing return statement in function"); @@ -954,6 +952,7 @@ Token token; break; case IDENTIFIER: token = jj_consume_token(IDENTIFIER); + outlineInfo.addVariable('$' + token.image); {if (true) return new Variable(token.image,token.sourceStart,token.sourceEnd);} break; default: @@ -1125,8 +1124,8 @@ final Expression expr,expr2; if (errorMessage != null) {if (true) throw 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; + errorStart = e.currentToken.sourceStart; + errorEnd = e.currentToken.sourceEnd; {if (true) throw e;} } currentSegment = functionDeclaration; @@ -1145,7 +1144,7 @@ final Expression expr,expr2; static final public MethodDeclaration MethodDeclarator(final int start) throws ParseException { Token identifier = null; Token reference = null; - final Hashtable formalParameters = new Hashtable(); + final ArrayList formalParameters = new ArrayList(); String identifierChar = SYNTAX_ERROR_CHAR; int end = start; switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1197,7 +1196,7 @@ final Expression expr,expr2; * FormalParameters follows method identifier. * (FormalParameter()) */ - static final public int FormalParameters(final Hashtable parameters) throws ParseException { + static final public int FormalParameters(final ArrayList parameters) throws ParseException { VariableDeclaration var; final Token token; Token tok = PHPParser.token; @@ -1216,7 +1215,7 @@ final Expression expr,expr2; case BIT_AND: case DOLLAR: var = FormalParameter(); - parameters.put(var.name(),var);end = var.sourceEnd; + parameters.add(var);end = var.sourceEnd; label_7: while (true) { switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { @@ -1229,7 +1228,7 @@ final Expression expr,expr2; } jj_consume_token(COMMA); var = FormalParameter(); - parameters.put(var.name(),var);end = var.sourceEnd; + parameters.add(var);end = var.sourceEnd; } break; default: @@ -1266,6 +1265,7 @@ final Expression expr,expr2; ; } variableDeclaration = VariableDeclaratorNoSuffix(); + outlineInfo.addVariable('$'+variableDeclaration.name()); if (token != null) { variableDeclaration.setReference(true); } @@ -1888,7 +1888,7 @@ final Expression expr,expr2; expr = UnaryExpression(); } catch (ParseException e) { if (errorMessage != null) {if (true) throw e;} - errorMessage = "unexpected token '"+e.currentToken.next.image+"'"; + errorMessage = "unexpected token '"+e.currentToken.next.image+'\''; errorLevel = ERROR; errorStart = PHPParser.token.sourceStart; errorEnd = PHPParser.token.sourceEnd; @@ -2720,8 +2720,8 @@ final Token token,token1; static final public FunctionCall Arguments(final Expression func) throws ParseException { Expression[] args = null; -final Token token; - jj_consume_token(LPAREN); +final Token token,lparen; + lparen = jj_consume_token(LPAREN); switch ((jj_ntk==-1)?jj_ntk():jj_ntk) { case ARRAY: case LIST: @@ -2757,11 +2757,17 @@ final Token token; } catch (ParseException e) { errorMessage = "unexpected token : '"+ e.currentToken.next.image +"', ')' expected to close the argument list"; errorLevel = ERROR; - errorStart = args[args.length-1].sourceEnd+1; - errorEnd = args[args.length-1].sourceEnd+1; + if (args == null) { + errorStart = lparen.sourceEnd+1; + errorEnd = lparen.sourceEnd+2; + } else { + errorStart = args[args.length-1].sourceEnd+1; + errorEnd = args[args.length-1].sourceEnd+2; + } processParseExceptionDebug(e); } - {if (true) return new FunctionCall(func,args,args[args.length-1].sourceEnd);} + int sourceEnd = (args == null && args.length != 0) ? lparen.sourceEnd+1 : args[args.length-1].sourceEnd; + {if (true) return new FunctionCall(func,args,sourceEnd);} throw new Error("Missing return statement in function"); } @@ -3100,8 +3106,8 @@ Token token; } catch (ParseException e) { errorMessage = "unexpected end of file , '