Parser detects wrong include files now
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / parser / Scanner.java
index 9146cc7..7d96e62 100644 (file)
@@ -16,6 +16,7 @@ import net.sourceforge.phpdt.core.compiler.CharOperation;
 import net.sourceforge.phpdt.core.compiler.IScanner;
 import net.sourceforge.phpdt.core.compiler.ITerminalSymbols;
 import net.sourceforge.phpdt.core.compiler.InvalidInputException;
+import net.sourceforge.phpdt.internal.compiler.env.ICompilationUnit;
 import net.sourceforge.phpeclipse.internal.compiler.ast.StringLiteral;
 
 public class Scanner implements IScanner, ITerminalSymbols {
@@ -196,6 +197,7 @@ public class Scanner implements IScanner, ITerminalSymbols {
 
   public static final boolean TRACE = false;
 
+  public ICompilationUnit compilationUnit = null;
   /**
    * Determines if the specified character is permissible as the first character in a PHP identifier
    */
@@ -311,6 +313,9 @@ public class Scanner implements IScanner, ITerminalSymbols {
 
   public final char[] getCurrentStringLiteralSource() {
     // Return the token REAL source (aka unicodes are precomputed)
+    if (startPosition + 1 >= currentPosition) {
+      return new char[0];
+    }
     char[] result;
     int length;
     System.arraycopy(source, startPosition + 1, result = new char[length = currentPosition - startPosition - 2], 0, length);
@@ -318,6 +323,14 @@ public class Scanner implements IScanner, ITerminalSymbols {
     return result;
   }
 
+  public final char[] getCurrentStringLiteralSource(int startPos) {
+    // Return the token REAL source (aka unicodes are precomputed)
+    char[] result;
+    int length;
+    System.arraycopy(source, startPos + 1, result = new char[length = currentPosition - startPos - 2], 0, length);
+    //    }
+    return result;
+  }
   /*
    * Search the source position corresponding to the end of a given line number
    * 
@@ -3626,7 +3639,12 @@ public class Scanner implements IScanner, ITerminalSymbols {
   }
 
   public final void setSource(char[] source) {
+    setSource(null, source);
+  }
+  
+  public final void setSource(ICompilationUnit compilationUnit, char[] source) {
     //the source-buffer is set to sourceString
+    this.compilationUnit = compilationUnit;
     if (source == null) {
       this.source = new char[0];
     } else {