Syntax highlighting is changeable.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / ui / text / PHPSourceViewerConfiguration.java
1 /**********************************************************************
2  Copyright (c) 2000, 2002 IBM Corp. and others.
3  All rights reserved. This program and the accompanying materials
4  are made available under the terms of the Common Public License v1.0
5  which accompanies this distribution, and is available at
6  http://www.eclipse.org/legal/cpl-v10.html
7
8  Contributors:
9  IBM Corporation - Initial implementation
10  Klaus Hartlage - www.eclipseproject.de
11  **********************************************************************/
12 package net.sourceforge.phpdt.ui.text;
13
14 import java.util.Vector;
15
16 import net.sourceforge.phpdt.core.JavaCore;
17 import net.sourceforge.phpdt.internal.ui.text.AbstractJavaScanner;
18 import net.sourceforge.phpdt.internal.ui.text.ContentAssistPreference;
19 import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
20 import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
21 import net.sourceforge.phpdt.internal.ui.text.JavaAnnotationHover;
22 import net.sourceforge.phpdt.internal.ui.text.JavaColorManager;
23 import net.sourceforge.phpdt.internal.ui.text.JavaCompositeReconcilingStrategy;
24 import net.sourceforge.phpdt.internal.ui.text.JavaElementProvider;
25 import net.sourceforge.phpdt.internal.ui.text.JavaOutlineInformationControl;
26 import net.sourceforge.phpdt.internal.ui.text.JavaPresentationReconciler;
27 import net.sourceforge.phpdt.internal.ui.text.JavaReconciler;
28 import net.sourceforge.phpdt.internal.ui.text.PreferencesAdapter;
29 import net.sourceforge.phpdt.internal.ui.text.java.JavaFormattingStrategy;
30 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategy;
31 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
32 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
33 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaInformationProvider;
34 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCodeScanner;
35 import net.sourceforge.phpdt.internal.ui.text.phpdoc.PHPDocCompletionProcessor;
36 import net.sourceforge.phpdt.ui.PreferenceConstants;
37 import net.sourceforge.phpeclipse.IPreferenceConstants;
38 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
39 import net.sourceforge.phpeclipse.phpeditor.PHPEditor;
40 import net.sourceforge.phpeclipse.phpeditor.html.HTMLFormattingStrategy;
41 import net.sourceforge.phpeclipse.phpeditor.php.HTMLCompletionProcessor;
42 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
43 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
44 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
45 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
46 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
47 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
48 import net.sourceforge.phpeclipse.phpeditor.php.SmartyCodeScanner;
49 import net.sourceforge.phpeclipse.phpeditor.php.SmartyDocCodeScanner;
50 import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider;
51 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
52 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
53 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
54 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
55
56 import org.eclipse.core.runtime.NullProgressMonitor;
57 import org.eclipse.jface.preference.IPreferenceStore;
58 import org.eclipse.jface.text.DefaultAutoIndentStrategy;
59 import org.eclipse.jface.text.DefaultInformationControl;
60 import org.eclipse.jface.text.IAutoIndentStrategy;
61 import org.eclipse.jface.text.IDocument;
62 import org.eclipse.jface.text.IInformationControl;
63 import org.eclipse.jface.text.IInformationControlCreator;
64 import org.eclipse.jface.text.ITextDoubleClickStrategy;
65 import org.eclipse.jface.text.ITextHover;
66 import org.eclipse.jface.text.ITextViewerExtension2;
67 import org.eclipse.jface.text.TextAttribute;
68 import org.eclipse.jface.text.contentassist.ContentAssistant;
69 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
70 import org.eclipse.jface.text.contentassist.IContentAssistant;
71 import org.eclipse.jface.text.formatter.ContentFormatter;
72 import org.eclipse.jface.text.formatter.IContentFormatter;
73 import org.eclipse.jface.text.formatter.IFormattingStrategy;
74 import org.eclipse.jface.text.information.IInformationPresenter;
75 import org.eclipse.jface.text.information.IInformationProvider;
76 import org.eclipse.jface.text.information.InformationPresenter;
77 import org.eclipse.jface.text.presentation.IPresentationDamager;
78 import org.eclipse.jface.text.presentation.IPresentationReconciler;
79 import org.eclipse.jface.text.presentation.IPresentationRepairer;
80 import org.eclipse.jface.text.presentation.PresentationReconciler;
81 import org.eclipse.jface.text.reconciler.IReconciler;
82 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
83 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
84 import org.eclipse.jface.text.rules.DefaultPartitioner;
85 import org.eclipse.jface.text.rules.RuleBasedScanner;
86 import org.eclipse.jface.text.rules.Token;
87 import org.eclipse.jface.text.source.IAnnotationHover;
88 import org.eclipse.jface.text.source.ISourceViewer;
89 import org.eclipse.jface.text.source.SourceViewerConfiguration;
90 import org.eclipse.jface.util.Assert;
91 import org.eclipse.jface.util.PropertyChangeEvent;
92 import org.eclipse.swt.SWT;
93 import org.eclipse.swt.widgets.Shell;
94 import org.eclipse.ui.editors.text.EditorsUI;
95 import org.eclipse.ui.texteditor.ChainedPreferenceStore;
96 import org.eclipse.ui.texteditor.ITextEditor;
97
98 /**
99  * Configuration for an <code>SourceViewer</code> which shows PHP code.
100  */
101 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
102   /**
103    * Preference key used to look up display tab width.
104    * 
105    * @since 2.0
106    */
107   public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
108
109   /**
110    * Preference key for inserting spaces rather than tabs.
111    * 
112    * @since 2.0
113    */
114   public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
115
116   //  public static final String HTML_DEFAULT =
117   // IPHPPartitionScannerConstants.HTML;
118   //IDocument.DEFAULT_CONTENT_TYPE;
119   private JavaTextTools fJavaTextTools;
120
121   private ITextEditor fTextEditor;
122
123   /**
124    * The document partitioning.
125    * 
126    * @since 3.0
127    */
128   private String fDocumentPartitioning;
129
130   private ContentFormatter fFormatter;
131
132   private HTMLFormattingStrategy fFormattingStrategy;
133
134   /**
135    * Single token scanner.
136    */
137   static class SingleTokenScanner extends BufferedRuleBasedScanner {
138     public SingleTokenScanner(TextAttribute attribute) {
139       setDefaultReturnToken(new Token(attribute));
140     }
141   };
142
143   /**
144    * The document partitioning.
145    * 
146    * @since 3.0
147    */
148   //  private String fDocumentPartitioning;
149   /**
150    * The Java source code scanner
151    * 
152    * @since 3.0
153    */
154   private AbstractJavaScanner fCodeScanner;
155
156   /**
157    * The Java multi-line comment scanner
158    * 
159    * @since 3.0
160    */
161   private AbstractJavaScanner fMultilineCommentScanner;
162
163   /**
164    * The Java single-line comment scanner
165    * 
166    * @since 3.0
167    */
168   private AbstractJavaScanner fSinglelineCommentScanner;
169
170   /**
171    * The Java string scanner
172    * 
173    * @since 3.0
174    */
175   private AbstractJavaScanner fStringScanner;
176
177   /**
178    * The Javadoc scanner
179    * 
180    * @since 3.0
181    */
182   private AbstractJavaScanner fJavaDocScanner;
183
184   /**
185    * The preference store, can be read-only
186    * 
187    * @since 3.0
188    */
189   private IPreferenceStore fPreferenceStore;
190
191   /**
192    * The color manager
193    * 
194    * @since 3.0
195    */
196   private IColorManager fColorManager;
197
198   private XMLTextTools fXMLTextTools;
199
200   private XMLConfiguration xmlConfiguration;
201
202   /**
203    * Creates a new Java source viewer configuration for viewers in the given editor using the given preference store, the color
204    * manager and the specified document partitioning.
205    * <p>
206    * Creates a Java source viewer configuration in the new setup without text tools. Clients are allowed to call
207    * {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}and disallowed to call
208    * {@link JavaSourceViewerConfiguration#getPreferenceStore()}on the resulting Java source viewer configuration.
209    * </p>
210    * 
211    * @param colorManager
212    *          the color manager
213    * @param preferenceStore
214    *          the preference store, can be read-only
215    * @param editor
216    *          the editor in which the configured viewer(s) will reside
217    * @param partitioning
218    *          the document partitioning for this configuration
219    * @since 3.0
220    */
221   public PHPSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor,
222       String partitioning) {
223     fColorManager = colorManager;
224     fPreferenceStore = preferenceStore;
225     fTextEditor = editor;
226     fDocumentPartitioning = partitioning;
227 //    fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
228     fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
229     xmlConfiguration = new XMLConfiguration(fXMLTextTools);
230     fColorManager= colorManager;
231         fPreferenceStore= preferenceStore;
232         fTextEditor= editor;
233         fDocumentPartitioning= partitioning;
234         
235     initializeScanners();
236   }
237
238   /**
239          * Creates a new Java source viewer configuration for viewers in the given editor 
240          * using the given Java tools.
241          *
242          * @param tools the Java text tools to be used
243          * @param editor the editor in which the configured viewer(s) will reside
244          * @see JavaTextTools
245          * @deprecated As of 3.0, replaced by {@link JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)}
246          */
247 //  public PHPSourceViewerConfiguration(JavaTextTools tools, PHPEditor editor, String partitioning) {
248 //    fJavaTextTools = tools;
249 //    fColorManager = tools.getColorManager();
250 //    fPreferenceStore = createPreferenceStore();
251 //    fDocumentPartitioning = partitioning;
252 //    fCodeScanner = (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
253 //    fMultilineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getMultilineCommentScanner();
254 //    fSinglelineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getSinglelineCommentScanner();
255 //    fStringScanner = (AbstractJavaScanner) fJavaTextTools.getStringScanner();
256 //    fJavaDocScanner = (AbstractJavaScanner) fJavaTextTools.getJavaDocScanner();
257 //    fTextEditor = editor;
258 //    fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
259 //    xmlConfiguration = new XMLConfiguration(fXMLTextTools);
260 //  }
261
262   /**
263    * Returns the color manager for this configuration.
264    * 
265    * @return the color manager
266    */
267   protected IColorManager getColorManager() {
268     return fColorManager;
269   }
270
271   /**
272    * Initializes the scanners.
273    * 
274    * @since 3.0
275    */
276   private void initializeScanners() {
277     Assert.isTrue(isNewSetup());
278     fCodeScanner = new PHPCodeScanner(getColorManager(), fPreferenceStore);
279     fMultilineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
280         IPreferenceConstants.PHP_MULTILINE_COMMENT);
281     fSinglelineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
282         IPreferenceConstants.PHP_SINGLELINE_COMMENT);
283     fStringScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING);
284     fJavaDocScanner = new PHPDocCodeScanner(getColorManager(), fPreferenceStore);
285   }
286
287   /**
288    * Determines whether the preference change encoded by the given event changes the behavior of one of its contained components.
289    * 
290    * @param event
291    *          the event to be investigated
292    * @return <code>true</code> if event causes a behavioral change
293    * @since 3.0
294    */
295   public boolean affectsTextPresentation(PropertyChangeEvent event) {
296     return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
297         || fSinglelineCommentScanner.affectsBehavior(event) || fStringScanner.affectsBehavior(event)
298         || fJavaDocScanner.affectsBehavior(event);
299   }
300
301   /**
302    * Adapts the behavior of the contained components to the change encoded in the given event.
303    * <p>
304    * Clients are not allowed to call this method if the old setup with text tools is in use.
305    * </p>
306    * 
307    * @param event
308    *          the event to which to adapt
309    * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
310    * @since 3.0
311    */
312   public void handlePropertyChangeEvent(PropertyChangeEvent event) {
313     Assert.isTrue(isNewSetup());
314     if (fCodeScanner.affectsBehavior(event))
315       fCodeScanner.adaptToPreferenceChange(event);
316     if (fMultilineCommentScanner.affectsBehavior(event))
317       fMultilineCommentScanner.adaptToPreferenceChange(event);
318     if (fSinglelineCommentScanner.affectsBehavior(event))
319       fSinglelineCommentScanner.adaptToPreferenceChange(event);
320     if (fStringScanner.affectsBehavior(event))
321       fStringScanner.adaptToPreferenceChange(event);
322     if (fJavaDocScanner.affectsBehavior(event))
323       fJavaDocScanner.adaptToPreferenceChange(event);
324   }
325
326   /*
327    * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
328    */
329   public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
330     //    if (fFormatter == null) {
331     //      fFormatter = new ContentFormatter();
332     //      fFormattingStrategy = new HTMLFormattingStrategy(this,
333     // sourceViewer);
334     //      fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
335     //      fFormatter.enablePartitionAwareFormatting(false);
336     //      fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
337     //    }
338     //    return fFormatter;
339     if (fFormatter == null) {
340       //ContentFormatter
341       fFormatter = new ContentFormatter();
342       IFormattingStrategy strategy = new JavaFormattingStrategy(sourceViewer);
343       fFormatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
344       fFormatter.enablePartitionAwareFormatting(false);
345       fFormatter.setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
346     }
347     return fFormatter;
348   }
349
350   /**
351    * Returns the names of the document position categories used by the document partitioners created by this object to manage their
352    * partition information. If the partitioners don't use document position categories, the returned result is <code>null</code>.
353    * 
354    * @return the partition managing position categories or <code>null</code> if there is none
355    */
356   public String[] getPartitionManagingPositionCategories() {
357     return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
358   }
359
360   //  /**
361   //   * Returns the names of the document position categories used by the
362   // document
363   //   * partitioners created by this object to manage their partition
364   // information.
365   //   * If the partitioners don't use document position categories, the
366   // returned
367   //   * result is <code>null</code>.
368   //   *
369   //   * @return the partition managing position categories or
370   // <code>null</code>
371   //   * if there is none
372   //   */
373   //  private String[] getPartitionManagingPositionCategories() {
374   //    return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
375   //  }
376   public ITextEditor getEditor() {
377     return fTextEditor;
378   }
379
380   /**
381    * Returns the preference store used by this configuration to initialize the individual bits and pieces.
382    * 
383    * @return the preference store used to initialize this configuration
384    * 
385    * @since 2.0
386    */
387   protected IPreferenceStore getPreferenceStore() {
388     return PHPeclipsePlugin.getDefault().getPreferenceStore();
389   }
390
391   //  /* (non-Javadoc)
392   //   * Method declared on SourceViewerConfiguration
393   //   */
394   //  public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
395   //    return new PHPAnnotationHover();
396   //  }
397   /*
398    * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
399    */
400   public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
401     return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
402   }
403
404   /*
405    * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
406    * @since 3.0
407    */
408   public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
409     return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
410   }
411
412   /*
413    * (non-Javadoc) Method declared on SourceViewerConfiguration
414    */
415   public IAutoIndentStrategy getAutoIndentStrategy(ISourceViewer sourceViewer, String contentType) {
416     if (IPHPPartitions.PHP_STRING_DQ.equals(contentType) || IPHPPartitions.PHP_STRING_SQ.equals(contentType))
417       return new JavaStringAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
418
419     return (PHPDocumentPartitioner.PHP_TEMPLATE_DATA.equals(contentType)
420         || PHPDocumentPartitioner.PHP_SCRIPT_CODE.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
421         || IPHPPartitions.PHP_PARTITIONING.equals(contentType) || PHPPartitionScanner.PHP_SCRIPTING_AREA.equals(contentType) ? new PHPAutoIndentStrategy()
422         : new DefaultAutoIndentStrategy());
423   }
424
425   /**
426    * Returns the PHP source code scanner for this configuration.
427    * 
428    * @return the PHP source code scanner
429    */
430   protected RuleBasedScanner getCodeScanner() {
431     return fCodeScanner; //fJavaTextTools.getCodeScanner();
432   }
433         /**
434          * Returns the Java multi-line comment scanner for this configuration.
435          *
436          * @return the Java multi-line comment scanner
437          * @since 2.0
438          */
439         protected RuleBasedScanner getMultilineCommentScanner() {
440                 return fMultilineCommentScanner;
441         }
442         
443         /**
444          * Returns the Java single-line comment scanner for this configuration.
445          *
446          * @return the Java single-line comment scanner
447          * @since 2.0
448          */
449         protected RuleBasedScanner getSinglelineCommentScanner() {
450                 return fSinglelineCommentScanner;
451         }
452         
453         /**
454          * Returns the Java string scanner for this configuration.
455          *
456          * @return the Java string scanner
457          * @since 2.0
458          */
459         protected RuleBasedScanner getStringScanner() {
460                 return fStringScanner;
461         }
462   /**
463    * Returns the HTML source code scanner for this configuration.
464    * 
465    * @return the HTML source code scanner
466    */
467   //  protected RuleBasedScanner getHTMLScanner() {
468   //    return fJavaTextTools.getHTMLScanner();
469   //  }
470   /**
471    * Returns the Smarty source code scanner for this configuration.
472    * 
473    * @return the Smarty source code scanner
474    */
475 //  protected RuleBasedScanner getSmartyScanner() {
476 //    return fJavaTextTools.getSmartyScanner();
477 //  }
478
479   /*
480    * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
481    */
482   /*
483    * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
484    */
485   public IReconciler getReconciler(ISourceViewer sourceViewer) {
486
487     final ITextEditor editor = getEditor();
488     if (editor != null && editor.isEditable()) {
489
490       JavaCompositeReconcilingStrategy strategy = new JavaCompositeReconcilingStrategy(editor,
491           getConfiguredDocumentPartitioning(sourceViewer));
492       JavaReconciler reconciler = new JavaReconciler(editor, strategy, false);
493       reconciler.setIsIncrementalReconciler(false);
494       reconciler.setProgressMonitor(new NullProgressMonitor());
495       reconciler.setDelay(500);
496
497       return reconciler;
498     }
499     return null;
500   }
501
502   //    public IReconciler getReconciler(ISourceViewer sourceViewer) {
503   //            if (getEditor() != null && getEditor().isEditable()) {
504   //                    JavaReconciler reconciler = new JavaReconciler(getEditor(),
505   //                                    new JavaReconcilingStrategy(getEditor()), false);
506   //                    reconciler.setProgressMonitor(new NullProgressMonitor());
507   //                    reconciler.setDelay(500);
508   //                    return reconciler;
509   //            }
510   //            return null;
511   //    }
512   /*
513    * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
514    * @since 2.1
515    */
516   public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
517     JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin.getDefault().getJavaEditorTextHoverDescriptors();
518     int stateMasks[] = new int[hoverDescs.length];
519     int stateMasksLength = 0;
520     for (int i = 0; i < hoverDescs.length; i++) {
521       if (hoverDescs[i].isEnabled()) {
522         int j = 0;
523         int stateMask = hoverDescs[i].getStateMask();
524         while (j < stateMasksLength) {
525           if (stateMasks[j] == stateMask)
526             break;
527           j++;
528         }
529         if (j == stateMasksLength)
530           stateMasks[stateMasksLength++] = stateMask;
531       }
532     }
533     if (stateMasksLength == hoverDescs.length)
534       return stateMasks;
535     int[] shortenedStateMasks = new int[stateMasksLength];
536     System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength);
537     return shortenedStateMasks;
538   }
539
540   /*
541    * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String, int)
542    * @since 2.1
543    */
544   public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType, int stateMask) {
545     JavaEditorTextHoverDescriptor[] hoverDescs = PHPeclipsePlugin.getDefault().getJavaEditorTextHoverDescriptors();
546     int i = 0;
547     while (i < hoverDescs.length) {
548       if (hoverDescs[i].isEnabled() && hoverDescs[i].getStateMask() == stateMask)
549         return new JavaEditorTextHoverProxy(hoverDescs[i], getEditor());
550       i++;
551     }
552     return null;
553     //          if (fEditor != null) {
554     //                  IEditorInput editorInput = fEditor.getEditorInput();
555     //                  if (editorInput instanceof IFileEditorInput) {
556     //                          try {
557     //                                  IFile f = ((IFileEditorInput) editorInput).getFile();
558     //                                  return new PHPTextHover(f.getProject());
559     //                          } catch (NullPointerException e) {
560     //                                  // this exception occurs, if getTextHover is called by
561     //                                  // preference pages !
562     //                          }
563     //                  }
564     //          }
565     //          return new PHPTextHover(null);
566   }
567
568   /*
569    * @see SourceViewerConfiguration#getTextHover(ISourceViewer, String)
570    */
571   public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
572     return getTextHover(sourceViewer, contentType, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
573   }
574
575   /**
576    * Returns the SmartyDoc source code scanner for this configuration.
577    * 
578    * @return the SmartyDoc source code scanner
579    */
580 //  protected RuleBasedScanner getSmartyDocScanner() {
581 //    return fJavaTextTools.getSmartyDocScanner();
582 //  }
583
584   /**
585    * Returns the PHPDoc source code scanner for this configuration.
586    * 
587    * @return the PHPDoc source code scanner
588    */
589   protected RuleBasedScanner getPHPDocScanner() {
590     return fJavaDocScanner; //fJavaTextTools.getJavaDocScanner();
591   }
592
593   /*
594    * (non-Javadoc) Method declared on SourceViewerConfiguration
595    */
596   public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
597     return new String[] { IDocument.DEFAULT_CONTENT_TYPE, PHPPartitionScanner.PHP_SCRIPTING_AREA,
598
599     IPHPPartitions.HTML, IPHPPartitions.HTML_MULTILINE_COMMENT, IPHPPartitions.PHP_PARTITIONING,
600         IPHPPartitions.PHP_SINGLELINE_COMMENT, IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT,
601         IPHPPartitions.PHP_STRING_DQ, IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT,
602         IPHPPartitions.JAVASCRIPT, IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY,
603         IPHPPartitions.SMARTY_MULTILINE_COMMENT,
604
605         XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL, XMLPartitionScanner.XML_TAG,
606         XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
607
608         XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
609         XMLPartitionScanner.DTD_INTERNAL_DECL,
610
611         PHPDocumentPartitioner.PHP_TEMPLATE_DATA, PHPDocumentPartitioner.PHP_SCRIPT_CODE };
612   }
613
614   public String[] getConfiguredHTMLContentTypes() {
615     return new String[] { XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL,
616         XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
617
618         XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
619         XMLPartitionScanner.DTD_INTERNAL_DECL, };
620   }
621
622   public String[] getConfiguredPHPContentTypes() {
623     return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IPHPPartitions.PHP_PARTITIONING, IPHPPartitions.PHP_SINGLELINE_COMMENT,
624         IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT, IPHPPartitions.PHP_STRING_DQ,
625         IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT, IPHPPartitions.JAVASCRIPT,
626         IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY, IPHPPartitions.SMARTY_MULTILINE_COMMENT, };
627   }
628
629   /*
630    * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
631    * @since 3.0
632    */
633   public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
634     if (fDocumentPartitioning != null)
635       return fDocumentPartitioning;
636     return super.getConfiguredDocumentPartitioning(sourceViewer);
637   }
638
639   /*
640    * (non-Javadoc) Method declared on SourceViewerConfiguration
641    */
642   public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
643     ContentAssistant assistant = new ContentAssistant();
644     IContentAssistProcessor processor = new HTMLCompletionProcessor(getEditor());
645     assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
646     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML);
647     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML_MULTILINE_COMMENT);
648
649     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS);
650     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS_MULTILINE_COMMENT);
651     assistant.setContentAssistProcessor(processor, IPHPPartitions.JAVASCRIPT);
652     assistant.setContentAssistProcessor(processor, IPHPPartitions.JS_MULTILINE_COMMENT);
653     // TODO define special smarty partition content assist
654     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY);
655     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
656
657     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
658     String[] htmlTypes = getConfiguredHTMLContentTypes();
659     for (int i = 0; i < htmlTypes.length; i++) {
660       assistant.setContentAssistProcessor(processor, htmlTypes[i]);
661     }
662     processor = new PHPCompletionProcessor(getEditor());
663
664     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_SCRIPT_CODE);
665     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_PARTITIONING);
666     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_DQ);
667     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_SQ);
668
669     assistant.setContentAssistProcessor(new PHPDocCompletionProcessor(getEditor()), IPHPPartitions.PHP_PHPDOC_COMMENT);
670     //    assistant.enableAutoActivation(true);
671     //    assistant.setAutoActivationDelay(500);
672     //    assistant.setProposalPopupOrientation(ContentAssistant.PROPOSAL_OVERLAY);
673     //    ContentAssistPreference.configure(assistant, getPreferenceStore());
674     //    assistant.setContextInformationPopupOrientation(
675     //      ContentAssistant.CONTEXT_INFO_ABOVE);
676     //    assistant.setContextInformationPopupBackground(
677     //      PHPEditorEnvironment.getPHPColorProvider().getColor(
678     //        new RGB(150, 150, 0)));
679     ContentAssistPreference.configure(assistant, getPreferenceStore());
680     assistant.setContextInformationPopupOrientation(ContentAssistant.CONTEXT_INFO_ABOVE);
681     assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
682     return assistant;
683   }
684
685   /*
686    * (non-Javadoc) Method declared on SourceViewerConfiguration
687    */
688   //  public String getDefaultPrefix(ISourceViewer sourceViewer, String
689   // contentType) {
690   //    return (PHPPartitionScanner.PHP.equals(contentType) ? "//" : null);
691   // //$NON-NLS-1$
692   //    // return (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType) ? "//" :
693   // null); //$NON-NLS-1$
694   //  }
695   /*
696    * @see SourceViewerConfiguration#getDefaultPrefix(ISourceViewer, String)
697    * @since 2.0
698    */
699   public String[] getDefaultPrefixes(ISourceViewer sourceViewer, String contentType) {
700     return new String[] { "//", "" }; //$NON-NLS-1$ //$NON-NLS-2$
701   }
702
703   /*
704    * (non-Javadoc) Method declared on SourceViewerConfiguration
705    */
706   public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) {
707     return new PHPDoubleClickSelector();
708   }
709
710   /*
711    * @see SourceViewerConfiguration#getIndentPrefixes(ISourceViewer, String)
712    */
713   public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
714     Vector vector = new Vector();
715     // prefix[0] is either '\t' or ' ' x tabWidth, depending on useSpaces
716     final IPreferenceStore preferences = PHPeclipsePlugin.getDefault().getPreferenceStore();
717     int tabWidth = preferences.getInt(JavaCore.FORMATTER_TAB_SIZE);
718     boolean useSpaces = getPreferenceStore().getBoolean(SPACES_FOR_TABS);
719     for (int i = 0; i <= tabWidth; i++) {
720       StringBuffer prefix = new StringBuffer();
721       if (useSpaces) {
722         for (int j = 0; j + i < tabWidth; j++)
723           prefix.append(' ');
724         if (i != 0)
725           prefix.append('\t');
726       } else {
727         for (int j = 0; j < i; j++)
728           prefix.append(' ');
729         if (i != tabWidth)
730           prefix.append('\t');
731       }
732       vector.add(prefix.toString());
733     }
734     vector.add(""); //$NON-NLS-1$
735     return (String[]) vector.toArray(new String[vector.size()]);
736   }
737
738   /**
739    * @return <code>true</code> iff the new setup without text tools is in use.
740    * 
741    * @since 3.0
742    */
743   private boolean isNewSetup() {
744     return fJavaTextTools == null;
745   }
746
747   /**
748    * Creates and returns a preference store which combines the preference stores from the text tools and which is read-only.
749    * 
750    * @return the read-only preference store
751    * @since 3.0
752    */
753   private IPreferenceStore createPreferenceStore() {
754     Assert.isTrue(!isNewSetup());
755     IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
756     if (fJavaTextTools.getCorePreferenceStore() == null)
757       return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(), generalTextStore });
758
759     return new ChainedPreferenceStore(new IPreferenceStore[] { fJavaTextTools.getPreferenceStore(),
760         new PreferencesAdapter(fJavaTextTools.getCorePreferenceStore()), generalTextStore });
761   }
762
763   /*
764    * (non-Javadoc) Method declared on SourceViewerConfiguration
765    */
766   public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
767     //  PHPColorProvider provider =
768     // PHPEditorEnvironment.getPHPColorProvider();
769     //    JavaColorManager provider =
770     // PHPEditorEnvironment.getPHPColorProvider();
771     PresentationReconciler phpReconciler = new JavaPresentationReconciler();
772     phpReconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
773
774     //    DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getHTMLScanner());
775     //    reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
776     //    reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
777     //    dr = new DefaultDamagerRepairer(getHTMLScanner());
778     //    reconciler.setDamager(dr, IPHPPartitions.HTML);
779     //    reconciler.setRepairer(dr, IPHPPartitions.HTML);
780     //    dr = new DefaultDamagerRepairer(getHTMLScanner());
781     //    reconciler.setDamager(dr, IPHPPartitions.CSS);
782     //    reconciler.setRepairer(dr, IPHPPartitions.CSS);
783     //    dr = new DefaultDamagerRepairer(getHTMLScanner());
784     //    reconciler.setDamager(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
785     //    reconciler.setRepairer(dr, IPHPPartitions.CSS_MULTILINE_COMMENT);
786     //    dr = new DefaultDamagerRepairer(getHTMLScanner());
787     //    reconciler.setDamager(dr, IPHPPartitions.JAVASCRIPT);
788     //    reconciler.setRepairer(dr, IPHPPartitions.JAVASCRIPT);
789     //    dr = new DefaultDamagerRepairer(getHTMLScanner());
790     //    reconciler.setDamager(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
791     //    reconciler.setRepairer(dr, IPHPPartitions.JS_MULTILINE_COMMENT);
792 //    DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(getSmartyScanner());
793 //    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY);
794 //    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY);
795 //    phpDR = new DefaultDamagerRepairer(getSmartyDocScanner());
796 //    phpReconciler.setDamager(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
797 //    phpReconciler.setRepairer(phpDR, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
798     //    dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
799     //        PHPColorProvider.MULTI_LINE_COMMENT))));
800     //    reconciler.setDamager(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
801     //    reconciler.setRepairer(dr, IPHPPartitions.HTML_MULTILINE_COMMENT);
802
803     DefaultDamagerRepairer phpDR = new DefaultDamagerRepairer(getCodeScanner());
804     phpReconciler.setDamager(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
805     phpReconciler.setRepairer(phpDR, IDocument.DEFAULT_CONTENT_TYPE);
806
807     phpDR = new DefaultDamagerRepairer(getCodeScanner());
808     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PARTITIONING);
809     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PARTITIONING);
810
811     phpDR = new DefaultDamagerRepairer(getPHPDocScanner());
812     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
813     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_PHPDOC_COMMENT);
814
815     phpDR = new DefaultDamagerRepairer(getStringScanner());
816     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_DQ);
817     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
818     phpDR = new DefaultDamagerRepairer(getStringScanner());
819     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
820     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
821     phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
822     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
823     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
824     phpDR = new DefaultDamagerRepairer(getMultilineCommentScanner());
825     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
826     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
827
828     PresentationReconciler reconciler = new PresentationReconciler();
829     reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
830     //
831     JavaTextTools jspTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
832     DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getPHPDocScanner());//jspTextTools.getJSPTextScanner());
833     reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
834     reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
835
836     //  dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
837     //        PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPBracketScanner());
838     //  reconciler.setDamager(dr, JSPScriptScanner.JSP_BRACKET);
839     //  reconciler.setRepairer(dr, JSPScriptScanner.JSP_BRACKET);
840
841     // xml partitions
842     configureEmbeddedPresentationReconciler(reconciler, xmlConfiguration.getPresentationReconciler(sourceViewer), xmlConfiguration
843         .getConfiguredContentTypes(sourceViewer), PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
844
845     // java partitions
846     configureEmbeddedPresentationReconciler(reconciler, phpReconciler, getConfiguredPHPContentTypes(),
847         PHPDocumentPartitioner.PHP_SCRIPT_CODE);
848
849     return reconciler;
850   }
851
852   private void configureEmbeddedPresentationReconciler(PresentationReconciler reconciler, IPresentationReconciler embedded,
853       String[] types, String defaultType) {
854     for (int i = 0; i < types.length; i++) {
855       String type = types[i];
856
857       IPresentationDamager damager = embedded.getDamager(type);
858       IPresentationRepairer repairer = embedded.getRepairer(type);
859
860       if (type == IDocument.DEFAULT_CONTENT_TYPE) {
861         type = defaultType;
862       }
863
864       reconciler.setDamager(damager, type);
865       reconciler.setRepairer(repairer, type);
866     }
867   }
868
869   /*
870    * (non-Javadoc) Method declared on SourceViewerConfiguration
871    */
872   public int getTabWidth(ISourceViewer sourceViewer) {
873     return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
874   }
875
876   /*
877    * (non-Javadoc) Method declared on SourceViewerConfiguration
878    */
879   //  public ITextHover getTextHover(ISourceViewer sourceViewer, String
880   // contentType) {
881   //    if (fEditor != null) {
882   //      IEditorInput editorInput = fEditor.getEditorInput();
883   //      if (editorInput instanceof IFileEditorInput) {
884   //        try {
885   //          IFile f = ((IFileEditorInput) editorInput).getFile();
886   //          return new PHPTextHover(f.getProject());
887   //        } catch (NullPointerException e) {
888   //          // this exception occurs, if getTextHover is called by preference pages
889   // !
890   //        }
891   //      }
892   //    }
893   //    return new PHPTextHover(null);
894   //  }
895   /*
896    * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
897    * @since 2.0
898    */
899   public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
900     return new IInformationControlCreator() {
901       public IInformationControl createInformationControl(Shell parent) {
902         return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
903         // return new HoverBrowserControl(parent);
904       }
905     };
906   }
907
908   /*
909    * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
910    * @since 2.0
911    */
912   public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
913     InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
914     presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
915     IInformationProvider provider = new JavaInformationProvider(getEditor());
916     presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
917     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
918     //          presenter.setInformationProvider(provider, IPHPPartitions.JAVA_CHARACTER);
919     presenter.setSizeConstraints(60, 10, true, true);
920     return presenter;
921   }
922
923   /*
924    * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
925    * @since 2.0
926    */
927   //    public IInformationPresenter getInformationPresenter(ISourceViewer
928   // sourceViewer) {
929   //            InformationPresenter presenter= new
930   // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
931   //            IInformationProvider provider= new JavaInformationProvider(getEditor());
932   //            presenter.setInformationProvider(provider,
933   // IDocument.DEFAULT_CONTENT_TYPE);
934   //            presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
935   //            presenter.setSizeConstraints(60, 10, true, true);
936   //            return presenter;
937   //    }
938   /**
939    * Returns the information presenter control creator. The creator is a factory creating the presenter controls for the given
940    * source viewer. This implementation always returns a creator for <code>DefaultInformationControl</code> instances.
941    * 
942    * @param sourceViewer
943    *          the source viewer to be configured by this configuration
944    * @return an information control creator
945    * @since 2.1
946    */
947   private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
948     return new IInformationControlCreator() {
949       public IInformationControl createInformationControl(Shell parent) {
950         int shellStyle = SWT.RESIZE;
951         int style = SWT.V_SCROLL | SWT.H_SCROLL;
952         return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
953         // return new HoverBrowserControl(parent);
954       }
955     };
956   }
957
958   /**
959    * Returns the outline presenter control creator. The creator is a factory creating outline presenter controls for the given
960    * source viewer. This implementation always returns a creator for <code>JavaOutlineInformationControl</code> instances.
961    * 
962    * @param sourceViewer
963    *          the source viewer to be configured by this configuration
964    * @return an information control creator
965    * @since 2.1
966    */
967   private IInformationControlCreator getOutlinePresenterControlCreator(ISourceViewer sourceViewer) {
968     return new IInformationControlCreator() {
969       public IInformationControl createInformationControl(Shell parent) {
970         int shellStyle = SWT.RESIZE;
971         int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
972         return new JavaOutlineInformationControl(parent, shellStyle, treeStyle);
973       }
974     };
975   }
976
977   /**
978    * Returns the outline presenter which will determine and shown information requested for the current cursor position.
979    * 
980    * @param sourceViewer
981    *          the source viewer to be configured by this configuration
982    * @param doCodeResolve
983    *          a boolean which specifies whether code resolve should be used to compute the Java element
984    * @return an information presenter
985    * @since 2.1
986    */
987   public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
988     InformationPresenter presenter = new InformationPresenter(getOutlinePresenterControlCreator(sourceViewer));
989     presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
990     IInformationProvider provider = new JavaElementProvider(getEditor(), doCodeResolve);
991     presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
992     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PARTITIONING);
993     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
994     presenter.setInformationProvider(provider, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
995     presenter.setInformationProvider(provider, IPHPPartitions.HTML);
996     presenter.setInformationProvider(provider, IPHPPartitions.HTML_MULTILINE_COMMENT);
997     presenter.setSizeConstraints(40, 20, true, false);
998     return presenter;
999   }
1000 }