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