added code completion for HTML mode
authorkhartlage <khartlage>
Thu, 2 Jan 2003 14:50:29 +0000 (14:50 +0000)
committerkhartlage <khartlage>
Thu, 2 Jan 2003 14:50:29 +0000 (14:50 +0000)
25 files changed:
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/ContextTypeRegistry.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/default-templates.xml
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/CompilationUnitContext.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/CompilationUnitContextType.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/CompilationUnitContextType.java with 98% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/GlobalVariables.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/GlobalVariables.java with 63% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLContextType.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/JavaDocContextType.java with 80% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPContextType.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/JavaContextType.java with 94% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/JavaTemplateMessages.java with 81% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPTemplateMessages.properties [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/JavaTemplateMessages.properties with 100% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java [new file with mode: 0644]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IPHPCompletionProposal.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/IJavaCompletionProposal.java with 93% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaCompletionProcessor_NotInUseVersion.java [deleted file]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/PHPCompletionProposalComparator.java [moved from net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaCompletionProposalComparator.java with 74% similarity]
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/BuiltInProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/IdentifierEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/IdentifierProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateEngine.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/template/TemplateProposal.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPPerspectiveFactory.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSourceViewerConfiguration.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPCompletionProcessor.java
net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPPartitionScanner.java

index 8247bdc..95366f0 100644 (file)
@@ -8,8 +8,8 @@ import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Map;
 
-import net.sourceforge.phpdt.internal.corext.template.java.JavaContextType;
-import net.sourceforge.phpdt.internal.corext.template.java.JavaDocContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.HTMLContextType;
 
 
 
@@ -64,8 +64,8 @@ public class ContextTypeRegistry {
 
        // XXX bootstrap with java and javadoc context types
        private ContextTypeRegistry() {
-               add(new JavaContextType());
-               add(new JavaDocContextType());
+               add(new PHPContextType());
+               add(new HTMLContextType());
        }
 
 }
index d635aae..2a1d730 100644 (file)
  */</template>
  <template name="echo" description="echo a string" context="php" enabled="true">echo "${string}";
   ${cursor}</template>
+  
+  
+  <template name="&amp;nbsp" description="no-break space " context="html" enabled="true">&amp;nbsp
+  </template>
+
+  <template name="&lt;html" description="html page with head,title,body" context="html" enabled="true">
+  &lt;html&gt;
+  &lt;head&gt;
+  &lt;title&gt;${title}&lt;/title&gt;
+  &lt;/head&gt;
+  &lt;body&gt;
+  ${cursor}
+  &lt;/body&gt;
+  &lt;/html&gt;
+  </template>  
+  <template name="&lt;title" description="title" context="html" enabled="true">
+  &lt;title&gt;${cursor}&lt;/title&gt;
+  </template> 
+  
+  <template name="&lt;table" description="3x3 table" context="html" enabled="true">
+  &lt;table&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t00}&lt;/td&gt;&lt;td&gt;${t01}&lt;/td&gt;&lt;td&gt;${t02}&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t10}&lt;/td&gt;&lt;td&gt;${t11}&lt;/td&gt;&lt;td&gt;${t12}&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t20}&lt;/td&gt;&lt;td&gt;${t21}&lt;/td&gt;&lt;td&gt;${t22}&lt;/td&gt;
+    &lt;/tr&gt;    
+  &lt;/table&gt;
+  ${cursor}
+  </template>
+  <template name="&lt;table" description="3x3 table with header" context="html" enabled="true">
+  &lt;table&gt;
+    &lt;tr&gt;
+      &lt;th&gt;${header0}&lt;/th&gt;&lt;th&gt;${header1}&lt;/th&gt;&lt;th&gt;${header2}&lt;/th&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t00}&lt;/td&gt;&lt;td&gt;${t01}&lt;/td&gt;&lt;td&gt;${t02}&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t10}&lt;/td&gt;&lt;td&gt;${t11}&lt;/td&gt;&lt;td&gt;${t12}&lt;/td&gt;
+    &lt;/tr&gt;
+    &lt;tr&gt;
+      &lt;td&gt;${t20}&lt;/td&gt;&lt;td&gt;${t21}&lt;/td&gt;&lt;td&gt;${t22}&lt;/td&gt;
+    &lt;/tr&gt;    
+  &lt;/table&gt;
+  ${cursor}
+  </template>
+  
+  <template name="&lt;a" description="hyperlink (href)" context="html" enabled="true">
+  &lt;a href="${link}"&gt;${description}&lt;/a&gt; ${cursor}
+  </template>  
+  <template name="&lt;a" description="hyperlink image" context="html" enabled="true">
+  &lt;a href="${link}"&gt;&lt;img src="${image}"&gt;&lt;/a&gt; ${cursor}
+  </template> 
+  <template name="&lt;a" description="hyperlink fragment identifier (name)" context="html" enabled="true">
+  &lt;a name="${anchor}"&gt;${description}&lt;/a&gt; ${cursor}
+  </template> 
+  <template name="&lt;p" description="paragraph" context="html" enabled="true">
+  &lt;p&gt;${cursor}&lt;/p&gt;
+  </template>
+  <template name="&lt;pre" description="preformated text" context="html" enabled="true">
+  &lt;pre&gt;${cursor}&lt;/pre&gt;
+  </template>
+  <template name="&lt;blockquote" description="blockquoted text" context="html" enabled="true">
+  &lt;blockquote&gt;${cursor}&lt;/blockquote&gt;
+  </template>
  </templates>
\ No newline at end of file
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/CompilationUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/java/CompilationUnitContext.java
deleted file mode 100644 (file)
index 17f42d6..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-package net.sourceforge.phpdt.internal.corext.template.java;
-
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
-import net.sourceforge.phpdt.internal.corext.template.Template;
-import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
-import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A compilation unit context.
- */
-public class CompilationUnitContext extends DocumentTemplateContext {
-
-  /** The platform default line delimiter. */
-  private static final String PLATFORM_LINE_DELIMITER= System.getProperty("line.separator"); //$NON-NLS-1$
-
-       /** The compilation unit, may be <code>null</code>. */
-//     private final ICompilationUnit fCompilationUnit;
-
-       /**
-        * Creates a compilation unit context.
-        * 
-        * @param type   the context type.
-        * @param document the document.
-        * @param completionPosition the completion position within the document.
-        * @param compilationUnit the compilation unit (may be <code>null</code>).
-        */
-       protected CompilationUnitContext(ContextType type, IDocument document, int completionPosition)
-       //,ICompilationUnit compilationUnit)
-       {
-               super(type, document, completionPosition);
-       //      fCompilationUnit= compilationUnit;
-       }
-       
-    /*
-   * @see TemplateContext#canEvaluate(Template templates)
-   */
-  public boolean canEvaluate(Template template) {
-    // return fForceEvaluation || 
-    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)
-   */
-  public TemplateBuffer evaluate(Template template) throws CoreException {
-    if (!canEvaluate(template))
-      return null;
-    
-    TemplateTranslator translator= new TemplateTranslator();
-    TemplateBuffer buffer= translator.translate(template.getPattern());
-
-    getContextType().edit(buffer, this);
-      
-    String lineDelimiter= null;
-    try {
-      lineDelimiter= getDocument().getLineDelimiter(0);
-    } catch (BadLocationException e) {
-    }
-
-    if (lineDelimiter == null)
-      lineDelimiter= PLATFORM_LINE_DELIMITER;
-    
-//    ITemplateEditor formatter= new JavaFormatter(lineDelimiter);
-//    formatter.edit(buffer, this);
-
-    return buffer;
-  }
-  
-  /*
-   * @see DocumentTemplateContext#getCompletionPosition();
-   */
-  public int getStart() {
-    IDocument document= getDocument();
-    try {
-      int start= getCompletionPosition();
-  
-      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))) ||
-           ((start != 0) && document.getChar(start - 1)=='$')) {
-        start--;
-      }
-  
-      return start;
-
-    } catch (BadLocationException e) {
-      return getCompletionPosition(); 
-    }
-  }
-
-  /**
-   * Returns the character before start position of completion.
-   */
-  public char getCharacterBeforeStart() {
-    int start= getStart();
-    
-    try {
-      return start == 0
-        ? ' '
-        : getDocument().getChar(start - 1);
-
-    } catch (BadLocationException e) {
-      return ' ';
-    }
-  }
-       /**
-        * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
-        */
-//     public final ICompilationUnit getCompilationUnit() {
-//             return fCompilationUnit;
-//     }
-
-       /**
-        * Returns the enclosing element of a particular element type, <code>null</code>
-        * if no enclosing element of that type exists.
-        */
-//     public IJavaElement findEnclosingElement(int elementType) {
-//             if (fCompilationUnit == null)
-//                     return null;
-//
-//             try {
-//                     IJavaElement element= fCompilationUnit.getElementAt(getStart());
-//                     while (element != null && element.getElementType() != elementType)
-//                             element= element.getParent();
-//                     
-//                     return element;
-//
-//             } catch (JavaModelException e) {
-//                     return null;
-//             }       
-//     }
-
-}
@@ -2,7 +2,7 @@
  * (c) Copyright IBM Corp. 2000, 2001.
  * All Rights Reserved.
  */
-package net.sourceforge.phpdt.internal.corext.template.java;
+package net.sourceforge.phpdt.internal.corext.template.php;
 
 import java.text.DateFormat;
 import java.util.Date;
@@ -22,7 +22,7 @@ public class GlobalVariables {
         */
        static class Cursor extends SimpleTemplateVariable {
                public Cursor() {
-                       super(JavaTemplateMessages.getString("GlobalVariables.variable.name.cursor"), JavaTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"), PHPTemplateMessages.getString("GlobalVariables.variable.description.cursor")); //$NON-NLS-1$ //$NON-NLS-2$
                        setEvaluationString(""); //$NON-NLS-1$
                        setResolved(true);
                }
@@ -33,7 +33,7 @@ public class GlobalVariables {
         */
        static class Dollar extends SimpleTemplateVariable {
                public Dollar() {
-                       super(JavaTemplateMessages.getString("GlobalVariables.variable.name.dollar"), JavaTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.dollar"), PHPTemplateMessages.getString("GlobalVariables.variable.description.dollar")); //$NON-NLS-1$ //$NON-NLS-2$
                        setEvaluationString("$"); //$NON-NLS-1$
                        setResolved(true);
                }
@@ -44,7 +44,7 @@ public class GlobalVariables {
         */
        static class Date extends SimpleTemplateVariable {
                public Date() {
-                       super(JavaTemplateMessages.getString("GlobalVariables.variable.name.date"), JavaTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.date"), PHPTemplateMessages.getString("GlobalVariables.variable.description.date")); //$NON-NLS-1$ //$NON-NLS-2$
                        setResolved(true);
                }
                public String evaluate(TemplateContext context) {
@@ -57,7 +57,7 @@ public class GlobalVariables {
         */
        static class Time extends SimpleTemplateVariable {
                public Time() {
-                       super(JavaTemplateMessages.getString("GlobalVariables.variable.name.time"), JavaTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.time"), PHPTemplateMessages.getString("GlobalVariables.variable.description.time")); //$NON-NLS-1$ //$NON-NLS-2$
                        setResolved(true);
                }
                public String evaluate(TemplateContext context) {
@@ -70,7 +70,7 @@ public class GlobalVariables {
         */
        static class User extends SimpleTemplateVariable {
                public User() {
-                       super(JavaTemplateMessages.getString("GlobalVariables.variable.name.user"), JavaTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
+                       super(PHPTemplateMessages.getString("GlobalVariables.variable.name.user"), PHPTemplateMessages.getString("GlobalVariables.variable.description.user")); //$NON-NLS-1$ //$NON-NLS-2$
                        setResolved(true);
                }
                public String evaluate(TemplateContext context) {
@@ -2,7 +2,7 @@
  * (c) Copyright IBM Corp. 2000, 2001.
  * All Rights Reserved.
  */
-package net.sourceforge.phpdt.internal.corext.template.java;
+package net.sourceforge.phpdt.internal.corext.template.php;
 
 //import org.eclipse.jdt.core.ICompilationUnit;
 
@@ -13,12 +13,12 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
 /**
  * A context type for javadoc.
  */
-public class JavaDocContextType extends CompilationUnitContextType {
+public class HTMLContextType extends CompilationUnitContextType {
 
        /**
         * Creates a java context type.
         */
-       public JavaDocContextType() {
+       public HTMLContextType() {
                super("html"); //$NON-NLS-1$
                
                // global
@@ -42,7 +42,7 @@ public class JavaDocContextType extends CompilationUnitContextType {
         * @see ContextType#createContext()
         */     
        public TemplateContext createContext() {
-               return new CompilationUnitContext(this, fDocument, fPosition); //, fCompilationUnit);
+               return new HTMLUnitContext(this, fDocument, fPosition); //, fCompilationUnit);
        }
 
 }
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/HTMLUnitContext.java
new file mode 100644 (file)
index 0000000..e459ce2
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
+import net.sourceforge.phpdt.internal.corext.template.Template;
+import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
+import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * A compilation unit context.
+ */
+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 = "$&<";
+  /** The compilation unit, may be <code>null</code>. */
+  //   private final ICompilationUnit fCompilationUnit;
+
+  /**
+   * Creates a compilation unit context.
+   * 
+   * @param type   the context type.
+   * @param document the document.
+   * @param completionPosition the completion position within the document.
+   * @param compilationUnit the compilation unit (may be <code>null</code>).
+   */
+  protected HTMLUnitContext(ContextType type, IDocument document, int completionPosition)
+  //,ICompilationUnit compilationUnit)
+  {
+    super(type, document, completionPosition);
+    // fCompilationUnit= compilationUnit;
+  }
+
+  /*
+  * @see TemplateContext#canEvaluate(Template templates)
+  */
+  public boolean canEvaluate(Template template) {
+    // return fForceEvaluation || 
+    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)
+  */
+  public TemplateBuffer evaluate(Template template) throws CoreException {
+    if (!canEvaluate(template))
+      return null;
+
+    TemplateTranslator translator = new TemplateTranslator();
+    TemplateBuffer buffer = translator.translate(template.getPattern());
+
+    getContextType().edit(buffer, this);
+
+    String lineDelimiter = null;
+    try {
+      lineDelimiter = getDocument().getLineDelimiter(0);
+    } catch (BadLocationException e) {
+    }
+
+    if (lineDelimiter == null)
+      lineDelimiter = PLATFORM_LINE_DELIMITER;
+
+    //    ITemplateEditor formatter= new JavaFormatter(lineDelimiter);
+    //    formatter.edit(buffer, this);
+
+    return buffer;
+  }
+
+  /*
+   * @see DocumentTemplateContext#getCompletionPosition();
+   */
+  public int getStart() {
+    IDocument document = getDocument();
+    try {
+      int start = getCompletionPosition();
+
+      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) {
+      return getCompletionPosition();
+    }
+  }
+
+  /**
+   * Returns the character before start position of completion.
+   */
+  public char getCharacterBeforeStart() {
+    int start = getStart();
+
+    try {
+      return start == 0 ? ' ' : getDocument().getChar(start - 1);
+
+    } catch (BadLocationException e) {
+      return ' ';
+    }
+  }
+  /**
+   * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
+   */
+  //   public final ICompilationUnit getCompilationUnit() {
+  //           return fCompilationUnit;
+  //   }
+
+  /**
+   * Returns the enclosing element of a particular element type, <code>null</code>
+   * if no enclosing element of that type exists.
+   */
+  //   public IJavaElement findEnclosingElement(int elementType) {
+  //           if (fCompilationUnit == null)
+  //                   return null;
+  //
+  //           try {
+  //                   IJavaElement element= fCompilationUnit.getElementAt(getStart());
+  //                   while (element != null && element.getElementType() != elementType)
+  //                           element= element.getParent();
+  //                   
+  //                   return element;
+  //
+  //           } catch (JavaModelException e) {
+  //                   return null;
+  //           }       
+  //   }
+
+}
@@ -2,7 +2,7 @@
  * (c) Copyright IBM Corp. 2000, 2001.
  * All Rights Reserved.
  */
-package net.sourceforge.phpdt.internal.corext.template.java;
+package net.sourceforge.phpdt.internal.corext.template.php;
 
 import java.util.Collection;
 /*
@@ -19,7 +19,7 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateVariable;
 /**
  * A context type for java code.
  */
-public class JavaContextType extends CompilationUnitContextType {
+public class PHPContextType extends CompilationUnitContextType {
 /*
        protected static class Array extends TemplateVariable {
                public Array() {
@@ -81,7 +81,7 @@ public class JavaContextType extends CompilationUnitContextType {
        /**
         * Creates a java context type.
         */
-       public JavaContextType() {
+       public PHPContextType() {
                super("php"); //$NON-NLS-1$
                
                // global
@@ -113,7 +113,7 @@ public class JavaContextType extends CompilationUnitContextType {
         * @see ContextType#createContext()
         */     
        public TemplateContext createContext() {
-               return new CompilationUnitContext(this, fDocument, fPosition); //, fCompilationUnit);
+               return new PHPUnitContext(this, fDocument, fPosition); //, fCompilationUnit);
        }
 
 }
@@ -2,18 +2,18 @@
  * (c) Copyright IBM Corp. 2000, 2001.
  * All Rights Reserved.
  */
-package net.sourceforge.phpdt.internal.corext.template.java;
+package net.sourceforge.phpdt.internal.corext.template.php;
 
 import java.text.MessageFormat;
 import java.util.MissingResourceException;
 import java.util.ResourceBundle;
 
-public class JavaTemplateMessages {
+public class PHPTemplateMessages {
 
-       private static final String RESOURCE_BUNDLE= JavaTemplateMessages.class.getName();
+       private static final String RESOURCE_BUNDLE= PHPTemplateMessages.class.getName();
        private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
 
-       private JavaTemplateMessages() {
+       private PHPTemplateMessages() {
        }
 
        public static String getString(String key) {
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/corext/template/php/PHPUnitContext.java
new file mode 100644 (file)
index 0000000..5d98915
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * (c) Copyright IBM Corp. 2000, 2001.
+ * All Rights Reserved.
+ */
+package net.sourceforge.phpdt.internal.corext.template.php;
+
+import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
+import net.sourceforge.phpdt.internal.corext.template.Template;
+import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
+import net.sourceforge.phpdt.internal.corext.template.TemplateTranslator;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+
+/**
+ * A compilation unit context.
+ */
+public class PHPUnitContext 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 = "$";
+  /** The compilation unit, may be <code>null</code>. */
+  //   private final ICompilationUnit fCompilationUnit;
+
+  /**
+   * Creates a compilation unit context.
+   * 
+   * @param type   the context type.
+   * @param document the document.
+   * @param completionPosition the completion position within the document.
+   * @param compilationUnit the compilation unit (may be <code>null</code>).
+   */
+  protected PHPUnitContext(ContextType type, IDocument document, int completionPosition)
+  //,ICompilationUnit compilationUnit)
+  {
+    super(type, document, completionPosition);
+    // fCompilationUnit= compilationUnit;
+  }
+
+  /*
+  * @see TemplateContext#canEvaluate(Template templates)
+  */
+  public boolean canEvaluate(Template template) {
+    // return fForceEvaluation || 
+    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)
+  */
+  public TemplateBuffer evaluate(Template template) throws CoreException {
+    if (!canEvaluate(template))
+      return null;
+
+    TemplateTranslator translator = new TemplateTranslator();
+    TemplateBuffer buffer = translator.translate(template.getPattern());
+
+    getContextType().edit(buffer, this);
+
+    String lineDelimiter = null;
+    try {
+      lineDelimiter = getDocument().getLineDelimiter(0);
+    } catch (BadLocationException e) {
+    }
+
+    if (lineDelimiter == null)
+      lineDelimiter = PLATFORM_LINE_DELIMITER;
+
+    //    ITemplateEditor formatter= new JavaFormatter(lineDelimiter);
+    //    formatter.edit(buffer, this);
+
+    return buffer;
+  }
+
+  /*
+   * @see DocumentTemplateContext#getCompletionPosition();
+   */
+  public int getStart() {
+    IDocument document = getDocument();
+    try {
+      int start = getCompletionPosition();
+
+      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) {
+      return getCompletionPosition();
+    }
+  }
+
+  /**
+   * Returns the character before start position of completion.
+   */
+  public char getCharacterBeforeStart() {
+    int start = getStart();
+
+    try {
+      return start == 0 ? ' ' : getDocument().getChar(start - 1);
+
+    } catch (BadLocationException e) {
+      return ' ';
+    }
+  }
+  /**
+   * Returns the compilation unit if one is associated with this context, <code>null</code> otherwise.
+   */
+  //   public final ICompilationUnit getCompilationUnit() {
+  //           return fCompilationUnit;
+  //   }
+
+  /**
+   * Returns the enclosing element of a particular element type, <code>null</code>
+   * if no enclosing element of that type exists.
+   */
+  //   public IJavaElement findEnclosingElement(int elementType) {
+  //           if (fCompilationUnit == null)
+  //                   return null;
+  //
+  //           try {
+  //                   IJavaElement element= fCompilationUnit.getElementAt(getStart());
+  //                   while (element != null && element.getElementType() != elementType)
+  //                           element= element.getParent();
+  //                   
+  //                   return element;
+  //
+  //           } catch (JavaModelException e) {
+  //                   return null;
+  //           }       
+  //   }
+
+}
@@ -18,7 +18,7 @@ import org.eclipse.jface.text.contentassist.ICompletionProposal;
  * The relevance value is used to sort the completion proposals. Proposals with higher relevance
  * should be listed before proposals with lower relevance.
  */
-public interface IJavaCompletionProposal extends ICompletionProposal {
+public interface IPHPCompletionProposal extends ICompletionProposal {
        
        /**
         * Returns the relevance of the proposal.
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaCompletionProcessor_NotInUseVersion.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/ui/text/java/JavaCompletionProcessor_NotInUseVersion.java
deleted file mode 100644 (file)
index 745bdee..0000000
+++ /dev/null
@@ -1,378 +0,0 @@
-package net.sourceforge.phpdt.internal.ui.text.java;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Hashtable;
-import java.util.List;
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationExtension;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-
-import org.eclipse.ui.IEditorPart;
-
-//import org.eclipse.jdt.core.ICompilationUnit;
-//import org.eclipse.jdt.core.JavaCore;
-//import org.eclipse.jdt.core.JavaModelException;
-//
-//import org.eclipse.jdt.ui.IWorkingCopyManager;
-//import org.eclipse.jdt.ui.PreferenceConstants;
-
-import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
-//import org.eclipse.jdt.internal.ui.JavaPlugin;
-import net.sourceforge.phpdt.internal.ui.PHPUIMessages;
-//import org.eclipse.jdt.internal.ui.text.JavaCodeReader;
-import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
-
-
-/**
- * Java completion processor.
- */
-public class JavaCompletionProcessor_NotInUseVersion implements IContentAssistProcessor {
-               
-       private static class ContextInformationWrapper implements IContextInformation, IContextInformationExtension {
-               
-               private final IContextInformation fContextInformation;
-               private int fPosition;
-               
-               public ContextInformationWrapper(IContextInformation contextInformation) {
-                       fContextInformation= contextInformation;
-               }
-               
-               /*
-                * @see IContextInformation#getContextDisplayString()
-                */
-               public String getContextDisplayString() {
-                       return fContextInformation.getContextDisplayString();
-               }
-
-                       /*
-                * @see IContextInformation#getImage()
-                */
-               public Image getImage() {
-                       return fContextInformation.getImage();
-               }
-
-               /*
-                * @see IContextInformation#getInformationDisplayString()
-                */
-               public String getInformationDisplayString() {
-                       return fContextInformation.getInformationDisplayString();
-               }
-
-               /*
-                * @see IContextInformationExtension#getContextInformationPosition()
-                */
-               public int getContextInformationPosition() {
-                       return fPosition;
-               }
-               
-               public void setContextInformationPosition(int position) {
-                       fPosition= position;    
-               }
-       };
-       
-       
-//     private final static String VISIBILITY= JavaCore.CODEASSIST_VISIBILITY_CHECK;
-       private final static String ENABLED= "enabled"; //$NON-NLS-1$
-       private final static String DISABLED= "disabled"; //$NON-NLS-1$
-       
-       
-       
-       private IEditorPart fEditor;
-//     private ResultCollector fCollector;
-//     private IWorkingCopyManager fManager;
-       private IContextInformationValidator fValidator;
-       
-       private char[] fProposalAutoActivationSet;
-       private JavaCompletionProposalComparator fComparator;
-       private boolean fAllowAddImports;
-        
-       private TemplateEngine fTemplateEngine;
-//     private ExperimentalResultCollector fExperimentalCollector;
-       
-       private int fNumberOfComputedResults= 0;
-       
-       
-       public JavaCompletionProcessor_NotInUseVersion(IEditorPart editor) {
-               fEditor= editor;
-//             fCollector= new ResultCollector();
-//             fManager= JavaPlugin.getDefault().getWorkingCopyManager();
-               ContextType contextType= ContextTypeRegistry.getInstance().getContextType("php"); //$NON-NLS-1$
-               if (contextType != null)
-                       fTemplateEngine= new TemplateEngine(contextType);
-//             fExperimentalCollector= new ExperimentalResultCollector();
-               fAllowAddImports= true;
-               
-               fComparator= new JavaCompletionProposalComparator();
-       }
-       
-       /**
-        * Sets this processor's set of characters triggering the activation of the
-        * completion proposal computation.
-        * 
-        * @param activationSet the activation set
-        */
-       public void setCompletionProposalAutoActivationCharacters(char[] activationSet) {
-               fProposalAutoActivationSet= activationSet;
-       }
-       
-       /**
-        * Tells this processor to restrict its proposal to those element
-        * visible in the actual invocation context.
-        * 
-        * @param restrict <code>true</code> if proposals should be restricted
-        */
-       public void restrictProposalsToVisibility(boolean restrict) {
-//             Hashtable options= JavaCore.getOptions();
-//             Object value= options.get(VISIBILITY);
-//             if (value instanceof String) {
-//                     String newValue= restrict ? ENABLED : DISABLED;
-//                     if ( !newValue.equals((String) value)) {
-//                             options.put(VISIBILITY, newValue);
-//                             JavaCore.setOptions(options);
-//                     }
-//             }
-       }
-       
-       /**
-        * Tells this processor to order the proposals alphabetically.
-        * 
-        * @param order <code>true</code> if proposals should be ordered.
-        */
-       public void orderProposalsAlphabetically(boolean order) {
-               fComparator.setOrderAlphabetically(order);
-       }
-       
-       /**
-        * Tells this processor to restrict is proposals to those
-        * starting with matching cases.
-        * 
-        * @param restrict <code>true</code> if proposals should be restricted
-        */
-       public void restrictProposalsToMatchingCases(boolean restrict) {
-               // not yet supported
-       }
-       
-       /**
-        * Tells this processor to add import statement for proposals that have
-        * a fully qualified type name
-        * 
-        * @param restrict <code>true</code> if import can be added
-        */
-       public void allowAddingImports(boolean allowAddingImports) {
-               fAllowAddImports= allowAddingImports;
-       }       
-               
-       /**
-        * @see IContentAssistProcessor#getErrorMessage()
-        */  
-       public String getErrorMessage() {
-       //      if (fNumberOfComputedResults == 0)
-                       return PHPUIMessages.getString("JavaEditor.codeassist.noCompletions"); //$NON-NLS-1$
-//             return fCollector.getErrorMessage();
-       }
-
-       /**
-        * @see IContentAssistProcessor#getContextInformationValidator()
-        */
-       public IContextInformationValidator getContextInformationValidator() {
-//             if (fValidator == null)
-//                     fValidator= new JavaParameterListValidator();
-               return fValidator;
-       }
-
-       /**
-        * @see IContentAssistProcessor#getContextInformationAutoActivationCharacters()
-        */
-       public char[] getContextInformationAutoActivationCharacters() {
-               return null;
-       }
-
-       /**
-        * @see IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
-        */
-       public char[] getCompletionProposalAutoActivationCharacters() {
-               return fProposalAutoActivationSet;
-       }
-       
-//     private boolean looksLikeMethod(JavaCodeReader reader) throws IOException {
-//             int curr= reader.read();
-//             while (curr != JavaCodeReader.EOF && Character.isWhitespace((char) curr))
-//                     curr= reader.read();
-//                     
-//             if (curr == JavaCodeReader.EOF)
-//                     return false;
-//
-//             return Character.isJavaIdentifierPart((char) curr) || Character.isJavaIdentifierStart((char) curr);
-//     }
-       
-       private int guessContextInformationPosition(ITextViewer viewer, int offset) {
-               int contextPosition= offset;
-                       
-               IDocument document= viewer.getDocument();
-               
-//             try {
-//
-//                     JavaCodeReader reader= new JavaCodeReader();
-//                     reader.configureBackwardReader(document, offset, true, true);
-//     
-//                     int nestingLevel= 0;
-//
-//                     int curr= reader.read();                
-//                     while (curr != JavaCodeReader.EOF) {
-//
-//                             if (')' == (char) curr)
-//                                     ++ nestingLevel;
-//
-//                             else if ('(' == (char) curr) {
-//                                     -- nestingLevel;
-//                             
-//                                     if (nestingLevel < 0) {
-//                                             int start= reader.getOffset();
-//                                             if (looksLikeMethod(reader))
-//                                                     return start + 1;
-//                                     }       
-//                             }
-//
-//                             curr= reader.read();                                    
-//                     }
-//             } catch (IOException e) {
-//             }
-               
-               return contextPosition;
-       }               
-       
-       private List addContextInformations(ITextViewer viewer, int offset) {
-               ICompletionProposal[] proposals= internalComputeCompletionProposals(viewer, offset, -1);
-
-               List result= new ArrayList();
-               for (int i= 0; i < proposals.length; i++) {
-                       IContextInformation contextInformation= proposals[i].getContextInformation();
-                       if (contextInformation != null) {
-                               ContextInformationWrapper wrapper= new ContextInformationWrapper(contextInformation);
-                               wrapper.setContextInformationPosition(offset);
-                               result.add(wrapper);                            
-                       }
-               }
-               return result;
-       }
-       
-       /**
-        * @see IContentAssistProcessor#computeContextInformation(ITextViewer, int)
-        */
-       public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) {
-               int contextInformationPosition= guessContextInformationPosition(viewer, offset);
-               List result= addContextInformations(viewer, contextInformationPosition);
-               return (IContextInformation[]) result.toArray(new IContextInformation[result.size()]);
-       }
-       
-       /**
-        * Order the given proposals.
-        */
-       private ICompletionProposal[] order(ICompletionProposal[] proposals) {
-               Arrays.sort(proposals, fComparator);
-               return proposals;       
-       }
-       
-       /**
-        * @see IContentAssistProcessor#computeCompletionProposals(ITextViewer, int)
-        */
-       public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
-               int contextInformationPosition= guessContextInformationPosition(viewer, offset);
-               return internalComputeCompletionProposals(viewer, offset, contextInformationPosition);
-       }
-       
-       private ICompletionProposal[] internalComputeCompletionProposals(ITextViewer viewer, int offset, int contextOffset) {
-               
-//             ICompilationUnit unit= fManager.getWorkingCopy(fEditor.getEditorInput());
-//             IJavaCompletionProposal[] results;
-//
-//             if (JavaPlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.CODEASSIST_FILL_ARGUMENT_NAMES)) {
-//                             
-//                     try {
-//                             if (unit != null) {
-//     
-//                                     fExperimentalCollector.reset(offset, contextOffset, unit.getJavaProject(), fAllowAddImports ? unit : null);
-//                                     fExperimentalCollector.setViewer(viewer);
-//                                     
-//                                     Point selection= viewer.getSelectedRange();
-//                                     if (selection.y > 0)
-//                                             fExperimentalCollector.setReplacementLength(selection.y);
-//                                     
-//                                     unit.codeComplete(offset, fExperimentalCollector);
-//                             }
-//                     } catch (JavaModelException x) {
-//                             Shell shell= viewer.getTextWidget().getShell();
-//                             ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
-//                     }                               
-//
-//                     results= fExperimentalCollector.getResults();
-//
-//             } else {
-//
-//                     try {
-//                             if (unit != null) {
-//     
-//                                     fCollector.reset(offset, contextOffset, unit.getJavaProject(), fAllowAddImports ? unit : null);
-//                                     Point selection= viewer.getSelectedRange();
-//                                     if (selection.y > 0)
-//                                             fCollector.setReplacementLength(selection.y);
-//                                     
-//                                     unit.codeComplete(offset, fCollector);
-//                             }
-//                     } catch (JavaModelException x) {
-//                             Shell shell= viewer.getTextWidget().getShell();
-//                             ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
-//                     }
-//                     
-//                     results= fCollector.getResults();
-//             }
-
-               if (fTemplateEngine != null) {
-          IJavaCompletionProposal[] results;
-//                     try {
-                               fTemplateEngine.reset();
-                               fTemplateEngine.complete(viewer, offset); //, unit);
-//                     } catch (JavaModelException x) {
-//                             Shell shell= viewer.getTextWidget().getShell();
-//                             ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
-//                     }                               
-                        
-                       IJavaCompletionProposal[] templateResults= fTemplateEngine.getResults();
-       
-                       // concatenate arrays
-                       IJavaCompletionProposal[] total= new IJavaCompletionProposal[templateResults.length]; // +results.length ];
-                       System.arraycopy(templateResults, 0, total, 0, templateResults.length);
-//                     System.arraycopy(results, 0, total, templateResults.length, results.length);
-                       results= total;
-//             }
-               
-               fNumberOfComputedResults= (results == null ? 0 : results.length);
-               
-               /*
-                * Order here and not in result collector to make sure that the order
-                * applies to all proposals and not just those of the compilation unit. 
-                */
-               return order(results);
-    }
-    return new IJavaCompletionProposal[0];
-       }
-}
\ No newline at end of file
@@ -2,14 +2,14 @@ package net.sourceforge.phpdt.internal.ui.text.java;
 
 import java.util.Comparator;
 
-public class JavaCompletionProposalComparator implements Comparator {
+public class PHPCompletionProposalComparator implements Comparator {
 
        private boolean fOrderAlphabetically;
 
        /**
         * Constructor for CompletionProposalComparator.
         */
-       public JavaCompletionProposalComparator() {
+       public PHPCompletionProposalComparator() {
                fOrderAlphabetically= false;
        }
        
@@ -21,8 +21,8 @@ public class JavaCompletionProposalComparator implements Comparator {
         * @see Comparator#compare(Object, Object)
         */
        public int compare(Object o1, Object o2) {
-               IJavaCompletionProposal c1= (IJavaCompletionProposal) o1;
-               IJavaCompletionProposal c2= (IJavaCompletionProposal) o2;
+               IPHPCompletionProposal c1= (IPHPCompletionProposal) o1;
+               IPHPCompletionProposal c2= (IPHPCompletionProposal) o2;
                if (!fOrderAlphabetically) {
                        int relevanceDif= c2.getRelevance() - c1.getRelevance();
                        if (relevanceDif != 0) {
index 68d6a36..2dcd584 100644 (file)
@@ -7,10 +7,10 @@ package net.sourceforge.phpdt.internal.ui.text.template;
 import java.util.ArrayList;
 
 import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
@@ -46,8 +46,8 @@ public class BuiltInEngine {
        /**
         * Returns the array of matching templates.
         */
-       public IJavaCompletionProposal[] getResults() {
-               return (IJavaCompletionProposal[]) fProposals.toArray(new IJavaCompletionProposal[fProposals.size()]);
+       public IPHPCompletionProposal[] getResults() {
+               return (IPHPCompletionProposal[]) fProposals.toArray(new IPHPCompletionProposal[fProposals.size()]);
        }
 
        /**
@@ -71,7 +71,7 @@ public class BuiltInEngine {
                        return;
                
                ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition);//mpilationUnit);
-               CompilationUnitContext context= (CompilationUnitContext) fContextType.createContext();
+               PHPUnitContext context= (PHPUnitContext) fContextType.createContext();
                int start= context.getStart();
                int end= context.getEnd();
                IRegion region= new Region(start, end - start);
index 1ff6be7..60f1e6d 100644 (file)
@@ -9,9 +9,9 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
 import net.sourceforge.phpdt.internal.corext.template.TemplatePosition;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.JavaTemplateMessages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPTemplateMessages;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import org.eclipse.core.runtime.CoreException;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
@@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Shell;
 /**
  * A PHP identifier proposal.
  */
-public class BuiltInProposal implements IJavaCompletionProposal {
+public class BuiltInProposal implements IPHPCompletionProposal {
 
   private final String fTemplate;
   private final TemplateContext fContext;
@@ -224,8 +224,8 @@ public class BuiltInProposal implements IJavaCompletionProposal {
    */
   public int getRelevance() {
 
-    if (fContext instanceof CompilationUnitContext) {
-      CompilationUnitContext context = (CompilationUnitContext) fContext;
+    if (fContext instanceof PHPUnitContext) {
+      PHPUnitContext context = (PHPUnitContext) fContext;
       switch (context.getCharacterBeforeStart()) {
         // high relevance after whitespace
         case ' ' :
index 6c4e62a..90d6c44 100644 (file)
@@ -7,10 +7,10 @@ package net.sourceforge.phpdt.internal.ui.text.template;
 import java.util.ArrayList;
 
 import net.sourceforge.phpdt.internal.corext.template.ContextType;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
@@ -46,8 +46,8 @@ public class IdentifierEngine {
        /**
         * Returns the array of matching templates.
         */
-       public IJavaCompletionProposal[] getResults() {
-               return (IJavaCompletionProposal[]) fProposals.toArray(new IJavaCompletionProposal[fProposals.size()]);
+       public IPHPCompletionProposal[] getResults() {
+               return (IPHPCompletionProposal[]) fProposals.toArray(new IPHPCompletionProposal[fProposals.size()]);
        }
 
        /**
@@ -71,7 +71,7 @@ public class IdentifierEngine {
                        return;
                
                ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition);//mpilationUnit);
-               CompilationUnitContext context= (CompilationUnitContext) fContextType.createContext();
+               PHPUnitContext context= (PHPUnitContext) fContextType.createContext();
                int start= context.getStart();
                int end= context.getEnd();
                IRegion region= new Region(start, end - start);
index 8e7502e..f104804 100644 (file)
@@ -9,9 +9,9 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
 import net.sourceforge.phpdt.internal.corext.template.TemplatePosition;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.JavaTemplateMessages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPTemplateMessages;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import org.eclipse.core.runtime.CoreException;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
@@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Shell;
 /**
  * A PHP identifier proposal.
  */
-public class IdentifierProposal implements IJavaCompletionProposal {
+public class IdentifierProposal implements IPHPCompletionProposal {
 
   private final String fTemplate;
   private final TemplateContext fContext;
@@ -228,8 +228,8 @@ public class IdentifierProposal implements IJavaCompletionProposal {
    */
   public int getRelevance() {
 
-    if (fContext instanceof CompilationUnitContext) {
-      CompilationUnitContext context = (CompilationUnitContext) fContext;
+    if (fContext instanceof PHPUnitContext) {
+      PHPUnitContext context = (PHPUnitContext) fContext;
       switch (context.getCharacterBeforeStart()) {
         // high relevance after whitespace
         case ' ' :
index 5990e83..b946e5f 100644 (file)
@@ -7,12 +7,12 @@ package net.sourceforge.phpdt.internal.ui.text.template;
 import java.util.ArrayList;
 
 import net.sourceforge.phpdt.internal.corext.template.ContextType;
+import net.sourceforge.phpdt.internal.corext.template.DocumentTemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.Template;
 import net.sourceforge.phpdt.internal.corext.template.Templates;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContextType;
+import net.sourceforge.phpdt.internal.corext.template.php.CompilationUnitContextType;
 import net.sourceforge.phpdt.internal.ui.PHPUiImages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import org.eclipse.jface.text.IDocument;
 import org.eclipse.jface.text.IRegion;
 import org.eclipse.jface.text.ITextViewer;
@@ -48,8 +48,8 @@ public class TemplateEngine {
        /**
         * Returns the array of matching templates.
         */
-       public IJavaCompletionProposal[] getResults() {
-               return (IJavaCompletionProposal[]) fProposals.toArray(new IJavaCompletionProposal[fProposals.size()]);
+       public IPHPCompletionProposal[] getResults() {
+               return (IPHPCompletionProposal[]) fProposals.toArray(new IPHPCompletionProposal[fProposals.size()]);
        }
 
        /**
@@ -73,7 +73,7 @@ public class TemplateEngine {
                        return;
                
                ((CompilationUnitContextType) fContextType).setContextParameters(document, completionPosition);//mpilationUnit);
-               CompilationUnitContext context= (CompilationUnitContext) fContextType.createContext();
+               DocumentTemplateContext context= (DocumentTemplateContext) fContextType.createContext();
                int start= context.getStart();
                int end= context.getEnd();
                IRegion region= new Region(start, end - start);
index c97c29a..8350ec3 100644 (file)
@@ -9,9 +9,9 @@ import net.sourceforge.phpdt.internal.corext.template.TemplateBuffer;
 import net.sourceforge.phpdt.internal.corext.template.TemplateContext;
 import net.sourceforge.phpdt.internal.corext.template.TemplateMessages;
 import net.sourceforge.phpdt.internal.corext.template.TemplatePosition;
-import net.sourceforge.phpdt.internal.corext.template.java.CompilationUnitContext;
-import net.sourceforge.phpdt.internal.corext.template.java.JavaTemplateMessages;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPUnitContext;
+import net.sourceforge.phpdt.internal.corext.template.php.PHPTemplateMessages;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
 import org.eclipse.core.runtime.CoreException;
 import net.sourceforge.phpdt.internal.ui.text.link.LinkedPositionManager;
@@ -32,7 +32,7 @@ import org.eclipse.swt.widgets.Shell;
 /**
  * A template proposal.
  */
-public class TemplateProposal implements IJavaCompletionProposal {
+public class TemplateProposal implements IPHPCompletionProposal {
 
        private final Template fTemplate;
        private final TemplateContext fContext;
@@ -114,7 +114,7 @@ public class TemplateProposal implements IJavaCompletionProposal {
                for (int i= 0; i != variables.length; i++) {
                        TemplatePosition variable= variables[i];
                        
-                       if (variable.getName().equals(JavaTemplateMessages.getString("GlobalVariables.variable.name.cursor"))) //$NON-NLS-1$
+                       if (variable.getName().equals(PHPTemplateMessages.getString("GlobalVariables.variable.name.cursor"))) //$NON-NLS-1$
                                return variable.getOffsets()[0];
                }
 
@@ -220,8 +220,8 @@ public class TemplateProposal implements IJavaCompletionProposal {
         */
        public int getRelevance() {
 
-               if (fContext instanceof CompilationUnitContext) {
-                       CompilationUnitContext context= (CompilationUnitContext) fContext;
+               if (fContext instanceof PHPUnitContext) {
+                       PHPUnitContext context= (PHPUnitContext) fContext;
                        switch (context.getCharacterBeforeStart()) { 
                        // high relevance after whitespace
                        case ' ':
index 059485c..6b508d2 100644 (file)
@@ -15,9 +15,12 @@ public class PHPPerspectiveFactory implements IPerspectiveFactory {
        public void createInitialLayout(IPageLayout layout) {
                String editorArea = layout.getEditorArea();
                
-               IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea", IPageLayout.LEFT, (float)0.25, editorArea);
-               phpResourcesArea.addView(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
-               
+//             IFolderLayout phpResourcesArea = layout.createFolder("phpresourcesarea", IPageLayout.LEFT, (float)0.25, editorArea);
+//             phpResourcesArea.addView(PHPeclipsePlugin.PHP_RESOURCES_VIEW_ID);
+               IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
+    folder.addView(IPageLayout.ID_RES_NAV);
+    folder.addPlaceholder(IPageLayout.ID_RES_NAV);
+    
                IFolderLayout consoleArea = layout.createFolder("consoleArea", IPageLayout.BOTTOM, (float)0.75, editorArea);
                
                consoleArea.addView(IPageLayout.ID_TASK_LIST);
index 04f7d9e..71f26dc 100644 (file)
@@ -191,27 +191,27 @@ public class PHPEditor extends TextEditor {
     return super.getAdapter(required);
   }
 
-  public void openContextHelp() {
-    IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
-    ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection();
-    int pos = selection.getOffset();
-    String word = getFunctionName(doc, pos);
-    openContextHelp(word);
-  }
-
-  private void openContextHelp(String word) {
-    open(word);
-  }
-
-  public static void open(String word) {
-    IHelp help = WorkbenchHelp.getHelpSupport();
-    if (help != null) {
-      IHelpResource helpResource = new PHPFunctionHelpResource(word);
-      WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
-    } else {
-      //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
-    }
-  }
+//  public void openContextHelp() {
+//    IDocument doc = this.getDocumentProvider().getDocument(this.getEditorInput());
+//    ITextSelection selection = (ITextSelection) this.getSelectionProvider().getSelection();
+//    int pos = selection.getOffset();
+//    String word = getFunctionName(doc, pos);
+//    openContextHelp(word);
+//  }
+//
+//  private void openContextHelp(String word) {
+//    open(word);
+//  }
+//
+//  public static void open(String word) {
+//    IHelp help = WorkbenchHelp.getHelpSupport();
+//    if (help != null) {
+//      IHelpResource helpResource = new PHPFunctionHelpResource(word);
+//      WorkbenchHelp.getHelpSupport().displayHelpResource(helpResource);
+//    } else {
+//      //   showMessage(shell, dialogTitle, ActionMessages.getString("Open help not available"), false); //$NON-NLS-1$
+//    }
+//  }
 
   private String getFunctionName(IDocument doc, int pos) {
     Point word = PHPWordExtractor.findWord(doc, pos);
index 2cb2397..80a8e6f 100644 (file)
@@ -11,9 +11,12 @@ Contributors:
 **********************************************************************/
 package net.sourceforge.phpeclipse.phpeditor;
 
-import java.util.List;
-
-import org.eclipse.swt.graphics.RGB;
+import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
+import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
+import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
 import org.eclipse.jface.text.IAutoIndentStrategy;
 import org.eclipse.jface.text.IDocument;
@@ -26,18 +29,11 @@ import org.eclipse.jface.text.presentation.IPresentationReconciler;
 import org.eclipse.jface.text.presentation.PresentationReconciler;
 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
-import org.eclipse.jface.text.rules.IToken;
-import org.eclipse.jface.text.rules.RuleBasedDamagerRepairer;
 import org.eclipse.jface.text.rules.Token;
 import org.eclipse.jface.text.source.IAnnotationHover;
 import org.eclipse.jface.text.source.ISourceViewer;
 import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
-import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
-//import net.sourceforge.phpeclipse.phpeditor.html.JavaDocCompletionProcessor;
-import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
+import org.eclipse.swt.graphics.RGB;
 
 /**
  * Configuration for an <code>SourceViewer</code> which shows PHP code.
@@ -88,8 +84,9 @@ public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
   public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
 
     ContentAssistant assistant = new ContentAssistant();
-    // assistant.setContentAssistProcessor(new PHPCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
+    assistant.setContentAssistProcessor(new HTMLCompletionProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
     assistant.setContentAssistProcessor(new PHPCompletionProcessor(), PHPPartitionScanner.PHP);
+    //assistant.setContentAssistProcessor(new PHPCompletionProcessor(), PHPPartitionScanner.HTML);
 
     assistant.enableAutoActivation(true);
     assistant.setAutoActivationDelay(500);
index a96712b..aaee068 100644 (file)
@@ -17,8 +17,8 @@ import java.util.List;
 
 import net.sourceforge.phpdt.internal.corext.template.ContextType;
 import net.sourceforge.phpdt.internal.corext.template.ContextTypeRegistry;
-import net.sourceforge.phpdt.internal.ui.text.java.IJavaCompletionProposal;
-import net.sourceforge.phpdt.internal.ui.text.java.JavaCompletionProposalComparator;
+import net.sourceforge.phpdt.internal.ui.text.java.IPHPCompletionProposal;
+import net.sourceforge.phpdt.internal.ui.text.java.PHPCompletionProposalComparator;
 import net.sourceforge.phpdt.internal.ui.text.template.BuiltInEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.IdentifierEngine;
 import net.sourceforge.phpdt.internal.ui.text.template.TemplateEngine;
@@ -236,7 +236,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
 
   protected IContextInformationValidator fValidator = new Validator();
   private TemplateEngine fTemplateEngine;
-  private JavaCompletionProposalComparator fComparator;
+  private PHPCompletionProposalComparator fComparator;
   private int fNumberOfComputedResults = 0;
 
   public PHPCompletionProcessor() {
@@ -245,7 +245,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
     if (contextType != null)
       fTemplateEngine = new TemplateEngine(contextType);
 
-    fComparator = new JavaCompletionProposalComparator();
+    fComparator = new PHPCompletionProposalComparator();
   }
   /* (non-Javadoc)
    * Method declared on IContentAssistProcessor
@@ -307,9 +307,9 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       //        ErrorDialog.openError(shell, JavaTextMessages.getString("CompletionProcessor.error.accessing.title"), JavaTextMessages.getString("CompletionProcessor.error.accessing.message"), x.getStatus()); //$NON-NLS-2$ //$NON-NLS-1$
       //      }       
 
-      IJavaCompletionProposal[] templateResults = fTemplateEngine.getResults();
+      IPHPCompletionProposal[] templateResults = fTemplateEngine.getResults();
 
-      IJavaCompletionProposal[] identifierResults = new IJavaCompletionProposal[0];
+      IPHPCompletionProposal[] identifierResults = new IPHPCompletionProposal[0];
       if (identifiers != null) {
         IdentifierEngine identifierEngine;
         String proposal;
@@ -328,7 +328,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
         }
       }
 
-      IJavaCompletionProposal[] builtinResults = new IJavaCompletionProposal[0];
+      IPHPCompletionProposal[] builtinResults = new IPHPCompletionProposal[0];
       if (PHPFunctionNames.FUNCTION_NAMES != null) {
         BuiltInEngine builtinEngine;
         String proposal;
@@ -342,8 +342,8 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
       }
 
       // concatenate arrays
-      IJavaCompletionProposal[] total;
-      total = new IJavaCompletionProposal[templateResults.length + identifierResults.length + builtinResults.length];
+      IPHPCompletionProposal[] total;
+      total = new IPHPCompletionProposal[templateResults.length + identifierResults.length + builtinResults.length];
       System.arraycopy(templateResults, 0, total, 0, templateResults.length);
       System.arraycopy(identifierResults, 0, total, templateResults.length, identifierResults.length);
       System.arraycopy(builtinResults, 0, total, templateResults.length + identifierResults.length, builtinResults.length);
@@ -356,7 +356,7 @@ public class PHPCompletionProcessor implements IContentAssistProcessor {
        */
       return order(results);
     }
-    return new IJavaCompletionProposal[0];
+    return new IPHPCompletionProposal[0];
   }
 
   private int guessContextInformationPosition(ITextViewer viewer, int offset) {
index 85aa0d2..a797115 100644 (file)
@@ -32,11 +32,11 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner {
   private final static String SKIP = "__skip"; //$NON-NLS-1$
   public final static String HTML_MULTILINE_COMMENT = "__html_multiline_comment"; //$NON-NLS-1$
   //   public final static String JAVA_DOC= "__java_javadoc"; //$NON-NLS-1$
-  public final static String PHP = "__php";
-  //  public final static String HTML = "__html";
+  public final static String PHP = "__php"; //$NON-NLS-1$
+  //public final static String HTML = "__html"; //$NON-NLS-1$
 
   public final static IToken php = new Token(PHP);
-  //  public final static IToken html = new Token(HTML);
+  //public final static IToken html = new Token(HTML);
   public final static IToken comment = new Token(HTML_MULTILINE_COMMENT);
 
   protected final static char[] php0EndSequence = { '<', '?' };
@@ -235,247 +235,247 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner {
   //    }
   //  }
 
-  public class HTMLPatternRule implements IPredicateRule {
-
-    protected static final int UNDEFINED = -1;
-
-    /** The token to be returned on success */
-    protected IToken fToken;
-
-    /** The pattern's column constrain */
-    protected int fColumn = UNDEFINED;
-    /** The pattern's escape character */
-    protected char fEscapeCharacter;
-    /** Indicates whether end of line termines the pattern */
-    protected boolean fBreaksOnEOL;
-
-    /**
-     * Creates a rule for the given starting and ending sequence.
-     * When these sequences are detected the rule will return the specified token.
-     * Alternatively, the sequence can also be ended by the end of the line.
-     * Any character which follows the given escapeCharacter will be ignored.
-     *
-     * @param startSequence the pattern's start sequence
-     * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
-     * @param token the token which will be returned on success
-     * @param escapeCharacter any character following this one will be ignored
-     * @param indicates whether the end of the line also termines the pattern
-     */
-    public HTMLPatternRule(IToken token) {
-      fToken = token;
-      fEscapeCharacter = (char) 0;
-      fBreaksOnEOL = false;
-    }
-
-    /**
-     * Sets a column constraint for this rule. If set, the rule's token
-     * will only be returned if the pattern is detected starting at the 
-     * specified column. If the column is smaller then 0, the column
-     * constraint is considered removed.
-     *
-     * @param column the column in which the pattern starts
-     */
-    public void setColumnConstraint(int column) {
-      if (column < 0)
-        column = UNDEFINED;
-      fColumn = column;
-    }
-
-    /**
-     * Evaluates this rules without considering any column constraints.
-     *
-     * @param scanner the character scanner to be used
-     * @return the token resulting from this evaluation
-     */
-    protected IToken doEvaluate(ICharacterScanner scanner) {
-      return doEvaluate(scanner, false);
-    }
-
-    /**
-     * Evaluates this rules without considering any column constraints. Resumes
-     * detection, i.e. look sonly for the end sequence required by this rule if the
-     * <code>resume</code> flag is set.
-     *
-     * @param scanner the character scanner to be used
-     * @param resume <code>true</code> if detection should be resumed, <code>false</code> otherwise
-     * @return the token resulting from this evaluation
-     * @since 2.0
-     */
-    protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
-
-      if (resume) {
-
-        if (endSequenceDetected(scanner))
-          return fToken;
-
-      } else {
-
-        int c = scanner.read();
-        //      if (c == fStartSequence[0]) {
-        //        if (sequenceDetected(scanner, fStartSequence, false)) {
-        if (endSequenceDetected(scanner))
-          return fToken;
-        //        }
-        //      }
-      }
-
-      scanner.unread();
-      return Token.UNDEFINED;
-    }
-
-    /*
-     * @see IRule#evaluate
-     */
-    public IToken evaluate(ICharacterScanner scanner) {
-      return evaluate(scanner, false);
-    }
-
-    /**
-     * Returns whether the end sequence was detected. As the pattern can be considered 
-     * ended by a line delimiter, the result of this method is <code>true</code> if the 
-     * rule breaks on the end  of the line, or if the EOF character is read.
-     *
-     * @param scanner the character scanner to be used
-     * @return <code>true</code> if the end sequence has been detected
-     */
-    protected boolean endSequenceDetected(ICharacterScanner scanner) {
-      int c;
-
-      char[][] delimiters = scanner.getLegalLineDelimiters();
-      while ((c = scanner.read()) != ICharacterScanner.EOF) {
-        if (c == '<') {
-          //       scanner.unread();
-          if (sequenceDetected(scanner, php2EndSequence, true)) {
-            // <?PHP
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            return true;
-          }
-          if (sequenceDetected(scanner, php1EndSequence, true)) {
-            // <?php
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            scanner.unread();
-            return true;
-          }
-          if (sequenceDetected(scanner, php0EndSequence, true)) {
-            // <?
-            scanner.unread();
-            scanner.unread();
-            return true;
-          }
-          //      scanner.read();
-        }
-
-      }
-      scanner.unread();
-      return false;
-    }
-
-    /**
-     * Returns whether the next characters to be read by the character scanner
-     * are an exact match with the given sequence. No escape characters are allowed 
-     * within the sequence. If specified the sequence is considered to be found
-     * when reading the EOF character.
-     *
-     * @param scanner the character scanner to be used
-     * @param sequence the sequence to be detected
-     * @param eofAllowed indicated whether EOF terminates the pattern
-     * @return <code>true</code> if the given sequence has been detected
-     */
-    protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
-      for (int i = 1; i < sequence.length; i++) {
-        int c = scanner.read();
-        if (c == ICharacterScanner.EOF && eofAllowed) {
-          return true;
-        } else if (c != sequence[i]) {
-          // Non-matching character detected, rewind the scanner back to the start.
-          scanner.unread();
-          for (int j = i - 1; j > 0; j--)
-            scanner.unread();
-          return false;
-        }
-      }
-
-      return true;
-    }
-
-    /*
-     * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
-     * @since 2.0
-     */
-    public IToken evaluate(ICharacterScanner scanner, boolean resume) {
-      if (fColumn == UNDEFINED)
-        return doEvaluate(scanner, resume);
-
-      int c = scanner.read();
-      scanner.unread();
-      //    if (c == fStartSequence[0])
-      return (fColumn == scanner.getColumn() ? doEvaluate(scanner, resume) : Token.UNDEFINED);
-      //    else
-      //      return Token.UNDEFINED;
-    }
-
-    /*
-     * @see IPredicateRule#getSuccessToken()
-     * @since 2.0
-     */
-    public IToken getSuccessToken() {
-      return fToken;
-    }
-  }
+//  public class HTMLPatternRule implements IPredicateRule {
+//
+//    protected static final int UNDEFINED = -1;
+//
+//    /** The token to be returned on success */
+//    protected IToken fToken;
+//
+//    /** The pattern's column constrain */
+//    protected int fColumn = UNDEFINED;
+//    /** The pattern's escape character */
+//    protected char fEscapeCharacter;
+//    /** Indicates whether end of line termines the pattern */
+//    protected boolean fBreaksOnEOL;
+//
+//    /**
+//     * Creates a rule for the given starting and ending sequence.
+//     * When these sequences are detected the rule will return the specified token.
+//     * Alternatively, the sequence can also be ended by the end of the line.
+//     * Any character which follows the given escapeCharacter will be ignored.
+//     *
+//     * @param startSequence the pattern's start sequence
+//     * @param endSequence the pattern's end sequence, <code>null</code> is a legal value
+//     * @param token the token which will be returned on success
+//     * @param escapeCharacter any character following this one will be ignored
+//     * @param indicates whether the end of the line also termines the pattern
+//     */
+//    public HTMLPatternRule(IToken token) {
+//      fToken = token;
+//      fEscapeCharacter = (char) 0;
+//      fBreaksOnEOL = false;
+//    }
+//
+//    /**
+//     * Sets a column constraint for this rule. If set, the rule's token
+//     * will only be returned if the pattern is detected starting at the 
+//     * specified column. If the column is smaller then 0, the column
+//     * constraint is considered removed.
+//     *
+//     * @param column the column in which the pattern starts
+//     */
+//    public void setColumnConstraint(int column) {
+//      if (column < 0)
+//        column = UNDEFINED;
+//      fColumn = column;
+//    }
+//
+//    /**
+//     * Evaluates this rules without considering any column constraints.
+//     *
+//     * @param scanner the character scanner to be used
+//     * @return the token resulting from this evaluation
+//     */
+//    protected IToken doEvaluate(ICharacterScanner scanner) {
+//      return doEvaluate(scanner, false);
+//    }
+//
+//    /**
+//     * Evaluates this rules without considering any column constraints. Resumes
+//     * detection, i.e. look sonly for the end sequence required by this rule if the
+//     * <code>resume</code> flag is set.
+//     *
+//     * @param scanner the character scanner to be used
+//     * @param resume <code>true</code> if detection should be resumed, <code>false</code> otherwise
+//     * @return the token resulting from this evaluation
+//     * @since 2.0
+//     */
+//    protected IToken doEvaluate(ICharacterScanner scanner, boolean resume) {
+//
+//      if (resume) {
+//
+//        if (endSequenceDetected(scanner))
+//          return fToken;
+//
+//      } else {
+//
+//        int c = scanner.read();
+//        //      if (c == fStartSequence[0]) {
+//        //        if (sequenceDetected(scanner, fStartSequence, false)) {
+//        if (endSequenceDetected(scanner))
+//          return fToken;
+//        //        }
+//        //      }
+//      }
+//
+//      scanner.unread();
+//      return Token.UNDEFINED;
+//    }
+//
+//    /*
+//     * @see IRule#evaluate
+//     */
+//    public IToken evaluate(ICharacterScanner scanner) {
+//      return evaluate(scanner, false);
+//    }
+//
+//    /**
+//     * Returns whether the end sequence was detected. As the pattern can be considered 
+//     * ended by a line delimiter, the result of this method is <code>true</code> if the 
+//     * rule breaks on the end  of the line, or if the EOF character is read.
+//     *
+//     * @param scanner the character scanner to be used
+//     * @return <code>true</code> if the end sequence has been detected
+//     */
+//    protected boolean endSequenceDetected(ICharacterScanner scanner) {
+//      int c;
+//
+//      char[][] delimiters = scanner.getLegalLineDelimiters();
+//      while ((c = scanner.read()) != ICharacterScanner.EOF) {
+//        if (c == '<') {
+//          //       scanner.unread();
+//          if (sequenceDetected(scanner, php2EndSequence, true)) {
+//            // <?PHP
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            return true;
+//          }
+//          if (sequenceDetected(scanner, php1EndSequence, true)) {
+//            // <?php
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            scanner.unread();
+//            return true;
+//          }
+//          if (sequenceDetected(scanner, php0EndSequence, true)) {
+//            // <?
+//            scanner.unread();
+//            scanner.unread();
+//            return true;
+//          }
+//          //      scanner.read();
+//        }
+//
+//      }
+//      scanner.unread();
+//      return false;
+//    }
+//
+//    /**
+//     * Returns whether the next characters to be read by the character scanner
+//     * are an exact match with the given sequence. No escape characters are allowed 
+//     * within the sequence. If specified the sequence is considered to be found
+//     * when reading the EOF character.
+//     *
+//     * @param scanner the character scanner to be used
+//     * @param sequence the sequence to be detected
+//     * @param eofAllowed indicated whether EOF terminates the pattern
+//     * @return <code>true</code> if the given sequence has been detected
+//     */
+//    protected boolean sequenceDetected(ICharacterScanner scanner, char[] sequence, boolean eofAllowed) {
+//      for (int i = 1; i < sequence.length; i++) {
+//        int c = scanner.read();
+//        if (c == ICharacterScanner.EOF && eofAllowed) {
+//          return true;
+//        } else if (c != sequence[i]) {
+//          // Non-matching character detected, rewind the scanner back to the start.
+//          scanner.unread();
+//          for (int j = i - 1; j > 0; j--)
+//            scanner.unread();
+//          return false;
+//        }
+//      }
+//
+//      return true;
+//    }
+//
+//    /*
+//     * @see IPredicateRule#evaluate(ICharacterScanner, boolean)
+//     * @since 2.0
+//     */
+//    public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+//      if (fColumn == UNDEFINED)
+//        return doEvaluate(scanner, resume);
+//
+//      int c = scanner.read();
+//      scanner.unread();
+//      //    if (c == fStartSequence[0])
+//      return (fColumn == scanner.getColumn() ? doEvaluate(scanner, resume) : Token.UNDEFINED);
+//      //    else
+//      //      return Token.UNDEFINED;
+//    }
+//
+//    /*
+//     * @see IPredicateRule#getSuccessToken()
+//     * @since 2.0
+//     */
+//    public IToken getSuccessToken() {
+//      return fToken;
+//    }
+//  }
   /**
    * Detector for empty comments.
    */
-  static class EmptyCommentDetector implements IWordDetector {
-
-    /* (non-Javadoc)
-    * Method declared on IWordDetector
-       */
-    public boolean isWordStart(char c) {
-      return (c == '/');
-    }
-
-    /* (non-Javadoc)
-    * Method declared on IWordDetector
-       */
-    public boolean isWordPart(char c) {
-      return (c == '*' || c == '/');
-    }
-  };
+//  static class EmptyCommentDetector implements IWordDetector {
+//
+//    /* (non-Javadoc)
+//    * Method declared on IWordDetector
+//     */
+//    public boolean isWordStart(char c) {
+//      return (c == '/');
+//    }
+//
+//    /* (non-Javadoc)
+//    * Method declared on IWordDetector
+//     */
+//    public boolean isWordPart(char c) {
+//      return (c == '*' || c == '/');
+//    }
+//  };
 
   /**
    * 
    */
-  static class WordPredicateRule extends WordRule implements IPredicateRule {
-
-    private IToken fSuccessToken;
-
-    public WordPredicateRule(IToken successToken) {
-      super(new EmptyCommentDetector());
-      fSuccessToken = successToken;
-      addWord("/**/", fSuccessToken);
-    }
-
-    /*
-     * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
-     */
-    public IToken evaluate(ICharacterScanner scanner, boolean resume) {
-      return super.evaluate(scanner);
-    }
-
-    /*
-     * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
-     */
-    public IToken getSuccessToken() {
-      return fSuccessToken;
-    }
-  };
+//  static class WordPredicateRule extends WordRule implements IPredicateRule {
+//
+//    private IToken fSuccessToken;
+//
+//    public WordPredicateRule(IToken successToken) {
+//      super(new EmptyCommentDetector());
+//      fSuccessToken = successToken;
+//      addWord("/**/", fSuccessToken);
+//    }
+//
+//    /*
+//     * @see org.eclipse.jface.text.rules.IPredicateRule#evaluate(ICharacterScanner, boolean)
+//     */
+//    public IToken evaluate(ICharacterScanner scanner, boolean resume) {
+//      return super.evaluate(scanner);
+//    }
+//
+//    /*
+//     * @see org.eclipse.jface.text.rules.IPredicateRule#getSuccessToken()
+//     */
+//    public IToken getSuccessToken() {
+//      return fSuccessToken;
+//    }
+//  };
 
   /**
    * Creates the partitioner and sets up the appropriate rules.
@@ -517,7 +517,7 @@ public class PHPPartitionScanner extends RuleBasedPartitionScanner {
     IPredicateRule[] result = new IPredicateRule[rules.size()];
     rules.toArray(result);
     setPredicateRules(result);
-    //    setDefaultReturnToken(html);
+   // setDefaultReturnToken(html);
   }
 
   //    public IToken nextToken() {