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