replaced a lot of deprecated code; if someone runs into a commit conflict afterwards...
[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.java.JavaFormattingStrategy;
28 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategyDQ;
29 import net.sourceforge.phpdt.internal.ui.text.java.JavaStringAutoIndentStrategySQ;
30 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverDescriptor;
31 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaEditorTextHoverProxy;
32 import net.sourceforge.phpdt.internal.ui.text.java.hover.JavaInformationProvider;
33 import net.sourceforge.phpdt.internal.ui.text.phpdoc.JavaDocAutoIndentStrategy;
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.php.HTMLCompletionProcessor;
40 import net.sourceforge.phpeclipse.phpeditor.php.PHPAutoIndentStrategy;
41 import net.sourceforge.phpeclipse.phpeditor.php.PHPCodeScanner;
42 import net.sourceforge.phpeclipse.phpeditor.php.PHPCompletionProcessor;
43 import net.sourceforge.phpeclipse.phpeditor.php.PHPDocumentPartitioner;
44 import net.sourceforge.phpeclipse.phpeditor.php.PHPDoubleClickSelector;
45 import net.sourceforge.phpeclipse.phpeditor.php.PHPPartitionScanner;
46 import net.sourceforge.phpeclipse.xml.ui.XMLPlugin;
47 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLConfiguration;
48 import net.sourceforge.phpeclipse.xml.ui.internal.text.XMLPartitionScanner;
49 import net.sourceforge.phpeclipse.xml.ui.text.XMLTextTools;
50
51 import org.eclipse.core.runtime.NullProgressMonitor;
52 import org.eclipse.jface.preference.IPreferenceStore;
53 import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
54 import org.eclipse.jface.text.DefaultInformationControl;
55 import org.eclipse.jface.text.IAutoEditStrategy;
56 import org.eclipse.jface.text.IDocument;
57 import org.eclipse.jface.text.IInformationControl;
58 import org.eclipse.jface.text.IInformationControlCreator;
59 import org.eclipse.jface.text.ITextDoubleClickStrategy;
60 import org.eclipse.jface.text.ITextHover;
61 import org.eclipse.jface.text.ITextViewerExtension2;
62 import org.eclipse.jface.text.TextAttribute;
63 import org.eclipse.jface.text.contentassist.ContentAssistant;
64 import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
65 import org.eclipse.jface.text.contentassist.IContentAssistant;
66 import org.eclipse.jface.text.formatter.ContentFormatter;
67 import org.eclipse.jface.text.formatter.IContentFormatter;
68 import org.eclipse.jface.text.formatter.IFormattingStrategy;
69 import org.eclipse.jface.text.information.IInformationPresenter;
70 import org.eclipse.jface.text.information.IInformationProvider;
71 import org.eclipse.jface.text.information.InformationPresenter;
72 import org.eclipse.jface.text.presentation.IPresentationDamager;
73 import org.eclipse.jface.text.presentation.IPresentationReconciler;
74 import org.eclipse.jface.text.presentation.IPresentationRepairer;
75 import org.eclipse.jface.text.presentation.PresentationReconciler;
76 import org.eclipse.jface.text.reconciler.IReconciler;
77 import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
78 import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
79 import org.eclipse.jface.text.rules.DefaultPartitioner;
80 import org.eclipse.jface.text.rules.RuleBasedScanner;
81 import org.eclipse.jface.text.rules.Token;
82 import org.eclipse.jface.text.source.IAnnotationHover;
83 import org.eclipse.jface.text.source.ISourceViewer;
84 import org.eclipse.jface.text.source.SourceViewerConfiguration;
85 import org.eclipse.jface.util.PropertyChangeEvent;
86 import org.eclipse.swt.SWT;
87 import org.eclipse.swt.widgets.Shell;
88 import org.eclipse.ui.texteditor.ITextEditor;
89
90 /**
91  * Configuration for an <code>SourceViewer</code> which shows PHP code.
92  */
93 public class PHPSourceViewerConfiguration extends SourceViewerConfiguration {
94   /**
95    * Preference key used to look up display tab width.
96    *
97    * @since 2.0
98    */
99   public final static String PREFERENCE_TAB_WIDTH = PreferenceConstants.EDITOR_TAB_WIDTH;
100
101   /**
102    * Preference key for inserting spaces rather than tabs.
103    *
104    * @since 2.0
105    */
106   public final static String SPACES_FOR_TABS = PreferenceConstants.EDITOR_SPACES_FOR_TABS;
107
108   //  public static final String HTML_DEFAULT =
109   // IPHPPartitionScannerConstants.HTML;
110   //IDocument.DEFAULT_CONTENT_TYPE;
111 //  private JavaTextTools fJavaTextTools;
112
113   private ITextEditor fTextEditor;
114
115   /**
116    * The document partitioning.
117    *
118    * @since 3.0
119    */
120   private String fDocumentPartitioning;
121
122   private ContentFormatter fFormatter;
123
124   /**
125    * Single token scanner.
126    */
127   static class SingleTokenScanner extends BufferedRuleBasedScanner {
128     public SingleTokenScanner(TextAttribute attribute) {
129       setDefaultReturnToken(new Token(attribute));
130     }
131   };
132
133   /**
134    * The document partitioning.
135    *
136    * @since 3.0
137    */
138   //  private String fDocumentPartitioning;
139   /**
140    * The Java source code scanner
141    *
142    * @since 3.0
143    */
144   private AbstractJavaScanner fCodeScanner;
145
146   /**
147    * The Java multi-line comment scanner
148    *
149    * @since 3.0
150    */
151   private AbstractJavaScanner fMultilineCommentScanner;
152
153   /**
154    * The Java single-line comment scanner
155    *
156    * @since 3.0
157    */
158   private AbstractJavaScanner fSinglelineCommentScanner;
159
160   /**
161    * The PHP double quoted string scanner
162    */
163   private AbstractJavaScanner fStringDQScanner;
164   /**
165    * The PHP single quoted string scanner
166    */
167   private AbstractJavaScanner fStringSQScanner;
168
169   /**
170    * The Javadoc scanner
171    *
172    * @since 3.0
173    */
174   private AbstractJavaScanner fJavaDocScanner;
175
176   /**
177    * The preference store, can be read-only
178    *
179    * @since 3.0
180    */
181   private IPreferenceStore fPreferenceStore;
182
183   /**
184    * The color manager
185    *
186    * @since 3.0
187    */
188   private IColorManager fColorManager;
189
190   private XMLTextTools fXMLTextTools;
191
192   private XMLConfiguration xmlConfiguration;
193
194   /**
195    * Creates a new Java source viewer configuration for viewers in the given editor using the given preference store, the color
196    * manager and the specified document partitioning.
197    * <p>
198    * Creates a Java source viewer configuration in the new setup without text tools. Clients are allowed to call
199    * {@link JavaSourceViewerConfiguration#handlePropertyChangeEvent(PropertyChangeEvent)}and disallowed to call
200    * {@link JavaSourceViewerConfiguration#getPreferenceStore()}on the resulting Java source viewer configuration.
201    * </p>
202    *
203    * @param colorManager
204    *          the color manager
205    * @param preferenceStore
206    *          the preference store, can be read-only
207    * @param editor
208    *          the editor in which the configured viewer(s) will reside
209    * @param partitioning
210    *          the document partitioning for this configuration
211    * @since 3.0
212    */
213   public PHPSourceViewerConfiguration(IColorManager colorManager, IPreferenceStore preferenceStore, ITextEditor editor,
214       String partitioning) {
215     fColorManager = colorManager;
216     fPreferenceStore = preferenceStore;
217     fTextEditor = editor;
218     fDocumentPartitioning = partitioning;
219     //    fJavaTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
220     fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
221     xmlConfiguration = new XMLConfiguration(fXMLTextTools);
222     fColorManager = colorManager;
223     fPreferenceStore = preferenceStore;
224     fTextEditor = editor;
225     fDocumentPartitioning = partitioning;
226
227     initializeScanners();
228   }
229
230   /**
231    * Creates a new Java source viewer configuration for viewers in the given editor using the given Java tools.
232    *
233    * @param tools
234    *          the Java text tools to be used
235    * @param editor
236    *          the editor in which the configured viewer(s) will reside
237    * @see JavaTextTools
238    * @deprecated As of 3.0, replaced by
239    *             {@link JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)}
240    */
241   //  public PHPSourceViewerConfiguration(JavaTextTools tools, PHPEditor editor, String partitioning) {
242   //    fJavaTextTools = tools;
243   //    fColorManager = tools.getColorManager();
244   //    fPreferenceStore = createPreferenceStore();
245   //    fDocumentPartitioning = partitioning;
246   //    fCodeScanner = (AbstractJavaScanner) fJavaTextTools.getCodeScanner();
247   //    fMultilineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getMultilineCommentScanner();
248   //    fSinglelineCommentScanner = (AbstractJavaScanner) fJavaTextTools.getSinglelineCommentScanner();
249   //    fStringDQScanner = (AbstractJavaScanner) fJavaTextTools.getStringScanner();
250   //    fJavaDocScanner = (AbstractJavaScanner) fJavaTextTools.getJavaDocScanner();
251   //    fTextEditor = editor;
252   //    fXMLTextTools = XMLPlugin.getDefault().getXMLTextTools();
253   //    xmlConfiguration = new XMLConfiguration(fXMLTextTools);
254   //  }
255   /**
256    * Returns the color manager for this configuration.
257    *
258    * @return the color manager
259    */
260   protected IColorManager getColorManager() {
261     return fColorManager;
262   }
263
264   /**
265    * Initializes the scanners.
266    *
267    * @since 3.0
268    */
269   private void initializeScanners() {
270 //    Assert.isTrue(isNewSetup());
271     fCodeScanner = new PHPCodeScanner(getColorManager(), fPreferenceStore);
272     fMultilineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
273         IPreferenceConstants.PHP_MULTILINE_COMMENT);
274     fSinglelineCommentScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore,
275         IPreferenceConstants.PHP_SINGLELINE_COMMENT);
276 //    fStringDQScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING_DQ);
277     fStringDQScanner = new PHPStringDQCodeScanner(getColorManager(), fPreferenceStore);
278     fStringSQScanner = new SingleTokenPHPScanner(getColorManager(), fPreferenceStore, IPreferenceConstants.PHP_STRING_SQ);
279     fJavaDocScanner = new PHPDocCodeScanner(getColorManager(), fPreferenceStore);
280   }
281
282   /**
283    * Determines whether the preference change encoded by the given event changes the behavior of one of its contained components.
284    *
285    * @param event
286    *          the event to be investigated
287    * @return <code>true</code> if event causes a behavioral change
288    * @since 3.0
289    */
290   public boolean affectsTextPresentation(PropertyChangeEvent event) {
291     return fCodeScanner.affectsBehavior(event) || fMultilineCommentScanner.affectsBehavior(event)
292         || fSinglelineCommentScanner.affectsBehavior(event) || fStringDQScanner.affectsBehavior(event)|| fStringSQScanner.affectsBehavior(event)
293         || fJavaDocScanner.affectsBehavior(event);
294   }
295
296   /**
297    * Adapts the behavior of the contained components to the change encoded in the given event.
298    * <p>
299    * Clients are not allowed to call this method if the old setup with text tools is in use.
300    * </p>
301    *
302    * @param event
303    *          the event to which to adapt
304    * @see JavaSourceViewerConfiguration#JavaSourceViewerConfiguration(IColorManager, IPreferenceStore, ITextEditor, String)
305    * @since 3.0
306    */
307   public void handlePropertyChangeEvent(PropertyChangeEvent event) {
308 //    Assert.isTrue(isNewSetup());
309     if (fCodeScanner.affectsBehavior(event))
310       fCodeScanner.adaptToPreferenceChange(event);
311     if (fMultilineCommentScanner.affectsBehavior(event))
312       fMultilineCommentScanner.adaptToPreferenceChange(event);
313     if (fSinglelineCommentScanner.affectsBehavior(event))
314       fSinglelineCommentScanner.adaptToPreferenceChange(event);
315     if (fStringDQScanner.affectsBehavior(event))
316       fStringDQScanner.adaptToPreferenceChange(event);
317     if (fStringSQScanner.affectsBehavior(event))
318       fStringSQScanner.adaptToPreferenceChange(event);
319     if (fJavaDocScanner.affectsBehavior(event))
320       fJavaDocScanner.adaptToPreferenceChange(event);
321   }
322
323   /*
324    * @see SourceViewerConfiguration#getContentFormatter(ISourceViewer)
325    */
326   public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
327     //    if (fFormatter == null) {
328     //      fFormatter = new ContentFormatter();
329     //      fFormattingStrategy = new HTMLFormattingStrategy(this,
330     // sourceViewer);
331     //      fFormatter.setFormattingStrategy(fFormattingStrategy, HTML_DEFAULT);
332     //      fFormatter.enablePartitionAwareFormatting(false);
333     //      fFormatter.setPartitionManagingPositionCategories(getConfiguredContentTypes(null));
334     //    }
335     //    return fFormatter;
336     if (fFormatter == null) {
337       //ContentFormatter
338       fFormatter = new ContentFormatter();
339       IFormattingStrategy strategy = new JavaFormattingStrategy(sourceViewer);
340       fFormatter.setFormattingStrategy(strategy, IDocument.DEFAULT_CONTENT_TYPE);
341       fFormatter.enablePartitionAwareFormatting(false);
342       fFormatter.setPartitionManagingPositionCategories(getPartitionManagingPositionCategories());
343     }
344     return fFormatter;
345   }
346
347   /**
348    * Returns the names of the document position categories used by the document partitioners created by this object to manage their
349    * partition information. If the partitioners don't use document position categories, the returned result is <code>null</code>.
350    *
351    * @return the partition managing position categories or <code>null</code> if there is none
352    */
353   public String[] getPartitionManagingPositionCategories() {
354     return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
355   }
356
357   //  /**
358   //   * Returns the names of the document position categories used by the
359   // document
360   //   * partitioners created by this object to manage their partition
361   // information.
362   //   * If the partitioners don't use document position categories, the
363   // returned
364   //   * result is <code>null</code>.
365   //   *
366   //   * @return the partition managing position categories or
367   // <code>null</code>
368   //   * if there is none
369   //   */
370   //  private String[] getPartitionManagingPositionCategories() {
371   //    return new String[] { DefaultPartitioner.CONTENT_TYPES_CATEGORY };
372   //  }
373   public ITextEditor getEditor() {
374     return fTextEditor;
375   }
376
377   /**
378    * Returns the preference store used by this configuration to initialize the individual bits and pieces.
379    *
380    * @return the preference store used to initialize this configuration
381    *
382    * @since 2.0
383    */
384   protected IPreferenceStore getPreferenceStore() {
385     return PHPeclipsePlugin.getDefault().getPreferenceStore();
386   }
387
388   //  /* (non-Javadoc)
389   //   * Method declared on SourceViewerConfiguration
390   //   */
391   //  public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
392   //    return new PHPAnnotationHover();
393   //  }
394   /*
395    * @see SourceViewerConfiguration#getAnnotationHover(ISourceViewer)
396    */
397   public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
398     return new JavaAnnotationHover(JavaAnnotationHover.VERTICAL_RULER_HOVER);
399   }
400
401   /*
402    * @see SourceViewerConfiguration#getOverviewRulerAnnotationHover(ISourceViewer)
403    * @since 3.0
404    */
405   public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
406     return new JavaAnnotationHover(JavaAnnotationHover.OVERVIEW_RULER_HOVER);
407   }
408
409   /*
410    * (non-Javadoc) Method declared on SourceViewerConfiguration
411    */
412   public IAutoEditStrategy getAutoEditStrategy(ISourceViewer sourceViewer, String contentType) {
413     if (IPHPPartitions.PHP_PHPDOC_COMMENT.equals(contentType)
414         || IPHPPartitions.PHP_MULTILINE_COMMENT.equals(contentType))
415       return new JavaDocAutoIndentStrategy(getConfiguredDocumentPartitioning(sourceViewer));
416     if (IPHPPartitions.PHP_STRING_DQ.equals(contentType))
417       return new JavaStringAutoIndentStrategyDQ(getConfiguredDocumentPartitioning(sourceViewer));
418     if (IPHPPartitions.PHP_STRING_SQ.equals(contentType))
419       return new JavaStringAutoIndentStrategySQ(getConfiguredDocumentPartitioning(sourceViewer));
420
421     return (PHPDocumentPartitioner.PHP_TEMPLATE_DATA.equals(contentType)
422         || PHPDocumentPartitioner.PHP_SCRIPT_CODE.equals(contentType) || IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)
423         || IPHPPartitions.PHP_PARTITIONING.equals(contentType) || PHPPartitionScanner.PHP_SCRIPTING_AREA.equals(contentType) ? new PHPAutoIndentStrategy()
424         : new DefaultIndentLineAutoEditStrategy());
425   }
426
427   /**
428    * Returns the PHP source code scanner for this configuration.
429    *
430    * @return the PHP source code scanner
431    */
432   protected RuleBasedScanner getCodeScanner() {
433     return fCodeScanner; //fJavaTextTools.getCodeScanner();
434   }
435
436   /**
437    * Returns the Java multi-line comment scanner for this configuration.
438    *
439    * @return the Java multi-line comment scanner
440    * @since 2.0
441    */
442   protected RuleBasedScanner getMultilineCommentScanner() {
443     return fMultilineCommentScanner;
444   }
445
446   /**
447    * Returns the Java single-line comment scanner for this configuration.
448    *
449    * @return the Java single-line comment scanner
450    * @since 2.0
451    */
452   protected RuleBasedScanner getSinglelineCommentScanner() {
453     return fSinglelineCommentScanner;
454   }
455
456   /**
457    * Returns the PHP double quoted string scanner for this configuration.
458    *
459    * @return the PHP double quoted string scanner
460    */
461   protected RuleBasedScanner getStringDQScanner() {
462     return fStringDQScanner;
463   }
464
465   /**
466    * Returns the PHP single quoted string scanner for this configuration.
467    *
468    * @return the PHP single quoted string scanner
469    */
470   protected RuleBasedScanner getStringSQScanner() {
471     return fStringSQScanner;
472   }
473   /**
474    * Returns the HTML source code scanner for this configuration.
475    *
476    * @return the HTML source code scanner
477    */
478   //  protected RuleBasedScanner getHTMLScanner() {
479   //    return fJavaTextTools.getHTMLScanner();
480   //  }
481   /**
482    * Returns the Smarty source code scanner for this configuration.
483    *
484    * @return the Smarty source code scanner
485    */
486   //  protected RuleBasedScanner getSmartyScanner() {
487   //    return fJavaTextTools.getSmartyScanner();
488   //  }
489   /*
490    * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
491    */
492   /*
493    * @see SourceViewerConfiguration#getReconciler(ISourceViewer)
494    */
495   public IReconciler getReconciler(ISourceViewer sourceViewer) {
496
497     final ITextEditor editor = getEditor();
498     if (editor != null && editor.isEditable()) {
499
500       JavaCompositeReconcilingStrategy strategy = new JavaCompositeReconcilingStrategy(editor,
501           getConfiguredDocumentPartitioning(sourceViewer));
502       JavaReconciler reconciler = new JavaReconciler(editor, strategy, false);
503       reconciler.setIsIncrementalReconciler(false);
504       reconciler.setProgressMonitor(new NullProgressMonitor());
505       reconciler.setDelay(500);
506
507       return reconciler;
508     }
509     return null;
510   }
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    * Returns the PHPDoc source code scanner for this configuration.
585    *
586    * @return the PHPDoc source code scanner
587    */
588   protected RuleBasedScanner getPHPDocScanner() {
589     return fJavaDocScanner; //fJavaTextTools.getJavaDocScanner();
590   }
591
592   /*
593    * (non-Javadoc) Method declared on SourceViewerConfiguration
594    */
595   public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
596     return new String[] { IDocument.DEFAULT_CONTENT_TYPE, PHPPartitionScanner.PHP_SCRIPTING_AREA,
597
598     IPHPPartitions.HTML, IPHPPartitions.HTML_MULTILINE_COMMENT, IPHPPartitions.PHP_PARTITIONING,
599         IPHPPartitions.PHP_SINGLELINE_COMMENT, IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT,
600         IPHPPartitions.PHP_STRING_DQ, IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.PHP_STRING_HEREDOC, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT,
601         IPHPPartitions.JAVASCRIPT, IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY,
602         IPHPPartitions.SMARTY_MULTILINE_COMMENT,
603
604         XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL, XMLPartitionScanner.XML_TAG,
605         XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
606
607         XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
608         XMLPartitionScanner.DTD_INTERNAL_DECL,
609
610         PHPDocumentPartitioner.PHP_TEMPLATE_DATA, PHPDocumentPartitioner.PHP_SCRIPT_CODE };
611   }
612
613   public String[] getConfiguredHTMLContentTypes() {
614     return new String[] { XMLPartitionScanner.XML_PI, XMLPartitionScanner.XML_COMMENT, XMLPartitionScanner.XML_DECL,
615         XMLPartitionScanner.XML_TAG, XMLPartitionScanner.XML_ATTRIBUTE, XMLPartitionScanner.XML_CDATA,
616
617         XMLPartitionScanner.DTD_INTERNAL, XMLPartitionScanner.DTD_INTERNAL_PI, XMLPartitionScanner.DTD_INTERNAL_COMMENT,
618         XMLPartitionScanner.DTD_INTERNAL_DECL, };
619   }
620
621   public String[] getConfiguredPHPContentTypes() {
622     return new String[] { IDocument.DEFAULT_CONTENT_TYPE, IPHPPartitions.PHP_PARTITIONING, IPHPPartitions.PHP_SINGLELINE_COMMENT,
623         IPHPPartitions.PHP_MULTILINE_COMMENT, IPHPPartitions.PHP_PHPDOC_COMMENT, IPHPPartitions.PHP_STRING_DQ,
624         IPHPPartitions.PHP_STRING_SQ, IPHPPartitions.PHP_STRING_HEREDOC, IPHPPartitions.CSS, IPHPPartitions.CSS_MULTILINE_COMMENT, IPHPPartitions.JAVASCRIPT,
625         IPHPPartitions.JS_MULTILINE_COMMENT, IPHPPartitions.SMARTY, IPHPPartitions.SMARTY_MULTILINE_COMMENT, };
626   }
627
628   /*
629    * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getConfiguredDocumentPartitioning(org.eclipse.jface.text.source.ISourceViewer)
630    * @since 3.0
631    */
632   public String getConfiguredDocumentPartitioning(ISourceViewer sourceViewer) {
633     if (fDocumentPartitioning != null)
634       return fDocumentPartitioning;
635     return super.getConfiguredDocumentPartitioning(sourceViewer);
636   }
637
638   /*
639    * (non-Javadoc) Method declared on SourceViewerConfiguration
640    */
641   public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
642     ContentAssistant assistant = new ContentAssistant();
643     IContentAssistProcessor processor = new HTMLCompletionProcessor(getEditor());
644     assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
645     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML);
646     assistant.setContentAssistProcessor(processor, IPHPPartitions.HTML_MULTILINE_COMMENT);
647
648     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS);
649     assistant.setContentAssistProcessor(processor, IPHPPartitions.CSS_MULTILINE_COMMENT);
650     assistant.setContentAssistProcessor(processor, IPHPPartitions.JAVASCRIPT);
651     assistant.setContentAssistProcessor(processor, IPHPPartitions.JS_MULTILINE_COMMENT);
652     // TODO define special smarty partition content assist
653     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY);
654     assistant.setContentAssistProcessor(processor, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
655
656     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
657     String[] htmlTypes = getConfiguredHTMLContentTypes();
658     for (int i = 0; i < htmlTypes.length; i++) {
659       assistant.setContentAssistProcessor(processor, htmlTypes[i]);
660     }
661     processor = new PHPCompletionProcessor(getEditor());
662
663     assistant.setContentAssistProcessor(processor, PHPDocumentPartitioner.PHP_SCRIPT_CODE);
664     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_PARTITIONING);
665     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_DQ);
666     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_SQ);
667     assistant.setContentAssistProcessor(processor, IPHPPartitions.PHP_STRING_HEREDOC);
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(getStringDQScanner());
816     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_DQ);
817     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_DQ);
818     phpDR = new DefaultDamagerRepairer(getStringSQScanner());
819     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_SQ);
820     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_SQ);
821     phpDR = new DefaultDamagerRepairer(getStringDQScanner());
822     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_STRING_HEREDOC);
823     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_STRING_HEREDOC);
824     phpDR = new DefaultDamagerRepairer(getSinglelineCommentScanner());
825     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
826     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_SINGLELINE_COMMENT);
827     phpDR = new DefaultDamagerRepairer(getMultilineCommentScanner());
828     phpReconciler.setDamager(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
829     phpReconciler.setRepairer(phpDR, IPHPPartitions.PHP_MULTILINE_COMMENT);
830
831     PresentationReconciler reconciler = new PresentationReconciler();
832     reconciler.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
833     //
834 //    JavaTextTools jspTextTools = PHPeclipsePlugin.getDefault().getJavaTextTools();
835     DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getPHPDocScanner());//jspTextTools.getJSPTextScanner());
836     reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
837     reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
838
839     //  dr = new DefaultDamagerRepairer(new SingleTokenScanner(new TextAttribute(fJavaTextTools.getColorManager().getColor(
840     //        PHPColorProvider.PHPDOC_TAG))));//jspTextTools.getJSPBracketScanner());
841     //  reconciler.setDamager(dr, JSPScriptScanner.JSP_BRACKET);
842     //  reconciler.setRepairer(dr, JSPScriptScanner.JSP_BRACKET);
843
844     // xml partitions
845     configureEmbeddedPresentationReconciler(reconciler, xmlConfiguration.getPresentationReconciler(sourceViewer), xmlConfiguration
846         .getConfiguredContentTypes(sourceViewer), PHPDocumentPartitioner.PHP_TEMPLATE_DATA);
847
848     // java partitions
849     configureEmbeddedPresentationReconciler(reconciler, phpReconciler, getConfiguredPHPContentTypes(),
850         PHPDocumentPartitioner.PHP_SCRIPT_CODE);
851
852     return reconciler;
853   }
854
855   private void configureEmbeddedPresentationReconciler(PresentationReconciler reconciler, IPresentationReconciler embedded,
856       String[] types, String defaultType) {
857     for (int i = 0; i < types.length; i++) {
858       String type = types[i];
859
860       IPresentationDamager damager = embedded.getDamager(type);
861       IPresentationRepairer repairer = embedded.getRepairer(type);
862
863       if (type == IDocument.DEFAULT_CONTENT_TYPE) {
864         type = defaultType;
865       }
866
867       reconciler.setDamager(damager, type);
868       reconciler.setRepairer(repairer, type);
869     }
870   }
871
872   /*
873    * (non-Javadoc) Method declared on SourceViewerConfiguration
874    */
875   public int getTabWidth(ISourceViewer sourceViewer) {
876     return getPreferenceStore().getInt(PREFERENCE_TAB_WIDTH);
877   }
878
879   /*
880    * (non-Javadoc) Method declared on SourceViewerConfiguration
881    */
882   //  public ITextHover getTextHover(ISourceViewer sourceViewer, String
883   // contentType) {
884   //    if (fEditor != null) {
885   //      IEditorInput editorInput = fEditor.getEditorInput();
886   //      if (editorInput instanceof IFileEditorInput) {
887   //        try {
888   //          IFile f = ((IFileEditorInput) editorInput).getFile();
889   //          return new PHPTextHover(f.getProject());
890   //        } catch (NullPointerException e) {
891   //          // this exception occurs, if getTextHover is called by preference pages
892   // !
893   //        }
894   //      }
895   //    }
896   //    return new PHPTextHover(null);
897   //  }
898   /*
899    * @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
900    * @since 2.0
901    */
902   public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
903     return new IInformationControlCreator() {
904       public IInformationControl createInformationControl(Shell parent) {
905         return new DefaultInformationControl(parent, SWT.NONE, new HTMLTextPresenter(true));
906         // return new HoverBrowserControl(parent);
907       }
908     };
909   }
910
911   /*
912    * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
913    * @since 2.0
914    */
915   public IInformationPresenter getInformationPresenter(ISourceViewer sourceViewer) {
916     InformationPresenter presenter = new InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
917     presenter.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
918     IInformationProvider provider = new JavaInformationProvider(getEditor());
919     presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
920     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
921     //          presenter.setInformationProvider(provider, IPHPPartitions.JAVA_CHARACTER);
922     presenter.setSizeConstraints(60, 10, true, true);
923     return presenter;
924   }
925
926   /*
927    * @see SourceViewerConfiguration#getInformationPresenter(ISourceViewer)
928    * @since 2.0
929    */
930   //    public IInformationPresenter getInformationPresenter(ISourceViewer
931   // sourceViewer) {
932   //            InformationPresenter presenter= new
933   // InformationPresenter(getInformationPresenterControlCreator(sourceViewer));
934   //            IInformationProvider provider= new JavaInformationProvider(getEditor());
935   //            presenter.setInformationProvider(provider,
936   // IDocument.DEFAULT_CONTENT_TYPE);
937   //            presenter.setInformationProvider(provider, IJavaPartitions.JAVA_DOC);
938   //            presenter.setSizeConstraints(60, 10, true, true);
939   //            return presenter;
940   //    }
941   /**
942    * Returns the information presenter control creator. The creator is a factory creating the presenter controls for the given
943    * source viewer. This implementation always returns a creator for <code>DefaultInformationControl</code> instances.
944    *
945    * @param sourceViewer
946    *          the source viewer to be configured by this configuration
947    * @return an information control creator
948    * @since 2.1
949    */
950   private IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
951     return new IInformationControlCreator() {
952       public IInformationControl createInformationControl(Shell parent) {
953         int shellStyle = SWT.RESIZE;
954         int style = SWT.V_SCROLL | SWT.H_SCROLL;
955         return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
956         // return new HoverBrowserControl(parent);
957       }
958     };
959   }
960
961   /**
962    * Returns the outline presenter control creator. The creator is a factory creating outline presenter controls for the given
963    * source viewer. This implementation always returns a creator for <code>JavaOutlineInformationControl</code> instances.
964    *
965    * @param sourceViewer
966    *          the source viewer to be configured by this configuration
967    * @return an information control creator
968    * @since 2.1
969    */
970   private IInformationControlCreator getOutlinePresenterControlCreator(ISourceViewer sourceViewer) {
971     return new IInformationControlCreator() {
972       public IInformationControl createInformationControl(Shell parent) {
973         int shellStyle = SWT.RESIZE;
974         int treeStyle = SWT.V_SCROLL | SWT.H_SCROLL;
975         return new JavaOutlineInformationControl(parent, shellStyle, treeStyle);
976       }
977     };
978   }
979
980   /**
981    * Returns the outline presenter which will determine and shown information requested for the current cursor position.
982    *
983    * @param sourceViewer
984    *          the source viewer to be configured by this configuration
985    * @param doCodeResolve
986    *          a boolean which specifies whether code resolve should be used to compute the Java element
987    * @return an information presenter
988    * @since 2.1
989    */
990   public IInformationPresenter getOutlinePresenter(ISourceViewer sourceViewer, boolean doCodeResolve) {
991     InformationPresenter presenter = new InformationPresenter(getOutlinePresenterControlCreator(sourceViewer));
992     presenter.setAnchor(InformationPresenter.ANCHOR_GLOBAL);
993     IInformationProvider provider = new JavaElementProvider(getEditor(), doCodeResolve);
994     presenter.setInformationProvider(provider, IDocument.DEFAULT_CONTENT_TYPE);
995     presenter.setInformationProvider(provider, PHPDocumentPartitioner.PHP_SCRIPT_CODE);
996     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PARTITIONING);
997     presenter.setInformationProvider(provider, IPHPPartitions.PHP_PHPDOC_COMMENT);
998     presenter.setInformationProvider(provider, IPHPPartitions.SMARTY_MULTILINE_COMMENT);
999     presenter.setInformationProvider(provider, IPHPPartitions.HTML);
1000     presenter.setInformationProvider(provider, IPHPPartitions.HTML_MULTILINE_COMMENT);
1001     presenter.setSizeConstraints(40, 20, true, false);
1002     return presenter;
1003   }
1004 }