fix #774 infinite loop in net.sourceforge.phpeclipse.builder.IdentifierIndexManager...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / phpeditor / php / PHPPartitionScanner.java
index 9b6420e..0b8409d 100644 (file)
@@ -8,11 +8,10 @@
  Contributors:
  Igor Malinin - initial contribution
 
- $Id: PHPPartitionScanner.java,v 1.32 2005-10-09 12:35:01 axelcl Exp $
+ $Id: PHPPartitionScanner.java,v 1.35 2007-03-17 14:07:31 axelcl Exp $
  **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor.php;
 
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -28,8 +27,8 @@ import org.eclipse.jface.text.rules.IToken;
 import org.eclipse.jface.text.rules.Token;
 
 /**
- *
- *
+ * 
+ * 
  * @author Igor Malinin
  */
 public class PHPPartitionScanner implements IPartitionTokenScanner {
@@ -268,7 +267,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner {
                                        if (position >= end) {
                                                return false;
                                        }
-                                       ch = document.getChar(position++); // ignore escaped character
+                                       ch = document.getChar(position++); // ignore escaped
+                                       // character
                                } else if (ch == '"') {
                                        return true;
                                }
@@ -292,7 +292,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner {
                                        if (position >= end) {
                                                return false;
                                        }
-                                       ch = document.getChar(position++); // ignore escaped character
+                                       ch = document.getChar(position++); // ignore escaped
+                                       // character
                                } else if (ch == '\'') {
                                        return true;
                                }
@@ -313,6 +314,14 @@ public class PHPPartitionScanner implements IPartitionTokenScanner {
                                return false;
                        }
                        ch = document.getChar(position++);
+                       // #1493165 start
+                       while (ch == ' ') {
+                               if (position >= end) {
+                                       return false;
+                               }
+                               ch = document.getChar(position++);
+                       }
+                       // #1493165 end
                        if (!Scanner.isPHPIdentifierStart(ch)) {
                                return false;
                        }
@@ -338,7 +347,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner {
                                                if (pos == heredocIdent.length) {
                                                        return true;
                                                }
-                                               ch = document.getChar(position++); // ignore escaped character
+                                               ch = document.getChar(position++); // ignore escaped
+                                               // character
                                                if (ch != heredocIdent[pos]) {
                                                        break;
                                                }
@@ -428,7 +438,8 @@ public class PHPPartitionScanner implements IPartitionTokenScanner {
        /*
         * @see org.eclipse.jface.text.rules.IPartitionTokenScanner
         */
-       public void setPartialRange(IDocument document, int offset, int length, String contentType, int partitionOffset) {
+       public void setPartialRange(IDocument document, int offset, int length,
+                       String contentType, int partitionOffset) {
                // state = STATE_DEFAULT;
                if (partitionOffset > -1) {
                        int delta = offset - partitionOffset;