fixed NPE in Parser ( function catch() )
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 1f76111..264b0ad 100644 (file)
@@ -70,7 +70,7 @@ public class Parser //extends PHPParserSuperclass
   //private boolean phpMode;
   protected int modifiers;
   protected int modifiersSourceStart;
-  protected IdentifierIndexManager indexManager;
+//  protected IdentifierIndexManager indexManager;
   
   protected Parser(ProblemReporter problemReporter) {
     this.problemReporter = problemReporter;
@@ -78,7 +78,7 @@ public class Parser //extends PHPParserSuperclass
     this.currentPHPString = 0;
     //         PHPParserSuperclass.fileToParse = fileToParse;
     this.phpList = null;
-    this.indexManager = null;
+//    this.indexManager = null;
     this.str = "";
     this.token = TokenNameEOF;
     //    this.chIndx = 0;
@@ -92,7 +92,7 @@ public class Parser //extends PHPParserSuperclass
     this.currentPHPString = 0;
     //    PHPParserSuperclass.fileToParse = fileToParse;
     this.phpList = null;
-    this.indexManager = null;
+//    this.indexManager = null;
     this.str = "";
     this.token = TokenNameEOF;
     this.phpEnd = false;
@@ -230,7 +230,7 @@ public class Parser //extends PHPParserSuperclass
     compilationUnit = null;
     referenceContext = null;
     includesList = new ArrayList();
-    this.indexManager = indexManager;
+//    this.indexManager = indexManager;
     this.str = "";
     this.token = TokenNameEOF;
     //    this.chIndx = 0;
@@ -1391,9 +1391,12 @@ public class Parser //extends PHPParserSuperclass
     // | class_variable_declaration ',' T_VARIABLE '=' static_scalar
     // | T_VARIABLE
     // | T_VARIABLE '=' static_scalar
+    char[] classVariable;
     do {
       if (token == TokenNameVariable) {
-        FieldDeclaration fieldDeclaration = new FieldDeclaration(scanner.getCurrentIdentifierSource(), scanner
+        classVariable = scanner.getCurrentIdentifierSource();
+      //  indexManager.addIdentifierInformation('v', classVariable, buf, -1, -1);
+        FieldDeclaration fieldDeclaration = new FieldDeclaration(classVariable, scanner
             .getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
         fieldDeclaration.modifiers = this.modifiers;
         fieldDeclaration.declarationSourceStart = declarationSourceStart;
@@ -1462,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();
@@ -1482,9 +1490,7 @@ public class Parser //extends PHPParserSuperclass
         getNextToken();
       }
     } else {
-      if (token > TokenNameKEYWORD) {
-        throwSyntaxError("Don't use keyword for function declaration [" + token + "].");
-      }
+      methodDecl.selector = "<undefined>".toCharArray();
       throwSyntaxError("Function name expected after keyword 'function'.");
     }
   }