new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParser.java
index 07c6773..4030cca 100644 (file)
@@ -1,25 +1,83 @@
 /* Generated By:JavaCC: Do not edit this line. PHPParser.java */
 package test;
 
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import java.util.Hashtable;
-import java.util.ArrayList;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.Reader;
 import java.io.StringReader;
-import java.io.*;
 import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Hashtable;
 
-import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
-import net.sourceforge.phpeclipse.PHPeclipsePlugin;
-import net.sourceforge.phpdt.internal.compiler.ast.*;
-import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
+import net.sourceforge.phpdt.core.IJavaModelMarker;
+import net.sourceforge.phpdt.internal.compiler.ast.AbstractCase;
+import net.sourceforge.phpdt.internal.compiler.ast.AbstractVariable;
+import net.sourceforge.phpdt.internal.compiler.ast.ArrayDeclarator;
+import net.sourceforge.phpdt.internal.compiler.ast.ArrayInitializer;
+import net.sourceforge.phpdt.internal.compiler.ast.ArrayVariableDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.AstNode;
+import net.sourceforge.phpdt.internal.compiler.ast.BinaryExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.Block;
+import net.sourceforge.phpdt.internal.compiler.ast.Break;
+import net.sourceforge.phpdt.internal.compiler.ast.Case;
+import net.sourceforge.phpdt.internal.compiler.ast.CastExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.ClassAccess;
+import net.sourceforge.phpdt.internal.compiler.ast.ClassDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.ClassInstantiation;
+import net.sourceforge.phpdt.internal.compiler.ast.ConditionalExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.ConstantIdentifier;
+import net.sourceforge.phpdt.internal.compiler.ast.Continue;
+import net.sourceforge.phpdt.internal.compiler.ast.DefaultCase;
+import net.sourceforge.phpdt.internal.compiler.ast.Define;
+import net.sourceforge.phpdt.internal.compiler.ast.DoStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.EchoStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.Else;
+import net.sourceforge.phpdt.internal.compiler.ast.ElseIf;
+import net.sourceforge.phpdt.internal.compiler.ast.EmptyStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.Expression;
+import net.sourceforge.phpdt.internal.compiler.ast.FalseLiteral;
+import net.sourceforge.phpdt.internal.compiler.ast.FieldDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.ForStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.ForeachStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.FunctionCall;
+import net.sourceforge.phpdt.internal.compiler.ast.GlobalStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.HTMLBlock;
+import net.sourceforge.phpdt.internal.compiler.ast.HTMLCode;
+import net.sourceforge.phpdt.internal.compiler.ast.IfStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.InclusionStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.LabeledStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.ListExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.Literal;
+import net.sourceforge.phpdt.internal.compiler.ast.MethodDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.NullLiteral;
+import net.sourceforge.phpdt.internal.compiler.ast.NumberLiteral;
+import net.sourceforge.phpdt.internal.compiler.ast.OperatorIds;
+import net.sourceforge.phpdt.internal.compiler.ast.PHPDocument;
+import net.sourceforge.phpdt.internal.compiler.ast.PHPEchoBlock;
+import net.sourceforge.phpdt.internal.compiler.ast.PostfixedUnaryExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.PrefixedUnaryExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.PrintExpression;
+import net.sourceforge.phpdt.internal.compiler.ast.ReturnStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.Statement;
+import net.sourceforge.phpdt.internal.compiler.ast.StaticStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.StringLiteral;
+import net.sourceforge.phpdt.internal.compiler.ast.SwitchStatement;
+import net.sourceforge.phpdt.internal.compiler.ast.TrueLiteral;
+import net.sourceforge.phpdt.internal.compiler.ast.Variable;
+import net.sourceforge.phpdt.internal.compiler.ast.VariableDeclaration;
+import net.sourceforge.phpdt.internal.compiler.ast.WhileStatement;
 import net.sourceforge.phpdt.internal.compiler.parser.Outlineable;
+import net.sourceforge.phpdt.internal.compiler.parser.OutlineableWithChildren;
 import net.sourceforge.phpdt.internal.compiler.parser.PHPOutlineInfo;
-import net.sourceforge.phpdt.internal.corext.Assert;
+import net.sourceforge.phpeclipse.PHPeclipsePlugin;
+import net.sourceforge.phpeclipse.actions.PHPStartApacheAction;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.ui.texteditor.MarkerUtilities;
 
 /**
  * A new php parser.
@@ -28,7 +86,7 @@ import net.sourceforge.phpdt.internal.corext.Assert;
  * You can test the parser with the PHPParserTestCase2.java
  * @author Matthieu Casanova
  */
-public final class PHPParser extends PHPParserSuperclass implements PHPParserConstants {
+public class PHPParser extends PHPParserSuperclass implements PHPParserConstants {
 
 //todo : fix the variables names bug
 //todo : handle tilde operator
@@ -60,7 +118,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
   //ast stack
   private final static int AstStackIncrement = 100;
   /** The stack of node. */
-  private static AstNode[] nodes;
+  protected static AstNode[] nodes;
   /** The cursor in expression stack. */
   private static int nodePtr;
 
@@ -121,7 +179,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
   /**
    * Reinitialize the parser.
    */
-  private static final void init() {
+  protected static final void init() {
     nodes = new AstNode[AstStackIncrement];
     nodePtr = -1;
     htmlStart = 0;
@@ -209,14 +267,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;
       }
@@ -261,7 +319,8 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
         else
           attributes.put(IMarker.SEVERITY, new Integer(IMarker.SEVERITY_INFO));
         MarkerUtilities.setLineNumber(attributes, lineNumber);
-        MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
+//        MarkerUtilities.createMarker(file, attributes, IMarker.PROBLEM);
+                               MarkerUtilities.createMarker(file, attributes, IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
       }
     }
   }
@@ -312,9 +371,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. */
@@ -335,7 +393,7 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
     }
   }
 
-  private static final void parse() throws ParseException {
+  protected static final void parse() throws ParseException {
           phpFile();
   }
 
@@ -953,7 +1011,7 @@ Token token;
       break;
     case IDENTIFIER:
       token = jj_consume_token(IDENTIFIER);
-   outlineInfo.addVariable("$" + token.image);
+   outlineInfo.addVariable('$' + token.image);
    {if (true) return new Variable(token.image,token.sourceStart,token.sourceEnd);}
       break;
     default:
@@ -1266,7 +1324,7 @@ final Expression expr,expr2;
       ;
     }
     variableDeclaration = VariableDeclaratorNoSuffix();
-    outlineInfo.addVariable("$"+variableDeclaration.name());
+    outlineInfo.addVariable('$'+variableDeclaration.name());
     if (token != null) {
       variableDeclaration.setReference(true);
     }
@@ -1889,7 +1947,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;
@@ -5109,7 +5167,7 @@ Token token;
     }
     try {
       statement = Statement();
-     pos = rparenToken.sourceEnd+1;
+     pos = statement.sourceEnd+1;
     } catch (ParseException e) {
     if (errorMessage != null) {if (true) throw e;}
     errorMessage = "statement expected";
@@ -5122,7 +5180,7 @@ Token token;
                                variable,
                                statement,
                                foreachToken.sourceStart,
-                               statement.sourceEnd);}
+                               pos);}
     throw new Error("Missing return statement in function");
   }
 
@@ -7575,4 +7633,5 @@ final ArrayList list = new ArrayList();
     JJCalls next;
   }
 
+
 }