*** empty log message ***
authorkpouer <kpouer>
Thu, 1 May 2003 14:06:00 +0000 (14:06 +0000)
committerkpouer <kpouer>
Thu, 1 May 2003 14:06:00 +0000 (14:06 +0000)
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/ast/VariableDeclaration.java
net.sourceforge.phpeclipse/src/test/PHPParser.java
net.sourceforge.phpeclipse/src/test/PHPParser.jj

index 4ba1ba5..25ae677 100644 (file)
@@ -33,6 +33,21 @@ public class VariableDeclaration extends AbstractVariableDeclaration implements
     this.parent = parent;
   }
 
+  /**
+   * Create a variable.
+   * @param initialization the initialization
+   * @param name the name of the variable
+   * @param sourceStart the start point
+   */
+  public VariableDeclaration(Object parent,
+                             char[] name,
+                             int sourceStart,
+                             int sourceEnd) {
+    super(name, sourceStart, sourceEnd);
+    this.initialization = initialization;
+    this.parent = parent;
+  }
+
   public void setReference(boolean reference) {
     this.reference = reference;
   }
index f7bc34d..4351df6 100644 (file)
@@ -606,12 +606,12 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
     if (superclassName == null) {
       classDeclaration = new ClassDeclaration(currentSegment,
                                               className.image.toCharArray(),
-                                              superclassName.image.toCharArray(),
                                               pos,
                                               0);
     } else {
       classDeclaration = new ClassDeclaration(currentSegment,
                                               className.image.toCharArray(),
+                                              superclassName.image.toCharArray(),
                                               pos,
                                               0);
     }
@@ -686,12 +686,13 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
  */
   static final public FieldDeclaration FieldDeclaration() throws ParseException {
   VariableDeclaration variableDeclaration;
+  final ArrayList list = new ArrayList();
+  final int pos = SimpleCharStream.getPosition();
     jj_consume_token(VAR);
     variableDeclaration = VariableDeclarator();
+    list.add(variableDeclaration);
     outlineInfo.addVariable(new String(variableDeclaration.name));
-    if (currentSegment != null) {
-      currentSegment.add(variableDeclaration);
-    }
+    currentSegment.add(variableDeclaration);
     label_4:
     while (true) {
       switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
@@ -704,9 +705,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
       }
       jj_consume_token(COMMA);
       variableDeclaration = VariableDeclarator();
-      if (currentSegment != null) {
-        currentSegment.add(variableDeclaration);
-      }
+       list.add(variableDeclaration);
+       outlineInfo.addVariable(new String(variableDeclaration.name));
+       currentSegment.add(variableDeclaration);
     }
     try {
       jj_consume_token(SEMICOLON);
@@ -717,6 +718,9 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
     errorEnd   = jj_input_stream.getPosition() + 1;
     {if (true) throw e;}
     }
+   {if (true) return new FieldDeclaration((VariableDeclaration[]) list.toArray(),
+                               pos,
+                               SimpleCharStream.getPosition());}
     throw new Error("Missing return statement in function");
   }
 
@@ -742,10 +746,16 @@ public final class PHPParser extends PHPParserSuperclass implements PHPParserCon
       jj_la1[10] = jj_gen;
       ;
     }
-   {if (true) return new VariableDeclaration(currentSegment,
+  if (initializer == null) {
+    {if (true) return new VariableDeclaration(currentSegment,
                                   varName.toCharArray(),
-                                  initializer,
-                                  pos);}
+                                  pos,
+                                  jj_input_stream.getPosition());}
+  }
+    {if (true) return new VariableDeclaration(currentSegment,
+                                    varName.toCharArray(),
+                                    initializer,
+                                    pos);}
     throw new Error("Missing return statement in function");
   }
 
@@ -3270,19 +3280,28 @@ final ArrayList list = new ArrayList();
 
   static final public VariableDeclaration LocalVariableDeclarator() throws ParseException {
   final String varName;
-  Expression init = null;
+  Expression initializer = null;
   final int pos = SimpleCharStream.getPosition();
     varName = VariableDeclaratorId();
     switch ((jj_ntk==-1)?jj_ntk():jj_ntk) {
     case ASSIGN:
       jj_consume_token(ASSIGN);
-      init = Expression();
+      initializer = Expression();
       break;
     default:
       jj_la1[88] = jj_gen;
       ;
     }
-   {if (true) return new VariableDeclaration(varName.toCharArray(),init,pos);}
+   if (initializer == null) {
+    {if (true) return new VariableDeclaration(currentSegment,
+                                  varName.toCharArray(),
+                                  pos,
+                                  jj_input_stream.getPosition());}
+   }
+    {if (true) return new VariableDeclaration(currentSegment,
+                                    varName.toCharArray(),
+                                    initializer,
+                                    pos);}
     throw new Error("Missing return statement in function");
   }
 
@@ -4965,18 +4984,6 @@ final int startBlock, endBlock;
     return retval;
   }
 
-  static final private boolean jj_3R_160() {
-    if (jj_scan_token(DECR)) return true;
-    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
-    return false;
-  }
-
-  static final private boolean jj_3R_159() {
-    if (jj_scan_token(INCR)) return true;
-    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
-    return false;
-  }
-
   static final private boolean jj_3R_157() {
     Token xsp;
     xsp = jj_scanpos;
@@ -6105,6 +6112,12 @@ final int startBlock, endBlock;
     return false;
   }
 
+  static final private boolean jj_3_8() {
+    if (jj_3R_47()) return true;
+    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+    return false;
+  }
+
   static final private boolean jj_3R_182() {
     if (jj_scan_token(ARRAY)) return true;
     if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -6119,12 +6132,6 @@ final int startBlock, endBlock;
     return false;
   }
 
-  static final private boolean jj_3_8() {
-    if (jj_3R_47()) return true;
-    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
-    return false;
-  }
-
   static final private boolean jj_3R_181() {
     if (jj_3R_188()) return true;
     if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
@@ -6519,6 +6526,18 @@ final int startBlock, endBlock;
     return false;
   }
 
+  static final private boolean jj_3R_160() {
+    if (jj_scan_token(DECR)) return true;
+    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+    return false;
+  }
+
+  static final private boolean jj_3R_159() {
+    if (jj_scan_token(INCR)) return true;
+    if (jj_la == 0 && jj_scanpos == jj_lastpos) return false;
+    return false;
+  }
+
   static private boolean jj_initialized_once = false;
   static public PHPParserTokenManager token_source;
   static SimpleCharStream jj_input_stream;
index 823b11e..44e28d2 100644 (file)
@@ -757,12 +757,12 @@ ClassDeclaration ClassDeclaration() :
     if (superclassName == null) {
       classDeclaration = new ClassDeclaration(currentSegment,
                                               className.image.toCharArray(),
-                                              superclassName.image.toCharArray(),
                                               pos,
                                               0);
     } else {
       classDeclaration = new ClassDeclaration(currentSegment,
                                               className.image.toCharArray(),
+                                              superclassName.image.toCharArray(),
                                               pos,
                                               0);
     }
@@ -819,22 +819,21 @@ void ClassBodyDeclaration(ClassDeclaration classDeclaration) :
 FieldDeclaration FieldDeclaration() :
 {
   VariableDeclaration variableDeclaration;
+  final ArrayList list = new ArrayList();
+  final int pos = SimpleCharStream.getPosition();
 }
 {
   <VAR> variableDeclaration = VariableDeclarator()
   {
+    list.add(variableDeclaration);
     outlineInfo.addVariable(new String(variableDeclaration.name));
-    if (currentSegment != null) {
-      currentSegment.add(variableDeclaration);
-    }
+    currentSegment.add(variableDeclaration);
   }
   ( <COMMA>
       variableDeclaration = VariableDeclarator()
-      {
-      if (currentSegment != null) {
-        currentSegment.add(variableDeclaration);
-      }
-      }
+      {list.add(variableDeclaration);
+       outlineInfo.addVariable(new String(variableDeclaration.name));
+       currentSegment.add(variableDeclaration);}
   )*
   try {
     <SEMICOLON>
@@ -845,6 +844,9 @@ FieldDeclaration FieldDeclaration() :
     errorEnd   = jj_input_stream.getPosition() + 1;
     throw e;
   }
+  {return new FieldDeclaration((VariableDeclaration[]) list.toArray(),
+                               pos,
+                               SimpleCharStream.getPosition());}
 }
 
 VariableDeclaration VariableDeclarator() :
@@ -867,10 +869,18 @@ VariableDeclaration VariableDeclarator() :
       throw e;
     }
   ]
-  {return new VariableDeclaration(currentSegment,
+  {
+  if (initializer == null) {
+    return new VariableDeclaration(currentSegment,
                                   varName.toCharArray(),
-                                  initializer,
-                                  pos);}
+                                  pos,
+                                  jj_input_stream.getPosition());
+  }
+    return new VariableDeclaration(currentSegment,
+                                    varName.toCharArray(),
+                                    initializer,
+                                    pos);
+  }
 }
 
 /**
@@ -2139,12 +2149,23 @@ VariableDeclaration[] LocalVariableDeclaration() :
 VariableDeclaration LocalVariableDeclarator() :
 {
   final String varName;
-  Expression init = null;
+  Expression initializer = null;
   final int pos = SimpleCharStream.getPosition();
 }
 {
-  varName = VariableDeclaratorId() [ <ASSIGN> init = Expression() ]
-  {return new VariableDeclaration(varName.toCharArray(),init,pos);}
+  varName = VariableDeclaratorId() [ <ASSIGN> initializer = Expression() ]
+  {
+   if (initializer == null) {
+    return new VariableDeclaration(currentSegment,
+                                  varName.toCharArray(),
+                                  pos,
+                                  jj_input_stream.getPosition());
+   }
+    return new VariableDeclaration(currentSegment,
+                                    varName.toCharArray(),
+                                    initializer,
+                                    pos);
+  }
 }
 
 EmptyStatement EmptyStatement() :