3.x RC1 compatibility
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / text / JavaTextTools.java
index 2937b46..5c025c8 100644 (file)
@@ -5,7 +5,6 @@ package net.sourceforge.phpdt.ui.text;
  * All Rights Reserved.
  */
 
-import net.sourceforge.phpdt.internal.ui.text.FastJavaPartitionScanner;
 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
 import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
@@ -16,6 +15,7 @@ import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
 import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
 import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
 
+import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.Preferences;
 import org.eclipse.jface.preference.IPreferenceStore;
 import org.eclipse.jface.text.IDocument;
@@ -26,6 +26,7 @@ import org.eclipse.jface.text.rules.IPartitionTokenScanner;
 import org.eclipse.jface.text.rules.RuleBasedScanner;
 import org.eclipse.jface.util.IPropertyChangeListener;
 import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.ui.part.FileEditorInput;
 //
 //import org.phpeclipse.phpdt.internal.ui.text.FastJavaPartitionScanner;
 //import org.phpeclipse.phpdt.internal.ui.text.JavaColorManager;
@@ -54,7 +55,7 @@ public class JavaTextTools {
   private final static String[] TYPES =
     new String[] {
       IPHPPartitions.PHP_PARTITIONING,
-      IPHPPartitions.PHP_MULTILINE_COMMENT,
+      IPHPPartitions.PHP_PHPDOC_COMMENT,
       IPHPPartitions.HTML,
       IPHPPartitions.HTML_MULTILINE_COMMENT,
       IPHPPartitions.JAVASCRIPT,
@@ -95,7 +96,7 @@ public class JavaTextTools {
   /** The SmartyDoc scanner */
   private SmartyDocCodeScanner fSmartyDocScanner;
   /** The Java partitions scanner */
-  private FastJavaPartitionScanner fPartitionScanner;
+  private PHPPartitionScanner fPartitionScanner;
 
   /** The preference store */
   private IPreferenceStore fPreferenceStore;
@@ -131,7 +132,8 @@ public class JavaTextTools {
     fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
     fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
     fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
-    fPartitionScanner = new FastJavaPartitionScanner();
+//    fPartitionScanner = new FastJavaPartitionScanner();
+    fPartitionScanner = new PHPPartitionScanner();
   }
 
   /**
@@ -167,7 +169,8 @@ public class JavaTextTools {
     fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
     fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
     fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
-    fPartitionScanner = new FastJavaPartitionScanner();
+  //  fPartitionScanner = new FastJavaPartitionScanner();
+    fPartitionScanner = new PHPPartitionScanner();
   }
 
   /**
@@ -362,25 +365,56 @@ public class JavaTextTools {
 
     return partitioner;
   }
-
        /**
-        * Sets up the Java document partitioner for the given document for the given partitioning.
+        * Sets up the Java document partitioner for the given document for the default partitioning.
         * 
         * @param document the document to be set up
+        * @since 3.0
+        */
+       public void setupJavaDocumentPartitioner(IDocument document) {
+               setupJavaDocumentPartitioner(document, IDocumentExtension3.DEFAULT_PARTITIONING,null);
+       }
+       /**
+        * Sets up the Java document partitioner for the given document for the given partitioning.
+        * @param document the document to be set up
         * @param partitioning the document partitioning
+        * @param element TODO
+        * 
         * @since 3.0
         */
-       public void setupJavaDocumentPartitioner(IDocument document, String partitioning) {
-               IDocumentPartitioner partitioner= createDocumentPartitioner();
-               if (document instanceof IDocumentExtension3) {
-                       IDocumentExtension3 extension3= (IDocumentExtension3) document;
-                       extension3.setDocumentPartitioner(partitioning, partitioner);
-               } else {
+       public void setupJavaDocumentPartitioner(IDocument document, String partitioning, Object element) {
+               IDocumentPartitioner partitioner = createDocumentPartitioner(".php");
+                        
+//             if (document instanceof IDocumentExtension3) {
+//                     IDocumentExtension3 extension3= (IDocumentExtension3) document;
+//                     extension3.setDocumentPartitioner(partitioning, partitioner);
+//             } else {
+                       document.setDocumentPartitioner(partitioner);
+//             }
+               partitioner.connect(document);
+       }
+       public void setupHTMLDocumentPartitioner(IDocument document, String partitioning, Object element) {
+               IDocumentPartitioner partitioner = createDocumentPartitioner(".html");
+                        
+//             if (document instanceof IDocumentExtension3) {
+//                     IDocumentExtension3 extension3= (IDocumentExtension3) document;
+//                     extension3.setDocumentPartitioner(partitioning, partitioner);
+//             } else {
+                       document.setDocumentPartitioner(partitioner);
+//             }
+               partitioner.connect(document);
+       }
+       public void setupSmartyDocumentPartitioner(IDocument document, String partitioning, Object element) {
+               IDocumentPartitioner partitioner = createDocumentPartitioner(".tpl");
+                        
+//             if (document instanceof IDocumentExtension3) {
+//                     IDocumentExtension3 extension3= (IDocumentExtension3) document;
+//                     extension3.setDocumentPartitioner(partitioning, partitioner);
+//             } else {
                        document.setDocumentPartitioner(partitioner);
-               }
+//             }
                partitioner.connect(document);
        }
-       
   /**
    * Returns the names of the document position categories used by the document
    * partitioners created by this object to manage their partition information.