fix "stack trace" from this post: http://phpeclipse.de/tiki-view_forum_thread.php ?
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Parser.java
index 137bf14..f668f45 100644 (file)
@@ -923,6 +923,8 @@ public class Parser //extends PHPParserSuperclass
     } else if (token == TokenNamefinal || token == TokenNameabstract || token == TokenNameclass || token == TokenNameinterface) {
       TypeDeclaration typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult);
       typeDecl.declarationSourceStart = scanner.getCurrentTokenStartPosition();
+      typeDecl.declarationSourceEnd = scanner.getCurrentTokenEndPosition();
+      typeDecl.name = new char[]{' '};
       // default super class
       typeDecl.superclass = new SingleTypeReference(TypeConstants.OBJECT, 0);
       compilationUnit.types.add(typeDecl);
@@ -1093,19 +1095,19 @@ public class Parser //extends PHPParserSuperclass
       checkAndSetModifiers(AccInterface);
       getNextToken();
       typeDecl.modifiers = this.modifiers;
+      typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
+      typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
       if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
-        typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
-        typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
         typeDecl.name = scanner.getCurrentIdentifierSource();
         if (token > TokenNameKEYWORD) {
-          throwSyntaxError("Don't use a keyword for interface declaration [" + scanner.toStringAction(token) + "].",
-              typeDecl.sourceStart, typeDecl.sourceEnd);
+          problemReporter.phpKeywordWarning(new String[]{scanner.toStringAction(token)}, scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(),
+              referenceContext, compilationUnit.compilationResult);
+//          throwSyntaxError("Don't use a keyword for interface declaration [" + scanner.toStringAction(token) + "].",
+//              typeDecl.sourceStart, typeDecl.sourceEnd);
         }
         getNextToken();
         interface_extends_list();
       } else {
-        typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
-        typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
         typeDecl.name = new char[]{' '};
         throwSyntaxError("Interface name expected after keyword 'interface'.", typeDecl.sourceStart, typeDecl.sourceEnd);
         return;
@@ -1116,15 +1118,17 @@ public class Parser //extends PHPParserSuperclass
       //               '{' class_statement_list'}'
       class_entry_type();
       typeDecl.modifiers = this.modifiers;
+      typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
+      typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
       //identifier
       //identifier 'extends' identifier
       if (token == TokenNameIdentifier || token > TokenNameKEYWORD) {
-        typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
-        typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
         typeDecl.name = scanner.getCurrentIdentifierSource();
         if (token > TokenNameKEYWORD) {
-          throwSyntaxError("Don't use a keyword for class declaration [" + scanner.toStringAction(token) + "].",
-              typeDecl.sourceStart, typeDecl.sourceEnd);
+          problemReporter.phpKeywordWarning(new String[]{scanner.toStringAction(token)}, scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(),
+              referenceContext, compilationUnit.compilationResult);
+//          throwSyntaxError("Don't use a keyword for class declaration [" + scanner.toStringAction(token) + "].",
+//              typeDecl.sourceStart, typeDecl.sourceEnd);
         }
         getNextToken();
         //    extends_from:
@@ -1142,8 +1146,6 @@ public class Parser //extends PHPParserSuperclass
         }
         implements_list();
       } else {
-        typeDecl.sourceStart = scanner.getCurrentTokenStartPosition();
-        typeDecl.sourceEnd = scanner.getCurrentTokenEndPosition();
         typeDecl.name = new char[]{' '};
         throwSyntaxError("Class name expected after keyword 'class'.", typeDecl.sourceStart, typeDecl.sourceEnd);
         return;
@@ -1258,7 +1260,7 @@ public class Parser //extends PHPParserSuperclass
     //    '(' parameter_list ')' method_body
     initializeModifiers();
     int declarationSourceStart = scanner.getCurrentTokenStartPosition();
-    ;
+    
     if (token == TokenNamevar) {
       checkAndSetModifiers(AccPublic);
       problemReporter.phpVarDeprecatedWarning(scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(),
@@ -1477,9 +1479,10 @@ public class Parser //extends PHPParserSuperclass
     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) + "].");
+        problemReporter.phpKeywordWarning(new String[]{scanner.toStringAction(token)}, scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition(),
+            referenceContext, compilationUnit.compilationResult);
+//        reportSyntaxWarning("Don't use keyword for function declaration [" + scanner.toStringAction(token) + "].",
+//          scanner.getCurrentTokenStartPosition(), scanner.getCurrentTokenEndPosition());
       }
       getNextToken();
       if (token == TokenNameLPAREN) {
@@ -1488,7 +1491,7 @@ public class Parser //extends PHPParserSuperclass
         throwSyntaxError("'(' expected in function declaration.");
       }
       if (token != TokenNameRPAREN) {
-        parameter_list();
+        parameter_list(); 
       }
       if (token != TokenNameRPAREN) {
         throwSyntaxError("')' expected in function declaration.");
@@ -2461,14 +2464,21 @@ public class Parser //extends PHPParserSuperclass
     //| class_constant '(' function_call_parameter_list ')'
     //| static_member '(' function_call_parameter_list ')'
     //| variable_without_objects '(' function_call_parameter_list ')'
+    char[] defineName = null;
+    int startPos=0;
+    int endPos=0;
     if (Scanner.TRACE) {
       System.out.println("TRACE: function_call()");
     }
     if (token == TokenNameIdentifier) {
+      defineName = scanner.getCurrentIdentifierSource();
+      startPos = scanner.getCurrentTokenStartPosition();
+      endPos = scanner.getCurrentTokenEndPosition();
       getNextToken();
       switch (token) {
         case TokenNamePAAMAYIM_NEKUDOTAYIM :
           // static member:
+          defineName = null;
           getNextToken();
           if (token == TokenNameIdentifier) {
             // class _constant
@@ -2483,6 +2493,45 @@ public class Parser //extends PHPParserSuperclass
       variable_without_objects();
     }
     if (token != TokenNameLPAREN) {
+      if (defineName!=null) {
+        // does this identifier contain only uppercase characters?
+        if (defineName.length==3) {
+          if (defineName[0]=='d' &&
+              defineName[1]=='i' &&
+              defineName[2]=='e' ) {
+            defineName=null;
+          } 
+        } else if (defineName.length==4) {
+          if (defineName[0]=='t' &&
+              defineName[1]=='r' &&
+              defineName[2]=='u' &&
+              defineName[3]=='e' ) {
+            defineName=null;
+          } else if (defineName[0]=='n' &&
+              defineName[1]=='u' &&
+              defineName[2]=='l' &&
+              defineName[3]=='l' ) {
+            defineName=null;
+          }
+        } else if (defineName.length==5) {
+          if (defineName[0]=='f' &&
+              defineName[1]=='a' &&
+              defineName[2]=='l' &&
+              defineName[3]=='s' &&
+              defineName[4]=='e' ) {
+            defineName=null;
+          }
+        }
+        if (defineName!=null) {
+          for (int i=0; i<defineName.length;i++) {
+            if (Character.isLowerCase(defineName[i])) {  
+              problemReporter.phpUppercaseIdentifierWarning(startPos, endPos,
+                referenceContext, compilationUnit.compilationResult);
+              break;
+            }
+          }
+        }
+      }
       // TODO is this ok ?
       return;
       //      throwSyntaxError("'(' expected in function call.");