Show line numbers (other than 1) in problems view for errors and warnings
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index 4ed6bf2..6d3e4a8 100644 (file)
@@ -213,9 +213,19 @@ public class Scanner implements IScanner, ITerminalSymbols {
   public ICompilationUnit compilationUnit = null;
 
   /**
+   * Determines if the specified character is permissible as the first character in a PHP identifier or variable
+   * 
+   * The '$' character for PHP variables is regarded as a correct first character !
+   *  
+   */
+  public static boolean isPHPIdentOrVarStart(char ch) {
+    return Character.isLetter(ch) || (ch == '$') || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
+  }
+
+  /**
    * Determines if the specified character is permissible as the first character in a PHP identifier.
    * 
-   * The '$' character for HP variables isn't regarded as the first character !
+   * The '$' character for PHP variables isn't regarded as the first character !
    */
   public static boolean isPHPIdentifierStart(char ch) {
     return Character.isLetter(ch) || (ch == '_') || (0x7F <= ch && ch <= 0xFF);
@@ -323,6 +333,13 @@ public class Scanner implements IScanner, ITerminalSymbols {
     return result;
   }
 
+  public final char[] getRawTokenSourceEnd() {
+    int length = this.eofPosition - this.currentPosition - 1;
+    char[] sourceEnd = new char[length];
+    System.arraycopy(this.source, this.currentPosition, sourceEnd, 0, length);
+    return sourceEnd;
+  }
+
   public int getCurrentTokenStartPosition() {
     return this.startPosition;
   }
@@ -933,6 +950,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
               withoutUnicodePtr--;
             }
           }
+        } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+          if (recordLineSeparator) {
+            pushLineSeparator();
+          }
         }
         // consume next character
         unicodeAsBackSlash = false;
@@ -1029,6 +1050,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
               withoutUnicodePtr--;
             }
           }
+        } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+          if (recordLineSeparator) {
+            pushLineSeparator();
+          }
         }
         // consume next character
         unicodeAsBackSlash = false;
@@ -1125,6 +1150,10 @@ public class Scanner implements IScanner, ITerminalSymbols {
               withoutUnicodePtr--;
             }
           }
+        } else if ((currentCharacter == '\r') || (currentCharacter == '\n')) {
+          if (recordLineSeparator) {
+            pushLineSeparator();
+          }
         }
         // consume next character
         unicodeAsBackSlash = false;
@@ -1223,6 +1252,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
                   }
                 }
                 break;
+              case '\r':
+              case '\n':
+                if (recordLineSeparator) {
+                  pushLineSeparator();
+                }
+                break;
               case '$':
                 if (isPHPIdentifierStart(source[currentPosition]) || source[currentPosition] == '{') {
                   currentPosition--;
@@ -4237,8 +4272,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
             continue nextTag;
 
           // ensure tag is not leaded with letter if tag starts with a letter
-          if (Character.isJavaIdentifierStart(tag[0])) {
-            if (Character.isJavaIdentifierPart(previous)) {
+          if (Scanner.isPHPIdentifierStart(tag[0])) {
+            if (Scanner.isPHPIdentifierPart(previous)) {
               continue nextTag;
             }
           }
@@ -4255,8 +4290,8 @@ public class Scanner implements IScanner, ITerminalSymbols {
             }
           }
           // ensure tag is not followed with letter if tag finishes with a letter
-          if (i + tagLength < commentEnd && Character.isJavaIdentifierPart(src[i + tagLength - 1])) {
-            if (Character.isJavaIdentifierPart(src[i + tagLength]))
+          if (i + tagLength < commentEnd && Scanner.isPHPIdentifierPart(src[i + tagLength - 1])) {
+            if (Scanner.isPHPIdentifierPart(src[i + tagLength]))
               continue nextTag;
           }
           if (this.foundTaskTags == null) {