X-Git-Url: http://git.phpeclipse.com

diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java
index ec11f3c..0d592a8 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/ui/text/JavaTextTools.java
@@ -5,17 +5,17 @@ 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;
 import net.sourceforge.phpeclipse.IPreferenceConstants;
 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCodeScanner;
-import net.sourceforge.phpeclipse.phpeditor.php.IPHPPartitionScannerConstants;
 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
 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;
@@ -46,21 +47,20 @@ import org.eclipse.jface.util.PropertyChangeEvent;
 public class JavaTextTools {
 
   private static PHPPartitionScanner HTML_PARTITION_SCANNER = null;
-
   private static PHPPartitionScanner PHP_PARTITION_SCANNER = null;
   private static PHPPartitionScanner SMARTY_PARTITION_SCANNER = null;
 
   // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC, PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
   private final static String[] TYPES =
     new String[] {
-      IPHPPartitionScannerConstants.PHP,
-      IPHPPartitionScannerConstants.PHP_MULTILINE_COMMENT,
-      IPHPPartitionScannerConstants.HTML,
-      IPHPPartitionScannerConstants.HTML_MULTILINE_COMMENT,
-      IPHPPartitionScannerConstants.JAVASCRIPT,
-      IPHPPartitionScannerConstants.CSS,
-      IPHPPartitionScannerConstants.SMARTY,
-      IPHPPartitionScannerConstants.SMARTY_MULTILINE_COMMENT };
+      IPHPPartitions.PHP_PARTITIONING,
+      IPHPPartitions.PHP_PHPDOC_COMMENT,
+      IPHPPartitions.HTML,
+      IPHPPartitions.HTML_MULTILINE_COMMENT,
+      IPHPPartitions.JAVASCRIPT,
+      IPHPPartitions.CSS,
+      IPHPPartitions.SMARTY,
+      IPHPPartitions.SMARTY_MULTILINE_COMMENT };
   private static PHPPartitionScanner XML_PARTITION_SCANNER = null;
 
   /**
@@ -95,7 +95,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;
@@ -118,22 +118,37 @@ public class JavaTextTools {
    * @see org.phpeclipse.phpdt.ui.PreferenceConstants#getPreferenceStore()
    * @since 2.0
    */
-  public JavaTextTools(IPreferenceStore store) {
-    fPreferenceStore = store;
-    fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
-
-    fColorManager = new JavaColorManager();
-    fCodeScanner = new PHPCodeScanner(fColorManager, store);
-    fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
-    fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
-    fStringScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_STRING);
-    fPHPDocScanner = new PHPDocCodeScanner(fColorManager, store);
-    fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
-    fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
-    fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
-    fPartitionScanner = new FastJavaPartitionScanner();
-  }
-
+//  public JavaTextTools(IPreferenceStore store) {
+//    fPreferenceStore = store;
+//    fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
+//
+//    fColorManager = new JavaColorManager();
+//    fCodeScanner = new PHPCodeScanner(fColorManager, store);
+//    fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
+//    fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
+//    fStringScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_STRING);
+//    fPHPDocScanner = new PHPDocCodeScanner(fColorManager, store);
+//    fHTMLScanner = new HTMLCodeScanner(fColorManager, store);
+//    fSmartyScanner = new SmartyCodeScanner(fColorManager, store);
+//    fSmartyDocScanner = new SmartyDocCodeScanner(fColorManager, store);
+////    fPartitionScanner = new FastJavaPartitionScanner();
+//    fPartitionScanner = new PHPPartitionScanner();
+//  }
+  /**
+	 * Creates a new Java text tools collection.
+	 * @param store the preference store to initialize the text tools. The text tool
+	 *			instance installs a listener on the passed preference store to adapt itself to 
+	 *			changes in the preference store. In general <code>PreferenceConstants.
+	 *			getPreferenceStore()</code> should be used to initialize the text tools.
+	 * @param coreStore optional preference store to initialize the text tools. The text tool
+	 *			instance installs a listener on the passed preference store to adapt itself to 
+	 *			changes in the preference store.
+	 * @see org.eclipse.jdt.ui.PreferenceConstants#getPreferenceStore()
+	 * @since 2.1
+	 */
+	public JavaTextTools(IPreferenceStore store, Preferences coreStore) {
+		this(store, coreStore, true);
+	}
   /**
    * Creates a new Java text tools collection.
    * 
@@ -159,6 +174,7 @@ public class JavaTextTools {
       fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener);
 
     fColorManager = new JavaColorManager(autoDisposeOnDisplayDispose);
+    
     fCodeScanner = new PHPCodeScanner(fColorManager, store);
     fMultilineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_MULTILINE_COMMENT);
     fSinglelineCommentScanner = new SingleTokenPHPScanner(fColorManager, store, IPreferenceConstants.PHP_SINGLELINE_COMMENT);
@@ -167,7 +183,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 +379,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.
@@ -429,6 +477,12 @@ public class JavaTextTools {
       fStringScanner.adaptToPreferenceChange(event);
     if (fPHPDocScanner.affectsBehavior(event))
       fPHPDocScanner.adaptToPreferenceChange(event);
+    if (fHTMLScanner.affectsBehavior(event))
+      fHTMLScanner.adaptToPreferenceChange(event);
+    if (fSmartyScanner.affectsBehavior(event))
+      fSmartyScanner.adaptToPreferenceChange(event);
+    if (fSmartyDocScanner.affectsBehavior(event))
+      fSmartyDocScanner.adaptToPreferenceChange(event);
   }
 
   /**
@@ -469,7 +523,7 @@ public class JavaTextTools {
   	*/
   private static PHPPartitionScanner getHTMLPartitionScanner() {
     if (HTML_PARTITION_SCANNER == null)
-      HTML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.HTML_FILE);
+      HTML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.HTML_FILE);
     return HTML_PARTITION_SCANNER;
   }
   /**
@@ -477,7 +531,7 @@ public class JavaTextTools {
   	*/
   private static PHPPartitionScanner getPHPPartitionScanner() {
     if (PHP_PARTITION_SCANNER == null)
-      PHP_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.PHP_FILE);
+      PHP_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.PHP_FILE);
     return PHP_PARTITION_SCANNER;
   }
 
@@ -486,7 +540,7 @@ public class JavaTextTools {
   	*/
   private static PHPPartitionScanner getSmartyPartitionScanner() {
     if (SMARTY_PARTITION_SCANNER == null)
-      SMARTY_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.SMARTY_FILE);
+      SMARTY_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.SMARTY_FILE);
     return SMARTY_PARTITION_SCANNER;
   }
 
@@ -495,7 +549,7 @@ public class JavaTextTools {
   	*/
   private static PHPPartitionScanner getXMLPartitionScanner() {
     if (XML_PARTITION_SCANNER == null)
-      XML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitionScannerConstants.XML_FILE);
+      XML_PARTITION_SCANNER = new PHPPartitionScanner(IPHPPartitions.XML_FILE);
     return XML_PARTITION_SCANNER;
   }