lot of fixes about offsets
[phpeclipse.git] / net.sourceforge.phpeclipse / src / test / PHPParserTokenManager.java
index dcc1814..d823935 100644 (file)
@@ -20,6 +20,14 @@ import net.sourceforge.phpdt.internal.corext.Assert;
 
 public class PHPParserTokenManager implements PHPParserConstants
 {
+  // CommonTokenAction: use the begins/ends fields added to the Jack
+  // CharStream class to set corresponding fields in each Token (which was
+  // also extended with new fields). By default Jack doesn't supply absolute
+  // offsets, just line/column offsets
+  static void CommonTokenAction(Token t) {
+    t.sourceStart = input_stream.beginOffset;
+    t.sourceEnd = input_stream.endOffset;
+  }
   public static  java.io.PrintStream debugStream = System.out;
   public static  void setDebugStream(java.io.PrintStream ds) { debugStream = ds; }
 static private final int jjStopAtPos(int pos, int kind)
@@ -2027,6 +2035,7 @@ public static Token getNextToken()
       jjmatchedKind = 0;
       matchedToken = jjFillToken();
       matchedToken.specialToken = specialToken;
+      CommonTokenAction(matchedToken);
       return matchedToken;
    }
    image = null;
@@ -2094,6 +2103,7 @@ public static Token getNextToken()
            TokenLexicalActions(matchedToken);
        if (jjnewLexState[jjmatchedKind] != -1)
          curLexState = jjnewLexState[jjmatchedKind];
+           CommonTokenAction(matchedToken);
            return matchedToken;
         }
         else if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L)