Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / ui / text / JavaTextTools.java
1 package net.sourceforge.phpdt.ui.text;
2
3 /*
4  * (c) Copyright IBM Corp. 2000, 2001.
5  * All Rights Reserved.
6  */
7
8 import net.sourceforge.phpdt.internal.ui.text.FastJavaPartitionScanner;
9 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
10 import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
11 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
12 import net.sourceforge.phpeclipse.IPreferenceConstants;
13 import net.sourceforge.phpeclipse.phpeditor.php.HTMLPartitionScanner;
14 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
15 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
16 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
17 import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
18 import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
19 import net.sourceforge.phpeclipse.ui.WebUI;
20 //import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
21 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
22
23 import org.eclipse.core.runtime.Preferences;
24 import org.eclipse.jface.preference.IPreferenceStore;
25 import org.eclipse.jface.text.IDocument;
26 import org.eclipse.jface.text.IDocumentExtension3;
27 import org.eclipse.jface.text.IDocumentPartitioner;
28 import org.eclipse.jface.text.rules.DefaultPartitioner;
29 import org.eclipse.jface.text.rules.FastPartitioner;
30 import org.eclipse.jface.text.rules.RuleBasedScanner;
31 import org.eclipse.jface.util.IPropertyChangeListener;
32 import org.eclipse.jface.util.PropertyChangeEvent;
33
34 //
35 // import org.phpeclipse.phpdt.internal.ui.text.FastJavaPartitionScanner;
36 // import org.phpeclipse.phpdt.internal.ui.text.JavaColorManager;
37 // import org.phpeclipse.phpdt.internal.ui.text.JavaPartitionScanner;
38 // import org.phpeclipse.phpdt.internal.ui.text.SingleTokenJavaScanner;
39 // import org.phpeclipse.phpdt.internal.ui.text.php.JavaCodeScanner;
40 // import org.phpeclipse.phpdt.internal.ui.text.phpdoc.JavaDocScanner;
41
42 /**
43  * Tools required to configure a Java text viewer. The color manager and all
44  * scanner exist only one time, i.e. the same instances are returned to all
45  * clients. Thus, clients share those tools.
46  * <p>
47  * This class may be instantiated; it is not intended to be subclassed.
48  * </p>
49  */
50 public class JavaTextTools implements IPHPPartitions {
51         // private static final String[] TOKENS = {
52         // JSPScriptScanner.JSP_DEFAULT,
53         // JSPScriptScanner.JSP_BRACKET };
54         private final static String[] LEGAL_CONTENT_TYPES = new String[] {
55                         PHP_PHPDOC_COMMENT, PHP_MULTILINE_COMMENT, PHP_SINGLELINE_COMMENT,
56                         PHP_STRING_DQ, PHP_STRING_SQ, PHP_STRING_HEREDOC };
57
58         // private static XMLPartitionScanner HTML_PARTITION_SCANNER = null;
59
60         // private static FastJavaPartitionScanner PHP_PARTITION_SCANNER = null;
61
62         private static HTMLPartitionScanner SMARTY_PARTITION_SCANNER = null;
63
64         // private static XMLPartitionScanner XML_PARTITION_SCANNER = null;
65
66         // private final static String[] TYPES= new String[] {
67         // PHPPartitionScanner.PHP, PHPPartitionScanner.JAVA_DOC,
68         // PHPPartitionScanner.JAVA_MULTILINE_COMMENT };
69         // private final static String[] TYPES = new String[] {
70         // IPHPPartitions.PHP_PARTITIONING,
71         // IPHPPartitions.PHP_PHPDOC_COMMENT,
72         // // IPHPPartitions.HTML,
73         // // IPHPPartitions.HTML_MULTILINE_COMMENT,
74         // IPHPPartitions.JAVASCRIPT,
75         // IPHPPartitions.CSS,
76         // IPHPPartitions.SMARTY,
77         // IPHPPartitions.SMARTY_MULTILINE_COMMENT };
78
79         /**
80          * This tools' preference listener.
81          */
82         private class PreferenceListener implements IPropertyChangeListener,
83                         Preferences.IPropertyChangeListener {
84                 public void propertyChange(PropertyChangeEvent event) {
85                         adaptToPreferenceChange(event);
86                 }
87
88                 public void propertyChange(Preferences.PropertyChangeEvent event) {
89                         adaptToPreferenceChange(new PropertyChangeEvent(event.getSource(),
90                                         event.getProperty(), event.getOldValue(), event
91                                                         .getNewValue()));
92                 }
93         };
94
95         // /** The color manager */
96         private JavaColorManager colorManager;
97
98         /** The PHP source code scanner */
99         private PHPCodeScanner fCodeScanner;
100
101         /** The PHP multiline comment scanner */
102         private SingleTokenPHPScanner fMultilineCommentScanner;
103
104         /** The Java singleline comment scanner */
105         private SingleTokenPHPScanner fSinglelineCommentScanner;
106
107         /** The PHP double quoted string scanner */
108         // private SingleTokenPHPScanner fStringDQScanner;
109         /** The PHP single quoted string scanner */
110         // private SingleTokenPHPScanner fStringSQScanner;
111         /** The PHPDoc scanner */
112         private PHPDocCodeScanner fPHPDocScanner;
113
114         /** The HTML scanner */
115         // private HTMLCodeScanner fHTMLScanner;
116         /** The Smarty scanner */
117         private SmartyCodeScanner fSmartyScanner;
118
119         /** The SmartyDoc scanner */
120         private SmartyDocCodeScanner fSmartyDocScanner;
121
122         /** The Java partitions scanner. */
123         private FastJavaPartitionScanner fPartitionScanner;
124
125         /** The preference store */
126         private IPreferenceStore fPreferenceStore;
127
128         /** The XML Language text tools */
129         private XMLTextTools xmlTextTools;
130
131         /**
132          * The core preference store.
133          * 
134          * @since 2.1
135          */
136         private Preferences fCorePreferenceStore;
137
138         /** The preference change listener */
139         private PreferenceListener fPreferenceListener = new PreferenceListener();
140
141         /** The JSP partitions scanner */
142         private PHPPartitionScanner jspPartitionScanner = null;
143
144         /** The JSP script subpartitions scanner */
145         // private JSPScriptScanner jspScriptScanner;
146         /** The PHP plain text scanner */
147         // private RuleBasedScanner jspTextScanner;
148         /** The PHP brackets scanner */
149         // private RuleBasedScanner jspBracketScanner;
150         /**
151          * Creates a new Java text tools collection.
152          * 
153          * @param store
154          *            the preference store to initialize the text tools. The text
155          *            tool instance installs a listener on the passed preference
156          *            store to adapt itself to changes in the preference store. In
157          *            general <code>PreferenceConstants.
158          *                      getPreferenceStore()</code>
159          *            should be used to initialize the text tools.
160          * @param coreStore
161          *            optional preference store to initialize the text tools. The
162          *            text tool instance installs a listener on the passed
163          *            preference store to adapt itself to changes in the preference
164          *            store.
165          * @see net.sourceforge.phpdt.ui.PreferenceConstants#getPreferenceStore()
166          * @since 2.1
167          */
168         public JavaTextTools(IPreferenceStore store, Preferences coreStore) {
169                 this(store, coreStore, true);
170         }
171
172         /**
173          * Creates a new Java text tools collection.
174          * 
175          * @param store
176          *            the preference store to initialize the text tools. The text
177          *            tool instance installs a listener on the passed preference
178          *            store to adapt itself to changes in the preference store. In
179          *            general <code>PreferenceConstants.
180          *                      getPreferenceStore()</code>
181          *            shoould be used to initialize the text tools.
182          * @param coreStore
183          *            optional preference store to initialize the text tools. The
184          *            text tool instance installs a listener on the passed
185          *            preference store to adapt itself to changes in the preference
186          *            store.
187          * @param autoDisposeOnDisplayDispose
188          *            if <code>true</code> the color manager automatically
189          *            disposes all managed colors when the current display gets
190          *            disposed and all calls to
191          *            {@link org.eclipse.jface.text.source.ISharedTextColors#dispose()}are
192          *            ignored.
193          * @see net.sourceforge.phpdt.ui.PreferenceConstants#getPreferenceStore()
194          * @since 2.1
195          */
196         public JavaTextTools(IPreferenceStore store, Preferences coreStore,
197                         boolean autoDisposeOnDisplayDispose) {
198                 // super(store, TOKENS, );
199                 // REVISIT: preference store
200                 xmlTextTools = new XMLTextTools(/*XMLPlugin*/WebUI.getDefault()
201                                 .getPreferenceStore());
202
203                 colorManager = new JavaColorManager(autoDisposeOnDisplayDispose);
204                 fPreferenceStore = store;
205                 fPreferenceStore.addPropertyChangeListener(fPreferenceListener);
206
207                 fCorePreferenceStore = coreStore;
208                 if (fCorePreferenceStore != null)
209                         fCorePreferenceStore.addPropertyChangeListener(fPreferenceListener);
210
211                 fCodeScanner = new PHPCodeScanner((JavaColorManager) colorManager,
212                                 store);
213                 fMultilineCommentScanner = new SingleTokenPHPScanner(
214                                 (JavaColorManager) colorManager, store,
215                                 IPreferenceConstants.PHP_MULTILINE_COMMENT);
216                 fSinglelineCommentScanner = new SingleTokenPHPScanner(
217                                 (JavaColorManager) colorManager, store,
218                                 IPreferenceConstants.PHP_SINGLELINE_COMMENT);
219                 // fStringDQScanner = new SingleTokenPHPScanner((JavaColorManager)
220                 // colorManager, store, IPreferenceConstants.PHP_STRING);
221                 // fStringSQScanner = new SingleTokenPHPScanner((JavaColorManager)
222                 // colorManager, store, IPreferenceConstants.PHP_STRING);
223
224                 fPHPDocScanner = new PHPDocCodeScanner((JavaColorManager) colorManager,
225                                 store);
226                 // fHTMLScanner = new HTMLCodeScanner((JavaColorManager)fColorManager,
227                 // store);
228                 fSmartyScanner = new SmartyCodeScanner((JavaColorManager) colorManager,
229                                 store);
230                 fSmartyDocScanner = new SmartyDocCodeScanner(
231                                 (JavaColorManager) colorManager, store);
232
233                 fPartitionScanner = new FastJavaPartitionScanner();
234
235                 // jspScriptScanner = new JSPScriptScanner();
236                 // fPartitionScanner = new FastJavaPartitionScanner();
237                 // fPartitionScanner = new PHPPartitionScanner();
238
239                 // jspBracketScanner = new RuleBasedScanner();
240                 // jspBracketScanner.setDefaultReturnToken(new
241                 // Token(JSPScriptScanner.JSP_BRACKET));
242                 // jspTextScanner = new RuleBasedScanner();
243                 // jspTextScanner.setDefaultReturnToken(new
244                 // Token(JSPScriptScanner.JSP_DEFAULT));
245         }
246
247         /**
248          * 
249          */
250         public XMLTextTools getXMLTextTools() {
251                 return xmlTextTools;
252         }
253
254         /**
255          * Disposes all the individual tools of this tools collection.
256          */
257         public void dispose() {
258
259                 fCodeScanner = null;
260                 fMultilineCommentScanner = null;
261                 fSinglelineCommentScanner = null;
262                 // fStringDQScanner = null;
263                 // fStringSQScanner = null;
264                 fPHPDocScanner = null;
265                 // fPartitionScanner = null;
266
267                 if (colorManager != null) {
268                         colorManager.dispose();
269                         colorManager = null;
270                 }
271
272                 if (fPreferenceStore != null) {
273                         fPreferenceStore.removePropertyChangeListener(fPreferenceListener);
274                         fPreferenceStore = null;
275
276                         if (fCorePreferenceStore != null) {
277                                 fCorePreferenceStore
278                                                 .removePropertyChangeListener(fPreferenceListener);
279                                 fCorePreferenceStore = null;
280                         }
281
282                         fPreferenceListener = null;
283                 }
284         }
285
286         /**
287          * Returns the color manager which is used to manage any Java-specific
288          * colors needed for such things like syntax highlighting.
289          * 
290          * @return the color manager to be used for Java text viewers
291          */
292         public JavaColorManager getColorManager() {
293                 return (JavaColorManager) colorManager;
294         }
295
296         /**
297          * Returns a scanner which is configured to scan Java source code.
298          * 
299          * @return a Java source code scanner
300          */
301         public RuleBasedScanner getCodeScanner() {
302                 return fCodeScanner;
303         }
304
305         /**
306          * Returns a scanner which is configured to scan Java multiline comments.
307          * 
308          * @return a Java multiline comment scanner
309          * 
310          * @since 2.0
311          */
312         public RuleBasedScanner getMultilineCommentScanner() {
313                 return fMultilineCommentScanner;
314         }
315
316         /**
317          * Returns a scanner which is configured to scan HTML code.
318          * 
319          * @return a HTML scanner
320          * 
321          * @since 2.0
322          */
323         // public RuleBasedScanner getHTMLScanner() {
324         // return fHTMLScanner;
325         // }
326         /**
327          * Returns a scanner which is configured to scan Smarty code.
328          * 
329          * @return a Smarty scanner
330          * 
331          * @since 2.0
332          */
333         public RuleBasedScanner getSmartyScanner() {
334                 return fSmartyScanner;
335         }
336
337         /**
338          * Returns a scanner which is configured to scan Smarty code.
339          * 
340          * @return a Smarty scanner
341          * 
342          * @since 2.0
343          */
344         public RuleBasedScanner getSmartyDocScanner() {
345                 return fSmartyDocScanner;
346         }
347
348         /**
349          * Returns a scanner which is configured to scan Java singleline comments.
350          * 
351          * @return a Java singleline comment scanner
352          * 
353          * @since 2.0
354          */
355         public RuleBasedScanner getSinglelineCommentScanner() {
356                 return fSinglelineCommentScanner;
357         }
358
359         /**
360          * Returns a scanner which is configured to scan Java strings.
361          * 
362          * @return a Java string scanner
363          * 
364          * @since 2.0
365          */
366         // public RuleBasedScanner getStringScanner() {
367         // return fStringDQScanner;
368         // }
369         /**
370          * Returns a scanner which is configured to scan JavaDoc compliant comments.
371          * Notes that the start sequence "/**" and the corresponding end sequence
372          * are part of the JavaDoc comment.
373          * 
374          * @return a JavaDoc scanner
375          */
376         public RuleBasedScanner getJavaDocScanner() {
377                 return fPHPDocScanner;
378         }
379
380         /**
381          * Returns a scanner which is configured to scan Java-specific partitions,
382          * which are multi-line comments, JavaDoc comments, and regular Java source
383          * code.
384          * 
385          * @return a Java partition scanner
386          */
387         // public IPartitionTokenScanner getPartitionScanner() {
388         // return fPartitionScanner;
389         // }
390         /**
391          * Factory method for creating a PHP-specific document partitioner using
392          * this object's partitions scanner. This method is a convenience method.
393          * 
394          * @return a newly created Java document partitioner
395          */
396         public IDocumentPartitioner createDocumentPartitioner() {
397                 return createDocumentPartitioner(".php");
398         }
399
400         /**
401          * Factory method for creating a PHP-specific document partitioner using
402          * this object's partitions scanner. This method is a convenience method.
403          * 
404          * @return a newly created Java document partitioner
405          */
406         public IDocumentPartitioner createDocumentPartitioner(String extension) {
407
408                 // String[] types =
409                 // new String[] {
410                 // FastJavaPartitionScanner.JAVA_DOC,
411                 // FastJavaPartitionScanner.JAVA_MULTI_LINE_COMMENT,
412                 // FastJavaPartitionScanner.JAVA_SINGLE_LINE_COMMENT,
413                 // FastJavaPartitionScanner.JAVA_STRING };
414                 //
415                 // return new DefaultPartitioner(getPartitionScanner(), types);
416                 IDocumentPartitioner partitioner = null;
417                 // System.out.println(extension);
418                 if (extension.equalsIgnoreCase(".html")
419                                 || extension.equalsIgnoreCase(".htm")) {
420                         // html
421                         partitioner = createHTMLPartitioner();
422                         partitioner = createJSPPartitioner();
423                 } else if (extension.equalsIgnoreCase(".xml")) {
424                         // xml
425                         partitioner = createXMLPartitioner();
426                         // } else if (extension.equalsIgnoreCase(".js")) {
427                         // // javascript
428                         // partitioner = createJavaScriptPartitioner();
429                         // } else if (extension.equalsIgnoreCase(".css")) {
430                         // // cascading style sheets
431                         // partitioner = createCSSPartitioner();
432                 } else if (extension.equalsIgnoreCase(".tpl")) {
433                         // smarty ?
434                         partitioner = createSmartyPartitioner();
435                         // } else if (extension.equalsIgnoreCase(".inc")) {
436                         // // php include files ?
437                         // partitioner = createIncludePartitioner();
438                 }
439
440                 if (partitioner == null) {
441                         partitioner = createJSPPartitioner();
442                 }
443
444                 return partitioner;
445         }
446
447         /**
448          * Sets up the Java document partitioner for the given document for the
449          * given partitioning.
450          * 
451          * @param document
452          *            the document to be set up
453          * @param partitioning
454          *            the document partitioning
455          * @param element
456          *            TODO
457          * 
458          * @since 3.0
459          */
460         // public void setupJavaDocumentPartitioner(IDocument document, String
461         // partitioning, Object element) {
462         // IDocumentPartitioner partitioner = createDocumentPartitioner(".php");
463         //
464         // // if (document instanceof IDocumentExtension3) {
465         // // IDocumentExtension3 extension3= (IDocumentExtension3) document;
466         // // extension3.setDocumentPartitioner(partitioning, partitioner);
467         // // } else {
468         // document.setDocumentPartitioner(partitioner);
469         // // }
470         // partitioner.connect(document);
471         // }
472         public void setupHTMLDocumentPartitioner(IDocument document,
473                         String partitioning, Object element) {
474                 IDocumentPartitioner partitioner = createDocumentPartitioner(".html");
475
476                 // if (document instanceof IDocumentExtension3) {
477                 // IDocumentExtension3 extension3= (IDocumentExtension3) document;
478                 // extension3.setDocumentPartitioner(partitioning, partitioner);
479                 // } else {
480                 document.setDocumentPartitioner(partitioner);
481                 // }
482                 partitioner.connect(document);
483         }
484
485         public void setupSmartyDocumentPartitioner(IDocument document,
486                         String partitioning, Object element) {
487                 IDocumentPartitioner partitioner = createDocumentPartitioner(".tpl");
488
489                 // if (document instanceof IDocumentExtension3) {
490                 // IDocumentExtension3 extension3= (IDocumentExtension3) document;
491                 // extension3.setDocumentPartitioner(partitioning, partitioner);
492                 // } else {
493                 document.setDocumentPartitioner(partitioner);
494                 // }
495                 partitioner.connect(document);
496         }
497
498         /**
499          * Returns the names of the document position categories used by the
500          * document partitioners created by this object to manage their partition
501          * information. If the partitioners don't use document position categories,
502          * the returned result is <code>null</code>.
503          * 
504          * @return the partition managing position categories or <code>null</code>
505          *         if there is none
506          */
507         public String[] getPartitionManagingPositionCategories() {
508                 return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
509         }
510
511         /**
512          * Determines whether the preference change encoded by the given event
513          * changes the behavior of one its contained components.
514          * 
515          * @param event
516          *            the event to be investigated
517          * @return <code>true</code> if event causes a behavioral change
518          * @since 2.0
519          * @deprecated As of 3.0, replaced by
520          *             {@link net.sourceforge.phpdt.ui.text.JavaSourceViewerConfiguration#affectsTextPresentation(PropertyChangeEvent)}
521          */
522         // public boolean affectsBehavior(PropertyChangeEvent event) {
523         // return fCodeScanner.affectsBehavior(event)
524         // || fMultilineCommentScanner.affectsBehavior(event)
525         // || fSinglelineCommentScanner.affectsBehavior(event)
526         // || fStringDQScanner.affectsBehavior(event)
527         // || fPHPDocScanner.affectsBehavior(event);
528         // }
529         /**
530          * Adapts the behavior of the contained components to the change encoded in
531          * the given event.
532          * 
533          * @param event
534          *            the event to which to adapt
535          * @since 2.0
536          */
537         protected void adaptToPreferenceChange(PropertyChangeEvent event) {
538                 if (fCodeScanner.affectsBehavior(event))
539                         fCodeScanner.adaptToPreferenceChange(event);
540                 if (fMultilineCommentScanner.affectsBehavior(event))
541                         fMultilineCommentScanner.adaptToPreferenceChange(event);
542                 if (fSinglelineCommentScanner.affectsBehavior(event))
543                         fSinglelineCommentScanner.adaptToPreferenceChange(event);
544                 // if (fStringDQScanner.affectsBehavior(event))
545                 // fStringDQScanner.adaptToPreferenceChange(event);
546                 if (fPHPDocScanner.affectsBehavior(event))
547                         fPHPDocScanner.adaptToPreferenceChange(event);
548                 // if (fHTMLScanner.affectsBehavior(event))
549                 // fHTMLScanner.adaptToPreferenceChange(event);
550                 if (fSmartyScanner.affectsBehavior(event))
551                         fSmartyScanner.adaptToPreferenceChange(event);
552                 if (fSmartyDocScanner.affectsBehavior(event))
553                         fSmartyDocScanner.adaptToPreferenceChange(event);
554                 // if (XMLPlugin.getDefault().getXMLTextTools().affectsBehavior(event))
555                 // {
556                 // XMLPlugin.getDefault().getXMLTextTools().adaptToPreferenceChange(event);
557                 // }
558         }
559
560         /**
561          * Return a partitioner for .html files.
562          */
563         public IDocumentPartitioner createHTMLPartitioner() {
564                 // return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
565                 return xmlTextTools.createXMLPartitioner();
566         }
567
568         // private static IDocumentPartitioner createIncludePartitioner() {
569         // // return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
570         // return new DefaultPartitioner(getPHPPartitionScanner(),
571         // FastJavaPartitionScanner.PHP_PARTITION_TYPES);
572         //
573         // }
574
575         // private static IDocumentPartitioner createJavaScriptPartitioner() {
576         // return new DefaultPartitioner(getHTMLPartitionScanner(), TYPES);
577         // }
578
579         /**
580          * Return a partitioner for .php files.
581          */
582         public IDocumentPartitioner createPHPPartitioner() {
583                 // return new DefaultPartitioner(getPHPPartitionScanner(), TYPES);
584                 return new /*DefaultPartitioner*/FastPartitioner(getPHPPartitionScanner(),
585                                 LEGAL_CONTENT_TYPES);
586         }
587
588         private IDocumentPartitioner createJSPPartitioner() {
589                 return new PHPDocumentPartitioner(getJSPPartitionScanner());
590                 // return new JSPDocumentPartitioner(getJSPPartitionScanner(),
591                 // jspScriptScanner);
592         }
593
594         /**
595          * 
596          */
597         // public IPartitionTokenScanner getJSPScriptScanner() {
598         // return jspScriptScanner;
599         // }
600         private IDocumentPartitioner createSmartyPartitioner() {
601                 return new /*DefaultPartitioner*/FastPartitioner(getSmartyPartitionScanner(),
602                                 XMLTextTools.TYPES);
603         }
604
605         private IDocumentPartitioner createXMLPartitioner() {
606                 // return new DefaultPartitioner(getXMLPartitionScanner(),
607                 // XMLTextTools.TYPES);
608                 return xmlTextTools.createXMLPartitioner();
609         }
610
611         // private IDocumentPartitioner createCSSPartitioner() {
612         // return new DefaultPartitioner(getHTMLPartitionScanner(),
613         // XMLTextTools.TYPES);
614         // }
615
616         /**
617          * Return a scanner for creating html partitions.
618          */
619         // private static XMLPartitionScanner getHTMLPartitionScanner() {
620         // // if (HTML_PARTITION_SCANNER == null)
621         // // HTML_PARTITION_SCANNER = new
622         // HTMLPartitionScanner(IPHPPartitions.HTML_FILE);
623         // // return HTML_PARTITION_SCANNER;^
624         // if (HTML_PARTITION_SCANNER == null)
625         // HTML_PARTITION_SCANNER = new XMLPartitionScanner(false);
626         // return HTML_PARTITION_SCANNER;
627         // }
628         /**
629          * Return a scanner for creating php partitions.
630          */
631         private FastJavaPartitionScanner getPHPPartitionScanner() {
632                 // if (PHP_PARTITION_SCANNER == null)
633                 // PHP_PARTITION_SCANNER = new FastJavaPartitionScanner(); //new
634                 // PHPPartitionScanner(IPHPPartitions.PHP_FILE);
635                 // return PHP_PARTITION_SCANNER;
636                 return fPartitionScanner;
637         }
638
639         /**
640          * Returns a scanner which is configured to scan plain text in JSP.
641          * 
642          * @return a JSP text scanner
643          */
644         // public RuleBasedScanner getJSPTextScanner() {
645         // return jspTextScanner;
646         // }
647         /**
648          * Returns a scanner which is configured to scan plain text in JSP.
649          * 
650          * @return a JSP text scanner
651          */
652         // public RuleBasedScanner getJSPBracketScanner() {
653         // return jspBracketScanner;
654         // }
655         /**
656          * Return a scanner for creating smarty partitions.
657          */
658         private static HTMLPartitionScanner getSmartyPartitionScanner() {
659                 if (SMARTY_PARTITION_SCANNER == null)
660                         SMARTY_PARTITION_SCANNER = new HTMLPartitionScanner(
661                                         IPHPPartitions.SMARTY_FILE);
662                 return SMARTY_PARTITION_SCANNER;
663         }
664
665         /**
666          * Return a scanner for creating xml partitions.
667          */
668         // private static XMLPartitionScanner getXMLPartitionScanner() {
669         // // if (XML_PARTITION_SCANNER == null)
670         // // XML_PARTITION_SCANNER = new
671         // HTMLPartitionScanner(IPHPPartitions.XML_FILE);
672         // // return XML_PARTITION_SCANNER;
673         // if (XML_PARTITION_SCANNER == null)
674         // XML_PARTITION_SCANNER = new XMLPartitionScanner(false);
675         // return XML_PARTITION_SCANNER;
676         // }
677         private PHPPartitionScanner getJSPPartitionScanner() {
678                 if (jspPartitionScanner == null)
679                         jspPartitionScanner = new PHPPartitionScanner();
680                 return jspPartitionScanner;
681         }
682
683         /**
684          * Sets up the Java document partitioner for the given document for the
685          * default partitioning.
686          * 
687          * @param document
688          *            the document to be set up
689          * @since 3.0
690          */
691         public void setupJavaDocumentPartitioner(IDocument document) {
692                 setupJavaDocumentPartitioner(document,
693                                 IDocumentExtension3.DEFAULT_PARTITIONING);
694         }
695
696         /**
697          * Sets up the Java document partitioner for the given document for the
698          * given partitioning.
699          * 
700          * @param document
701          *            the document to be set up
702          * @param partitioning
703          *            the document partitioning
704          * @since 3.0
705          */
706         public void setupJavaDocumentPartitioner(IDocument document,
707                         String partitioning) {
708                 IDocumentPartitioner partitioner = createDocumentPartitioner();
709                 if (document instanceof IDocumentExtension3) {
710                         IDocumentExtension3 extension3 = (IDocumentExtension3) document;
711                         extension3.setDocumentPartitioner(partitioning, partitioner);
712                 } else {
713                         document.setDocumentPartitioner(partitioner);
714                 }
715                 partitioner.connect(document);
716         }
717
718         /**
719          * Returns this text tool's preference store.
720          * 
721          * @return the preference store
722          * @since 3.0
723          */
724         protected IPreferenceStore getPreferenceStore() {
725                 return fPreferenceStore;
726         }
727
728         /**
729          * Returns this text tool's core preference store.
730          * 
731          * @return the core preference store
732          * @since 3.0
733          */
734         protected Preferences getCorePreferenceStore() {
735                 return fCorePreferenceStore;
736         }
737 }