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