Improved completion processor
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / corext / template / java / CompilationUnitContext.java
index dcc8f00..17f42d6 100644 (file)
@@ -47,6 +47,19 @@ public class CompilationUnitContext extends DocumentTemplateContext {
     return template.matches(getKey(), getContextType().getName());
   }
   
+  /**
+   * Returns <code>true</code> if template matches the prefix and context,
+   * <code>false</code> otherwise.
+   */
+  public boolean canEvaluate(String identifier) {
+    String prefix = getKey();
+    return 
+//      fEnabled &&
+//      fContextTypeName.equals(contextTypeName) &&
+      (prefix.length() != 0) &&
+      identifier.toLowerCase().startsWith(prefix.toLowerCase());
+  }
+  
     /*
    * @see TemplateContext#evaluate(Template template)
    */
@@ -82,11 +95,15 @@ public class CompilationUnitContext extends DocumentTemplateContext {
     try {
       int start= getCompletionPosition();
   
-      while ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1)))
+      while ( ((start != 0) && Character.isUnicodeIdentifierPart(document.getChar(start - 1))) ||
+               ((start != 0) && document.getChar(start - 1)=='$') ) {
         start--;
+      }
         
-      if ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1)))
+      if ( ((start != 0) && Character.isUnicodeIdentifierStart(document.getChar(start - 1))) ||
+           ((start != 0) && document.getChar(start - 1)=='$')) {
         start--;
+      }
   
       return start;