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