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