Changes:
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / template / php / PHPUnitContext.java
index 6ccc7a1..8f9a0be 100644 (file)
@@ -25,7 +25,7 @@ public class PHPUnitContext extends DocumentTemplateContext {
   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.
    * 
@@ -37,10 +37,17 @@ public class PHPUnitContext extends DocumentTemplateContext {
   protected PHPUnitContext(ContextType type, IDocument document, int completionPosition)
   //,ICompilationUnit compilationUnit)
   {
-    super(type, document, completionPosition);
+    super(type, document, completionPosition, 0);
     // fCompilationUnit= compilationUnit;
   }
-
+       
+       protected PHPUnitContext(ContextType type, IDocument document, int completionPosition, int completionLength)
+               //,ICompilationUnit compilationUnit)
+               {
+                       super(type, document, completionPosition, completionLength);
+                       //      fCompilationUnit= compilationUnit;
+               }
+               
   /*
   * @see TemplateContext#canEvaluate(Template templates)
   */
@@ -58,7 +65,8 @@ public class PHPUnitContext extends DocumentTemplateContext {
     return
     //      fEnabled &&
     //      fContextTypeName.equals(contextTypeName) &&
-     (prefix.length() != 0) && identifier.toLowerCase().startsWith(prefix.toLowerCase());
+//      (prefix.length() != 0) && 
+      identifier.toLowerCase().startsWith(prefix.toLowerCase());
   }
 
   /*
@@ -94,8 +102,12 @@ public class PHPUnitContext extends DocumentTemplateContext {
   public int getStart() {
     IDocument document = getDocument();
     try {
-      int start = getCompletionPosition();
+      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--;
@@ -109,7 +121,7 @@ public class PHPUnitContext extends DocumentTemplateContext {
       return start;
 
     } catch (BadLocationException e) {
-      return getCompletionPosition();
+      return getCompletionOffset();
     }
   }
 
@@ -126,6 +138,7 @@ public class PHPUnitContext extends DocumentTemplateContext {
       return ' ';
     }
   }
+  
   /**
    * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
    */
@@ -153,4 +166,11 @@ public class PHPUnitContext extends DocumentTemplateContext {
   //           }       
   //   }
 
+  /**
+   * @param b
+   */
+  public void setForceEvaluation(boolean b) {
+    fForceEvaluation = b;
+  }
+
 }