Workaround for feature request #1154254 (sticky browser URL) that solves bug #1827766...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / text / PHPStringDQCodeScanner.java
index 85dbb75..6203ece 100644 (file)
@@ -30,92 +30,96 @@ import org.eclipse.jface.text.rules.WordRule;
  */
 public final class PHPStringDQCodeScanner extends AbstractJavaScanner {
 
-  private static String[] fgTokenProperties = { IPreferenceConstants.PHP_STRING_DQ, IPreferenceConstants.PHP_VARIABLE, IPreferenceConstants.PHP_VARIABLE_DOLLAR};
+       private static String[] fgTokenProperties = {
+                       IPreferenceConstants.PHP_STRING_DQ,
+                       IPreferenceConstants.PHP_VARIABLE,
+                       IPreferenceConstants.PHP_VARIABLE_DOLLAR };
 
-  private class PHPWordRule extends WordRule {
-       private StringBuffer fBuffer = new StringBuffer();
+       private class PHPWordRule extends WordRule {
+               private StringBuffer fBuffer = new StringBuffer();
 
-       public PHPWordRule(IWordDetector detector) {
-         super(detector, Token.UNDEFINED);
-       }
+               public PHPWordRule(IWordDetector detector) {
+                       super(detector, Token.UNDEFINED);
+               }
 
-       public PHPWordRule(IWordDetector detector, IToken defaultToken) {
-         super(detector, defaultToken);
-       }
+               public PHPWordRule(IWordDetector detector, IToken defaultToken) {
+                       super(detector, defaultToken);
+               }
 
-       public IToken evaluate(ICharacterScanner scanner) {
-         int c = scanner.read();
-         boolean isUnderscore = false;
-         if (fDetector.isWordStart((char) c)) {
-               if (fColumn == UNDEFINED || (fColumn == scanner.getColumn() - 1)) {
-
-                 fBuffer.setLength(0);
-                 fBuffer.append((char) c);
-                 c = scanner.read();
-                 if (c=='_') {
-                         isUnderscore = true;
-                 }
-                 while (c != ICharacterScanner.EOF && fDetector.isWordPart((char) c)) {
-                       fBuffer.append((char) c);
-                       c = scanner.read();
-                       // hack for coloring object elements with variable color instead of string color
-                       if (c=='-') {
-                               int c2=scanner.read();
-                               if (c2=='>') {
-                                       fBuffer.append(c);
-                                       fBuffer.append(c2);
-                                       c=scanner.read();
-                               }
-                               else {
+               public IToken evaluate(ICharacterScanner scanner) {
+                       int c = scanner.read();
+                       boolean isUnderscore = false;
+                       if (fDetector.isWordStart((char) c)) {
+                               if (fColumn == UNDEFINED
+                                               || (fColumn == scanner.getColumn() - 1)) {
+
+                                       fBuffer.setLength(0);
+                                       fBuffer.append((char) c);
+                                       c = scanner.read();
+                                       if (c == '_') {
+                                               isUnderscore = true;
+                                       }
+                                       while (c != ICharacterScanner.EOF
+                                                       && fDetector.isWordPart((char) c)) {
+                                               fBuffer.append((char) c);
+                                               c = scanner.read();
+                                               // hack for coloring object elements with variable color
+                                               // instead of string color
+                                               if (c == '-') {
+                                                       int c2 = scanner.read();
+                                                       if (c2 == '>') {
+                                                               fBuffer.append(c);
+                                                               fBuffer.append(c2);
+                                                               c = scanner.read();
+                                                       } else {
+                                                               scanner.unread();
+                                                       }
+                                               }
+                                               // hack end
+                                       }
                                        scanner.unread();
+                                       if (isUnderscore) {
+                                               return getToken(IPreferenceConstants.PHP_VARIABLE_DOLLAR);
+                                       }
+                                       return getToken(IPreferenceConstants.PHP_VARIABLE);
                                }
                        }
-                       // hack end
-                 }
-                 scanner.unread();
-                 if (isUnderscore) {
-                         return getToken(IPreferenceConstants.PHP_VARIABLE_DOLLAR);
-                 }
-                 return getToken(IPreferenceConstants.PHP_VARIABLE);
-               }
-         }
 
-         scanner.unread();
-         return Token.UNDEFINED;
+                       scanner.unread();
+                       return Token.UNDEFINED;
+               }
        }
-  }
 
-  public PHPStringDQCodeScanner(IColorManager manager, IPreferenceStore store) {
-       super(manager, store);
-       initialize();
-  }
+       public PHPStringDQCodeScanner(IColorManager manager, IPreferenceStore store) {
+               super(manager, store);
+               initialize();
+       }
 
-  public IDocument getDocument() {
-       return fDocument;
-  }
+       public IDocument getDocument() {
+               return fDocument;
+       }
 
-  /*
-   * @see AbstractJavaScanner#getTokenProperties()
-   */
-  protected String[] getTokenProperties() {
-       return fgTokenProperties;
-  }
+       /*
+        * @see AbstractJavaScanner#getTokenProperties()
+        */
+       protected String[] getTokenProperties() {
+               return fgTokenProperties;
+       }
 
-  /*
-   * @see AbstractJavaScanner#createRules()
-   */
-  protected List createRules() {
+       /*
+        * @see AbstractJavaScanner#createRules()
+        */
+       protected List createRules() {
 
-       List list = new ArrayList();
+               List list = new ArrayList();
 
-       // Add rule for tags.
-       Token token = getToken(IPreferenceConstants.PHP_STRING_DQ);
-       PHPWordRule wordRule = new PHPWordRule(new PHPVariableDetector(), token);
+               // Add rule for tags.
+               Token token = getToken(IPreferenceConstants.PHP_STRING_DQ);
+               PHPWordRule wordRule = new PHPWordRule(new PHPVariableDetector(), token);
 
-       list.add(wordRule);
+               list.add(wordRule);
 
-       setDefaultReturnToken(getToken(IPreferenceConstants.PHP_STRING_DQ));
-       return list;
-  }
+               setDefaultReturnToken(getToken(IPreferenceConstants.PHP_STRING_DQ));
+               return list;
+       }
 }
-