From: khartlage Date: Sun, 11 Jul 2004 08:33:44 +0000 (+0000) Subject: fixed NPE in Parser ( function catch() ) X-Git-Url: http://git.phpeclipse.com fixed NPE in Parser ( function catch() ) --- 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 45fa6e4..264b0ad 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 @@ -1465,10 +1465,15 @@ public class Parser //extends PHPParserSuperclass if (token == TokenNameAND) { getNextToken(); } - if (token == TokenNameIdentifier) { - methodDecl.sourceStart = scanner.getCurrentTokenStartPosition(); - methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition(); + methodDecl.sourceStart = scanner.getCurrentTokenStartPosition(); + methodDecl.sourceEnd = scanner.getCurrentTokenEndPosition(); + if (Scanner.isIdentifierOrKeyword(token)) { methodDecl.selector = scanner.getCurrentIdentifierSource(); + if (token > TokenNameKEYWORD) { + reportSyntaxWarning("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].", + scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition()); +// throwSyntaxError("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "]."); + } getNextToken(); if (token == TokenNameLPAREN) { getNextToken(); @@ -1485,9 +1490,7 @@ public class Parser //extends PHPParserSuperclass getNextToken(); } } else { - if (token > TokenNameKEYWORD) { - throwSyntaxError("Don't use keyword for function declaration [" + token + "]."); - } + methodDecl.selector = "".toCharArray(); throwSyntaxError("Function name expected after keyword 'function'."); } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java index c1098d5..0544363 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Scanner.java @@ -2259,6 +2259,9 @@ public class Scanner implements IScanner, ITerminalSymbols { public char[] getSource() { return this.source; } + public static boolean isIdentifierOrKeyword(int token) { + return (token == TokenNameIdentifier) || (token > TokenNameKEYWORD); + } final char[] optimizedCurrentTokenSource1() { //return always the same char[] build only once //optimization at no speed cost of 99.5 % of the singleCharIdentifier