improved PHP parser
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / ui / text / SmartSemicolonAutoEditStrategy.java
index edd3013..7b8e3d3 100644 (file)
@@ -12,6 +12,7 @@ package net.sourceforge.phpdt.internal.ui.text;
 
 import java.util.Arrays;
 
+import net.sourceforge.phpdt.internal.compiler.parser.Scanner;
 import net.sourceforge.phpdt.internal.core.Assert;
 import net.sourceforge.phpdt.internal.ui.text.SmartBackspaceManager.UndoSpec;
 import net.sourceforge.phpdt.ui.PreferenceConstants;
@@ -327,7 +328,7 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
                                return -1;
                        
                        ch= document.getChar(p);
-                       if (Character.isJavaIdentifierPart(ch) || ch == ']' || ch == '[')
+                       if (Scanner.isPHPIdentifierPart(ch) || ch == ']' || ch == '[')
                                return offset;
        
                } catch (BadLocationException e) {
@@ -636,10 +637,10 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
                        if (pos < 0)
                                return false;
 
-                       if (pos != 0 && Character.isJavaIdentifierPart(text.charAt(pos - 1)))
+                       if (pos != 0 && Scanner.isPHPIdentifierPart(text.charAt(pos - 1)))
                                return false;
 
-                       if (pos + 3 < length && Character.isJavaIdentifierPart(text.charAt(pos + 3)))
+                       if (pos + 3 < length && Scanner.isPHPIdentifierPart(text.charAt(pos + 3)))
                                return false;
                        
                        return true;
@@ -759,7 +760,7 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
        /**
         * Checks whether code>document</code> contains the <code>String</code> <code>like</code> such 
         * that its last character is at <code>position</code>. If <code>like</code> starts with a
-        * identifier part (as determined by {@link Character#isJavaIdentifier(char)}), it is also made
+        * identifier part (as determined by {@link Scanner#isPHPIdentifierPart(char)}), it is also made
         * sure that <code>like</code> is preceded by some non-identifier character or stands at the
         * document start.
         * 
@@ -777,7 +778,7 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
                        if (!like.equals(document.get(position - length + 1, length)))
                                return false;
 
-                       if (position >= length && Character.isJavaIdentifierPart(like.charAt(0)) && Character.isJavaIdentifierPart(document.getChar(position - length)))
+                       if (position >= length && Scanner.isPHPIdentifierPart(like.charAt(0)) && Scanner.isPHPIdentifierPart(document.getChar(position - length)))
                                return false;
 
                } catch (BadLocationException e) {
@@ -864,7 +865,7 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
                        while (p >= 0) {
 
                                char ch= document.getChar(p);
-                               if (Character.isJavaIdentifierPart(ch)) {
+                               if (Scanner.isPHPIdentifierPart(ch)) {
                                        p--;
                                        continue;
                                }
@@ -980,7 +981,7 @@ public class SmartSemicolonAutoEditStrategy implements IAutoEditStrategy {
                /* searching for (^|\s)for(\s|$) */
                int forPos= line.indexOf("for"); //$NON-NLS-1$
                if (forPos != -1) {
-                       if ((forPos == 0 || !Character.isJavaIdentifierPart(line.charAt(forPos - 1))) && (line.length() == forPos + 3 || !Character.isJavaIdentifierPart(line.charAt(forPos + 3))))
+                       if ((forPos == 0 || !Scanner.isPHPIdentifierPart(line.charAt(forPos - 1))) && (line.length() == forPos + 3 || !Scanner.isPHPIdentifierPart(line.charAt(forPos + 3))))
                                return true;
                }
                return false;