Prepared better HEREDOC support; see comment for bug #1319276
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / text / JavaTextTools.java
index 91283c2..e9edc5e 100644 (file)
@@ -54,15 +54,16 @@ public class JavaTextTools implements IPHPPartitions {
       PHP_MULTILINE_COMMENT,
       PHP_SINGLELINE_COMMENT,
       PHP_STRING_DQ,
-      PHP_STRING_SQ };
+      PHP_STRING_SQ,
+      PHP_STRING_HEREDOC};
 
-  private static XMLPartitionScanner HTML_PARTITION_SCANNER = null;
+//  private static XMLPartitionScanner HTML_PARTITION_SCANNER = null;
 
-  private static FastJavaPartitionScanner PHP_PARTITION_SCANNER = null;
+//  private static FastJavaPartitionScanner PHP_PARTITION_SCANNER = null;
 
   private static HTMLPartitionScanner SMARTY_PARTITION_SCANNER = null;
 
-  private static XMLPartitionScanner XML_PARTITION_SCANNER = null;
+//  private static XMLPartitionScanner XML_PARTITION_SCANNER = null;
 
   // private final static String[] TYPES= new String[] { PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC,
   // PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
@@ -102,8 +103,11 @@ public class JavaTextTools implements IPHPPartitions {
   /** The Java singleline comment scanner */
   private SingleTokenPHPScanner fSinglelineCommentScanner;
 
-  /** The Java string scanner */
-  private SingleTokenPHPScanner fStringScanner;
+  /** The PHP double quoted string scanner */
+//  private SingleTokenPHPScanner fStringDQScanner;
+
+  /** The PHP single quoted string scanner */
+//  private SingleTokenPHPScanner fStringSQScanner;
 
   /** The PHPDoc scanner */
   private PHPDocCodeScanner fPHPDocScanner;
@@ -127,7 +131,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * The core preference store.
-   * 
+   *
    * @since 2.1
    */
   private Preferences fCorePreferenceStore;
@@ -146,7 +150,7 @@ public class JavaTextTools implements IPHPPartitions {
   //  private RuleBasedScanner jspBracketScanner;
   /**
    * 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.
@@ -164,7 +168,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * 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.
@@ -197,7 +201,9 @@ public class JavaTextTools implements IPHPPartitions {
         IPreferenceConstants.PHP_MULTILINE_COMMENT);
     fSinglelineCommentScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store,
         IPreferenceConstants.PHP_SINGLELINE_COMMENT);
-    fStringScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+//    fStringDQScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+//    fStringSQScanner = new SingleTokenPHPScanner((JavaColorManager) colorManager, store, IPreferenceConstants.PHP_STRING);
+
     fPHPDocScanner = new PHPDocCodeScanner((JavaColorManager) colorManager, store);
     //    fHTMLScanner = new HTMLCodeScanner((JavaColorManager)fColorManager, store);
     fSmartyScanner = new SmartyCodeScanner((JavaColorManager) colorManager, store);
@@ -216,7 +222,7 @@ public class JavaTextTools implements IPHPPartitions {
   }
 
   /**
-   *  
+   *
    */
   public XMLTextTools getXMLTextTools() {
     return xmlTextTools;
@@ -230,7 +236,8 @@ public class JavaTextTools implements IPHPPartitions {
     fCodeScanner = null;
     fMultilineCommentScanner = null;
     fSinglelineCommentScanner = null;
-    fStringScanner = null;
+//    fStringDQScanner = null;
+//    fStringSQScanner = null;
     fPHPDocScanner = null;
     //    fPartitionScanner = null;
 
@@ -254,7 +261,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns the color manager which is used to manage any Java-specific colors needed for such things like syntax highlighting.
-   * 
+   *
    * @return the color manager to be used for Java text viewers
    */
   public JavaColorManager getColorManager() {
@@ -263,7 +270,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan Java source code.
-   * 
+   *
    * @return a Java source code scanner
    */
   public RuleBasedScanner getCodeScanner() {
@@ -272,9 +279,9 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan Java multiline comments.
-   * 
+   *
    * @return a Java multiline comment scanner
-   * 
+   *
    * @since 2.0
    */
   public RuleBasedScanner getMultilineCommentScanner() {
@@ -283,9 +290,9 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan HTML code.
-   * 
+   *
    * @return a HTML scanner
-   * 
+   *
    * @since 2.0
    */
   //  public RuleBasedScanner getHTMLScanner() {
@@ -293,9 +300,9 @@ public class JavaTextTools implements IPHPPartitions {
   //  }
   /**
    * Returns a scanner which is configured to scan Smarty code.
-   * 
+   *
    * @return a Smarty scanner
-   * 
+   *
    * @since 2.0
    */
   public RuleBasedScanner getSmartyScanner() {
@@ -304,9 +311,9 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan Smarty code.
-   * 
+   *
    * @return a Smarty scanner
-   * 
+   *
    * @since 2.0
    */
   public RuleBasedScanner getSmartyDocScanner() {
@@ -315,9 +322,9 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan Java singleline comments.
-   * 
+   *
    * @return a Java singleline comment scanner
-   * 
+   *
    * @since 2.0
    */
   public RuleBasedScanner getSinglelineCommentScanner() {
@@ -326,19 +333,19 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan Java strings.
-   * 
+   *
    * @return a Java string scanner
-   * 
+   *
    * @since 2.0
    */
-  public RuleBasedScanner getStringScanner() {
-    return fStringScanner;
-  }
+//  public RuleBasedScanner getStringScanner() {
+//    return fStringDQScanner;
+//  }
 
   /**
    * Returns a scanner which is configured to scan JavaDoc compliant comments. Notes that the start sequence "/**" and the
    * corresponding end sequence are part of the JavaDoc comment.
-   * 
+   *
    * @return a JavaDoc scanner
    */
   public RuleBasedScanner getJavaDocScanner() {
@@ -348,7 +355,7 @@ public class JavaTextTools implements IPHPPartitions {
   /**
    * Returns a scanner which is configured to scan Java-specific partitions, which are multi-line comments, JavaDoc comments, and
    * regular Java source code.
-   * 
+   *
    * @return a Java partition scanner
    */
   //  public IPartitionTokenScanner getPartitionScanner() {
@@ -357,7 +364,7 @@ public class JavaTextTools implements IPHPPartitions {
   /**
    * Factory method for creating a PHP-specific document partitioner using this object's partitions scanner. This method is a
    * convenience method.
-   * 
+   *
    * @return a newly created Java document partitioner
    */
   public IDocumentPartitioner createDocumentPartitioner() {
@@ -367,7 +374,7 @@ public class JavaTextTools implements IPHPPartitions {
   /**
    * Factory method for creating a PHP-specific document partitioner using this object's partitions scanner. This method is a
    * convenience method.
-   * 
+   *
    * @return a newly created Java document partitioner
    */
   public IDocumentPartitioner createDocumentPartitioner(String extension) {
@@ -412,14 +419,14 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * 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, Object element) {
@@ -460,7 +467,7 @@ public class JavaTextTools implements IPHPPartitions {
   /**
    * Returns the names of the document position categories used by the document partitioners created by this object to manage their
    * partition information. If the partitioners don't use document position categories, the returned result is <code>null</code>.
-   * 
+   *
    * @return the partition managing position categories or <code>null</code> if there is none
    */
   public String[] getPartitionManagingPositionCategories() {
@@ -469,7 +476,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Determines whether the preference change encoded by the given event changes the behavior of one its contained components.
-   * 
+   *
    * @param event
    *          the event to be investigated
    * @return <code>true</code> if event causes a behavioral change
@@ -481,12 +488,12 @@ public class JavaTextTools implements IPHPPartitions {
   //    return fCodeScanner.affectsBehavior(event)
   //        || fMultilineCommentScanner.affectsBehavior(event)
   //        || fSinglelineCommentScanner.affectsBehavior(event)
-  //        || fStringScanner.affectsBehavior(event)
+  //        || fStringDQScanner.affectsBehavior(event)
   //        || fPHPDocScanner.affectsBehavior(event);
   //  }
   /**
    * Adapts the behavior of the contained components to the change encoded in the given event.
-   * 
+   *
    * @param event
    *          the event to which to adapt
    * @since 2.0
@@ -498,8 +505,8 @@ public class JavaTextTools implements IPHPPartitions {
       fMultilineCommentScanner.adaptToPreferenceChange(event);
     if (fSinglelineCommentScanner.affectsBehavior(event))
       fSinglelineCommentScanner.adaptToPreferenceChange(event);
-    //    if (fStringScanner.affectsBehavior(event))
-    //      fStringScanner.adaptToPreferenceChange(event);
+    //    if (fStringDQScanner.affectsBehavior(event))
+    //      fStringDQScanner.adaptToPreferenceChange(event);
     if (fPHPDocScanner.affectsBehavior(event))
       fPHPDocScanner.adaptToPreferenceChange(event);
     //    if (fHTMLScanner.affectsBehavior(event))
@@ -540,12 +547,12 @@ public class JavaTextTools implements IPHPPartitions {
   }
 
   private IDocumentPartitioner createJSPPartitioner() {
-    return new PHPDocumentPartitioner(getJSPPartitionScanner(), getPHPPartitionScanner());
+    return new PHPDocumentPartitioner(getJSPPartitionScanner());
     //    return new JSPDocumentPartitioner(getJSPPartitionScanner(), jspScriptScanner);
   }
 
   /**
-   *  
+   *
    */
   //  public IPartitionTokenScanner getJSPScriptScanner() {
   //    return jspScriptScanner;
@@ -586,7 +593,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns a scanner which is configured to scan plain text in JSP.
-   * 
+   *
    * @return a JSP text scanner
    */
   //  public RuleBasedScanner getJSPTextScanner() {
@@ -594,7 +601,7 @@ public class JavaTextTools implements IPHPPartitions {
   //  }
   /**
    * Returns a scanner which is configured to scan plain text in JSP.
-   * 
+   *
    * @return a JSP text scanner
    */
   //  public RuleBasedScanner getJSPBracketScanner() {
@@ -612,14 +619,14 @@ public class JavaTextTools implements IPHPPartitions {
   /**
    * Return a scanner for creating xml partitions.
    */
-  private static XMLPartitionScanner getXMLPartitionScanner() {
-    //    if (XML_PARTITION_SCANNER == null)
-    //      XML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.XML_FILE);
-    //    return XML_PARTITION_SCANNER;
-    if (XML_PARTITION_SCANNER == null)
-      XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
-    return XML_PARTITION_SCANNER;
-  }
+//  private static XMLPartitionScanner getXMLPartitionScanner() {
+//    //    if (XML_PARTITION_SCANNER == null)
+//    //      XML_PARTITION_SCANNER = new HTMLPartitionScanner(IPHPPartitions.XML_FILE);
+//    //    return XML_PARTITION_SCANNER;
+//    if (XML_PARTITION_SCANNER == null)
+//      XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
+//    return XML_PARTITION_SCANNER;
+//  }
 
   private PHPPartitionScanner getJSPPartitionScanner() {
     if (jspPartitionScanner == null)
@@ -629,7 +636,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * 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
@@ -640,7 +647,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Sets up the Java document partitioner for the given document for the given partitioning.
-   * 
+   *
    * @param document
    *          the document to be set up
    * @param partitioning
@@ -660,7 +667,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns this text tool's preference store.
-   * 
+   *
    * @return the preference store
    * @since 3.0
    */
@@ -670,7 +677,7 @@ public class JavaTextTools implements IPHPPartitions {
 
   /**
    * Returns this text tool's core preference store.
-   * 
+   *
    * @return the core preference store
    * @since 3.0
    */