Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / template / php / HTMLUnitContext.java
index 76343dd..136e438 100644 (file)
@@ -22,10 +22,17 @@ public class HTMLUnitContext extends DocumentTemplateContext {
   /** The platform default line delimiter. */
   private static final String PLATFORM_LINE_DELIMITER = System.getProperty("line.separator"); //$NON-NLS-1$
 
-  private static final String specialChars = "&<#";
+  /** special characters
+   * '&' for the start of HTML entities
+   * '<' for the start of HTML tags
+   * '#' for the start of colour attributes
+   * '{' for the start of smarty partitions inside HTML code
+   */
+  private static final String specialChars = "&<#{";
+
   /** The compilation unit, may be <code>null</code>. */
   //   private final ICompilationUnit fCompilationUnit;
-
+  protected boolean fForceEvaluation;
   /**
    * Creates a compilation unit context.
    * 
@@ -95,21 +102,39 @@ public class HTMLUnitContext extends DocumentTemplateContext {
     IDocument document = getDocument();
     try {
       int start = getCompletionOffset();
-
-         if ( ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
-               return --start;
-         }
-                       
-      while (((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
-        || ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
-        start--;
+      char ch = ' ';
+      while (start != 0) {
+        ch = document.getChar(start - 1);
+        if (specialChars.indexOf(ch) != (-1)) {
+          return --start;
+        }
+        if (Character.isUnicodeIdentifierPart(ch)) {
+          start--;
+        } else {
+          break;
+        }
       }
-
-      if (((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
-        || ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1) )) {
+      if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1))) {
         start--;
+        if ((start != 0) && specialChars.indexOf(document.getChar(start - 1)) != (-1)) {
+          start--;
+        }
       }
 
+      //      while (((start != 0)
+      //        && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
+      //        || ((start != 0)
+      //          && specialChars.indexOf(document.getChar(start - 1)) != (-1))) {
+      //        start--;
+      //      }
+      //
+      //if (((start != 0)
+      //       && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
+      //       || ((start != 0)
+      //               && specialChars.indexOf(document.getChar(start - 1)) != (-1))) {
+      //       start--;
+      //}
+
       return start;
 
     } catch (BadLocationException e) {
@@ -156,5 +181,10 @@ public class HTMLUnitContext extends DocumentTemplateContext {
   //                   return null;
   //           }       
   //   }
-
+  /**
+   * Forces evaluation.
+   */
+  public void setForceEvaluation(boolean evaluate) {
+    fForceEvaluation = evaluate;
+  }
 }