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